-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UI: Migrate to Storybook #6507
Merged
Merged
UI: Migrate to Storybook #6507
Changes from 148 commits
Commits
Show all changes
158 commits
Select commit
Hold shift + click to select a range
e2585c3
Add working Storybook configuration
backspace 2b73ee4
Remove port from Storybook build command
backspace 74573fd
Add empty commit
backspace 19c3038
Add missing ampersand
backspace f7ee279
Add Babel dependency
backspace 461b083
Change to master branch
backspace 57be30b
Change root URL temporarily
backspace e4c4960
Change Ember to build for test environment
backspace 2a720cb
Change environment for live Storybook
backspace 221a63c
Add story generator and Markdown generator
backspace 6b618f3
Add first generated story
backspace 1f81399
Fix lint errors
backspace 5a7233f
Change copy-button example to match Freestyle
backspace 7001a75
Change GitHub search paths
backspace 02fff45
Add notes Storybook addon
backspace 75eba13
Change generator to use curly-bracket invocation
backspace a45b4d6
Add json-viewer story
backspace 3f2a0a3
Remove test story
backspace fc6779a
Move lengthy example JSON below story definition
backspace de400a7
Add margin around canvas
backspace 5f00359
Update copy-button JSDoc
backspace 5a34dbd
Move extracted variables into definition
backspace 19c2ce2
Add header for copy button
backspace f522df5
Change notes link strings
backspace e25174c
Remove superfluous backticks
backspace cca35ce
Add demonstration knob
backspace d67bdeb
Change back to angle bracket invocation
backspace 9d57507
Add theme
backspace 2b08862
Add note about known issue with JsonViewer
backspace 00a445f
Change CopyButton text
backspace ca0172c
Add code wrapper for component names in links
backspace d373211
Add ESLint directive for stories
backspace c3d25ca
Remove currently-broken assertion
backspace 8cc8b9b
Add autofix ESLint changes
backspace 197d796
Add stories directory to lint-staged task
backspace 81daf7a
Add viewport addon
backspace 44b8eff
Remove panel for JsonViewer
backspace bcd6f13
Update known issue to say it’s intermittent
backspace 5853e10
Add preliminary ListAccordion component
backspace 1ddb57f
Add spacing between stories
backspace af0bb0d
Add storysource addon
backspace ebbf652
Merge remote-tracking branch 'origin/master' into f-ui/storybook
backspace 6ea438c
Update accordion to have three stories
backspace 6edf17d
Update JsonViewer to have two stories
backspace eaaad5a
Add two-step button stories
backspace fd42609
Add alerts stories
backspace ad30ee5
Change casing to be consistent
backspace 7e2349a
Add Freestyle styles inside Storybook
backspace a4d44d3
Add boxed section stories
backspace d9ca89e
Add breadcrumbs stories
backspace 0777713
Add styling for story annotations
backspace 89413f6
Update stories to CSF
backspace 5156552
Add stories directory for auto-linting
backspace e6377b5
Add auto-fixed stories formatting
backspace ff62602
Add proxy tag story
backspace 8e11bf4
Add annotation classes to alerts stories
backspace d920598
Add ESLint fixes
backspace 8c4e46b
Add theme stories
backspace efd54c6
Move component stories into a grouping
backspace ca90035
Add job-diff stories
backspace 9b03dfc
Add subdirectory for generated notes
backspace 7a9e106
Add note about necessary code
backspace cf42251
Add dropdown stories
backspace 9376a95
Add gutter menu stories
backspace e552065
Add header story
backspace cfd5640
Add inline definitions stories
backspace 6c21249
Add log stream story
backspace 6a4f070
Add metrics stories
backspace fc4c8d5
Add multi-select stories
backspace 8788716
Add page tabs stories
backspace 2fd3d31
Add page title stories
backspace 5afc701
Add search box stories
backspace 74783f5
Add table stories
backspace 7688aad
Add attributes table story
backspace ac82bb9
Add timeline stories
backspace e40f6ed
Add distribution bar stories
backspace e36e728
Add jumbo distribution bar story
backspace 2856bab
Add Babel configuration to fix story Ember imports
backspace c4bf802
Add line chart stories
backspace e813386
Add progress bar stories
backspace 6a7be52
Add stats time series stories
backspace 299137a
Remove unused imports
backspace ae1e7f6
Change initialiser to not use prototype extension
backspace d0dbee5
Mark file for Node context
backspace 9cb00b4
Change sorting of story sections in sidebar
backspace 9e28e07
Change stories titles for consistency
backspace 1567fa0
Add missing buttons stories
backspace 19a9925
Change to “Standard” standard for first story
backspace d827856
Change story title case to be consistent
backspace c86a311
Update missed story title
backspace 6e4c114
Remove addon-related story-generation code
backspace 385eef9
Add handling for charts in documentation generator
backspace 4caa869
Remove “main index” from notes template
backspace cd9b181
Fix data for line chart with gaps
backspace ace7a18
Remove notes
backspace ad94ee6
Change storybook port to new default
backspace 0538f14
Remove --ci flag post-development
backspace 965c4a1
Revert mistaken changes
backspace 954b746
Remove outdated TODO
backspace 9db5e63
Move dependency
backspace e1ddb05
Add ESLint configuration for stories directory
backspace 3ed7648
Remove FIXMEs relating to using Freestyle elements
backspace 3c41ffc
Update tabs to not navigate when clicking
backspace 8afc706
Fix boxed section contexts
backspace 58b9758
Fix table sorting and pagination
backspace d3a3943
Add hacks to get charts to render properly
backspace 46fc64c
Apply delayer fixes to JSON Viewer stories
backspace 3e82671
Remove unused import
backspace d58501c
Change story templates to have regular indents
backspace a9eaddd
Fix more indentation
backspace 8dbe4dd
Remove unused property
backspace 1f8b992
Fix StatsTimeSeries chart data
backspace e140675
Move story panel before knobs panel
backspace 85183a8
Change addons panel to show by default
backspace 6d6e649
Fix more links to not promote iframe to parent
backspace 0c7bb66
Update Storybook and addon versions
backspace cadbd6a
Restore root URL
backspace ed41dca
Remove FIXME about Babel configuration
backspace 2ec98df
Rename container element
backspace a680cf0
Add explanation of sorting
backspace d5073d9
Restore addons panel for JSON Viewer story
backspace f9d8c3b
Update theme elements
backspace 46ae4a3
Add missing dependencies
backspace 93fb49f
Remove in-repo-addon-related code from blueprint
backspace d9450f3
Change blueprint to generate into subdirectory
backspace 0a3fece
Restore true root URL
backspace 16be24e
Remove unused variable
backspace b0b1ba3
Remove superfluous resolution
backspace 9f8f151
Change wrapper namings for clarity
backspace a7fa713
Remove superfluous comment
backspace 905a98b
Move delay utilities into subdirectory
backspace 788baae
Change delay utilities to use next vs later
backspace 75202cb
Add spacing between fonts
backspace ec544c8
Add explanations of delay utilities
backspace 5f9a00b
Remove Freestyle template, components, and route
backspace ecf8d2f
Fix story title
backspace f5174a9
Change environment to not be test
backspace 58b3c4f
Change environment to not be test
backspace 08c1ae2
Update to latest release of ember-cli-storybook
backspace 2efc14a
Restore removed assertion
backspace 12dcc4f
Add Storybook-specific configuration
backspace 4f25b48
Add base href for Ember iframe
backspace b6bb0ad
Remove target for iframe base element
backspace 14efc18
Add explanation of base element changes
backspace 5dd310b
Remove --ci flag from Storybook script
backspace 45e038b
Change const to let
backspace b5f3d8c
Add Storybook details to README
backspace 2a09d08
Move Storybook packages to optionalDependencies
backspace d3804a8
Change static build to be production
backspace f7e2f31
Merge branch 'master' into f-ui/storybook
backspace a3acaba
Return to development build
backspace 5f53b31
Move ember-cli-storybook to devDependencies
backspace 879c4ea
Remove Freestyle templates
backspace 0184ef8
Fix colour name
backspace 0661843
Merge branch 'master' into f-ui/storybook
backspace a657fa9
Update class attributes to be double-quoted
backspace f8258f0
Update ember-cli-storybook
backspace 8d7def2
Merge branch 'master' into f-ui/storybook
backspace File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
STORYBOOK_NAME=nomad-ui |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import '@storybook/addon-storysource/register'; | ||
import '@storybook/addon-knobs/register'; | ||
import '@storybook/addon-viewport/register'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* eslint-env node */ | ||
module.exports = { | ||
presets: [ | ||
[ | ||
'@babel/preset-env', | ||
{ | ||
shippedProposals: true, | ||
useBuiltIns: 'usage', | ||
corejs: '3', | ||
targets: ['last 1 Chrome versions', 'last 1 Firefox versions', 'last 1 Safari versions'], | ||
}, | ||
], | ||
], | ||
plugins: [ | ||
[ | ||
'@babel/plugin-proposal-decorators', | ||
{ | ||
legacy: true, | ||
}, | ||
], | ||
['@babel/plugin-proposal-class-properties', { loose: true }], | ||
'@babel/plugin-syntax-dynamic-import', | ||
['@babel/plugin-proposal-object-rest-spread', { loose: true, useBuiltIns: true }], | ||
'babel-plugin-macros', | ||
['emotion', { sourceMap: true, autoLabel: true }], | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* eslint-env node */ | ||
import { addDecorator, addParameters, configure } from '@storybook/ember'; | ||
import { INITIAL_VIEWPORTS } from '@storybook/addon-viewport'; | ||
import theme from './theme.js'; | ||
|
||
addParameters({ | ||
viewport: { viewports: INITIAL_VIEWPORTS }, | ||
options: { | ||
showPanel: true, | ||
theme | ||
}, | ||
}); | ||
|
||
addDecorator(storyFn => { | ||
let { template, context } = storyFn(); | ||
|
||
let wrapperElementStyle = { | ||
margin: '20px', | ||
}; | ||
|
||
let applicationWrapperElement = document.createElement('div'); | ||
Object.assign(applicationWrapperElement.style, wrapperElementStyle); | ||
|
||
let storybookElement = document.createElement('div'); | ||
storybookElement.setAttribute('id', 'storybook'); | ||
|
||
let wormhole = document.createElement('div'); | ||
wormhole.setAttribute('id', 'ember-basic-dropdown-wormhole'); | ||
|
||
storybookElement.appendChild(wormhole); | ||
|
||
applicationWrapperElement.appendChild(storybookElement); | ||
storybookElement.appendTo = function appendTo(el) { | ||
el.appendChild(applicationWrapperElement); | ||
}; | ||
|
||
/** | ||
* Stories that require routing (table sorting/pagination) fail | ||
* with the default iframe setup with this error: | ||
* Path /iframe.html does not start with the provided rootURL /ui/ | ||
* | ||
* Changing ENV.rootURL fixes that but then HistoryLocation.getURL | ||
* fails because baseURL is undefined, which is usually set up by | ||
* Ember CLI configuring the base element. This adds the href for | ||
* Ember CLI to use. | ||
* | ||
* The default target="_parent" breaks table sorting and pagination | ||
* by trying to navigate when clicking the query-params-changing | ||
* elements. Removing the base target for the iframe means that | ||
* navigation-requiring links within stories need to have the | ||
* target themselves. | ||
*/ | ||
let baseElement = document.querySelector('base'); | ||
baseElement.setAttribute('href', '/'); | ||
baseElement.removeAttribute('target'); | ||
backspace marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
return { | ||
template, | ||
context, | ||
element: storybookElement, | ||
}; | ||
}); | ||
|
||
// The order of import controls the sorting in the sidebar | ||
backspace marked this conversation as resolved.
Show resolved
Hide resolved
|
||
configure([ | ||
require.context('../stories/theme', true, /\.stories\.js$/), | ||
require.context('../stories/components', true, /\.stories\.js$/), | ||
require.context('../stories/charts', true, /\.stories\.js$/), | ||
], module); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<meta name="nomad-ui/config/environment" content="%7B%22modulePrefix%22%3A%22nomad-ui%22%2C%22environment%22%3A%22development%22%2C%22rootURL%22%3A%22%2F%22%2C%22locationType%22%3A%22auto%22%2C%22EmberENV%22%3A%7B%22FEATURES%22%3A%7B%7D%2C%22EXTEND_PROTOTYPES%22%3A%7B%22Date%22%3Afalse%7D%2C%22_JQUERY_INTEGRATION%22%3Atrue%7D%2C%22APP%22%3A%7B%22blockingQueries%22%3Atrue%2C%22mirageScenario%22%3A%22smallCluster%22%2C%22mirageWithNamespaces%22%3Atrue%2C%22mirageWithTokens%22%3Atrue%2C%22mirageWithRegions%22%3Atrue%2C%22autoboot%22%3Afalse%7D%2C%22ember-cli-mirage%22%3A%7B%22enabled%22%3Atrue%2C%22excludeFilesFromBuild%22%3Afalse%2C%22usingProxy%22%3Afalse%2C%22useDefaultPassthroughs%22%3Atrue%7D%2C%22exportApplicationGlobal%22%3Atrue%7D" /> | ||
<link rel="stylesheet" href="./assets/vendor.css" /> | ||
<link rel="stylesheet" href="./assets/nomad-ui.css" /> | ||
<link rel="icon" href=".//favicon.png" /> | ||
<script> | ||
(function() { | ||
var srcUrl = null; | ||
var host = location.hostname || 'localhost'; | ||
var defaultPort = location.protocol === 'https:' ? 443 : 80; | ||
var port = 4200; | ||
var path = ''; | ||
var prefixURL = ''; | ||
var src = srcUrl || prefixURL + '/_lr/livereload.js?port=' + port + '&host=' + host + path; | ||
var script = document.createElement('script'); | ||
script.type = 'text/javascript'; | ||
script.src = location.protocol + '//' + host + ':4200' + src; | ||
document.getElementsByTagName('head')[0].appendChild(script); | ||
}()); | ||
backspace marked this conversation as resolved.
Show resolved
Hide resolved
|
||
</script> | ||
<script>runningTests = true;</script> | ||
<script src="./assets/vendor.js"></script> | ||
<script src="./assets/nomad-ui.js"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { create } from '@storybook/theming'; | ||
|
||
// From Bulma | ||
let blackBis = 'hsl(0, 0%, 7%)'; | ||
let greyLight = 'hsl(0, 0%, 71%)'; | ||
|
||
// From product-colors.scss | ||
let packerBlue = '#1563ff'; | ||
backspace marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
export default create({ | ||
base: 'light', | ||
|
||
colorPrimary: blackBis, | ||
colorSecondary: packerBlue, | ||
|
||
// UI | ||
appBorderColor: greyLight, | ||
|
||
// Typography | ||
// From variables.scss | ||
fontBase: "-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif", | ||
// From Bulma | ||
fontCode: 'monospace', | ||
|
||
// Text colors | ||
textColor: blackBis, | ||
|
||
// Toolbar default and active colors | ||
barTextColor: greyLight, | ||
barSelectedColor: 'white', | ||
barBg: blackBis, | ||
|
||
brandTitle: 'Nomad Storybook', | ||
brandUrl: 'https://www.nomadproject.io/', | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* eslint-env node */ | ||
module.exports = function({ config }) { | ||
config.module.rules.push({ | ||
test: /\.stories\.jsx?$/, | ||
loaders: [require.resolve('@storybook/source-loader')], | ||
enforce: 'pre', | ||
}); | ||
|
||
return config; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What was this method for? Obvs jumped out at me as it's adding a method onto a DOM element.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It’s what allows us to apply a style to the container element. This is mostly copied from Vault, though I changed some variable names to be more clear.