Skip to content
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 158 commits into from
Jan 21, 2020
Merged
Show file tree
Hide file tree
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 Oct 10, 2019
2b73ee4
Remove port from Storybook build command
backspace Oct 10, 2019
74573fd
Add empty commit
backspace Oct 10, 2019
19c3038
Add missing ampersand
backspace Oct 10, 2019
f7ee279
Add Babel dependency
backspace Oct 10, 2019
461b083
Change to master branch
backspace Oct 10, 2019
57be30b
Change root URL temporarily
backspace Oct 11, 2019
e4c4960
Change Ember to build for test environment
backspace Oct 11, 2019
2a720cb
Change environment for live Storybook
backspace Oct 15, 2019
221a63c
Add story generator and Markdown generator
backspace Oct 15, 2019
6b618f3
Add first generated story
backspace Oct 15, 2019
1f81399
Fix lint errors
backspace Oct 15, 2019
5a7233f
Change copy-button example to match Freestyle
backspace Oct 16, 2019
7001a75
Change GitHub search paths
backspace Oct 16, 2019
02fff45
Add notes Storybook addon
backspace Oct 16, 2019
75eba13
Change generator to use curly-bracket invocation
backspace Oct 16, 2019
a45b4d6
Add json-viewer story
backspace Oct 16, 2019
3f2a0a3
Remove test story
backspace Oct 16, 2019
fc6779a
Move lengthy example JSON below story definition
backspace Oct 16, 2019
de400a7
Add margin around canvas
backspace Oct 16, 2019
5f00359
Update copy-button JSDoc
backspace Oct 16, 2019
5a34dbd
Move extracted variables into definition
backspace Oct 16, 2019
19c2ce2
Add header for copy button
backspace Oct 16, 2019
f522df5
Change notes link strings
backspace Oct 16, 2019
e25174c
Remove superfluous backticks
backspace Oct 16, 2019
cca35ce
Add demonstration knob
backspace Oct 16, 2019
d67bdeb
Change back to angle bracket invocation
backspace Oct 17, 2019
9d57507
Add theme
backspace Oct 17, 2019
2b08862
Add note about known issue with JsonViewer
backspace Oct 17, 2019
00a445f
Change CopyButton text
backspace Oct 17, 2019
ca0172c
Add code wrapper for component names in links
backspace Oct 17, 2019
d373211
Add ESLint directive for stories
backspace Oct 17, 2019
c3d25ca
Remove currently-broken assertion
backspace Oct 17, 2019
8cc8b9b
Add autofix ESLint changes
backspace Oct 17, 2019
197d796
Add stories directory to lint-staged task
backspace Oct 17, 2019
81daf7a
Add viewport addon
backspace Oct 17, 2019
44b8eff
Remove panel for JsonViewer
backspace Oct 17, 2019
bcd6f13
Update known issue to say it’s intermittent
backspace Oct 17, 2019
5853e10
Add preliminary ListAccordion component
backspace Oct 23, 2019
1ddb57f
Add spacing between stories
backspace Oct 23, 2019
af0bb0d
Add storysource addon
backspace Oct 24, 2019
ebbf652
Merge remote-tracking branch 'origin/master' into f-ui/storybook
backspace Oct 24, 2019
6ea438c
Update accordion to have three stories
backspace Oct 24, 2019
6edf17d
Update JsonViewer to have two stories
backspace Oct 24, 2019
eaaad5a
Add two-step button stories
backspace Oct 24, 2019
fd42609
Add alerts stories
backspace Oct 28, 2019
ad30ee5
Change casing to be consistent
backspace Oct 28, 2019
7e2349a
Add Freestyle styles inside Storybook
backspace Oct 28, 2019
a4d44d3
Add boxed section stories
backspace Oct 28, 2019
d9ca89e
Add breadcrumbs stories
backspace Oct 28, 2019
0777713
Add styling for story annotations
backspace Oct 28, 2019
89413f6
Update stories to CSF
backspace Oct 29, 2019
5156552
Add stories directory for auto-linting
backspace Oct 29, 2019
e6377b5
Add auto-fixed stories formatting
backspace Oct 29, 2019
ff62602
Add proxy tag story
backspace Oct 29, 2019
8e11bf4
Add annotation classes to alerts stories
backspace Oct 29, 2019
d920598
Add ESLint fixes
backspace Oct 29, 2019
8c4e46b
Add theme stories
backspace Oct 30, 2019
efd54c6
Move component stories into a grouping
backspace Oct 30, 2019
ca90035
Add job-diff stories
backspace Oct 30, 2019
9b03dfc
Add subdirectory for generated notes
backspace Oct 30, 2019
7a9e106
Add note about necessary code
backspace Oct 30, 2019
cf42251
Add dropdown stories
backspace Oct 30, 2019
9376a95
Add gutter menu stories
backspace Oct 30, 2019
e552065
Add header story
backspace Oct 30, 2019
cfd5640
Add inline definitions stories
backspace Oct 30, 2019
6c21249
Add log stream story
backspace Oct 30, 2019
6a4f070
Add metrics stories
backspace Oct 30, 2019
fc4c8d5
Add multi-select stories
backspace Oct 30, 2019
8788716
Add page tabs stories
backspace Oct 30, 2019
2fd3d31
Add page title stories
backspace Oct 30, 2019
5afc701
Add search box stories
backspace Oct 30, 2019
74783f5
Add table stories
backspace Oct 31, 2019
7688aad
Add attributes table story
backspace Oct 31, 2019
ac82bb9
Add timeline stories
backspace Oct 31, 2019
e40f6ed
Add distribution bar stories
backspace Oct 31, 2019
e36e728
Add jumbo distribution bar story
backspace Oct 31, 2019
2856bab
Add Babel configuration to fix story Ember imports
backspace Nov 1, 2019
c4bf802
Add line chart stories
backspace Nov 1, 2019
e813386
Add progress bar stories
backspace Nov 1, 2019
6a7be52
Add stats time series stories
backspace Nov 1, 2019
299137a
Remove unused imports
backspace Nov 1, 2019
ae1e7f6
Change initialiser to not use prototype extension
backspace Nov 1, 2019
d0dbee5
Mark file for Node context
backspace Nov 1, 2019
9cb00b4
Change sorting of story sections in sidebar
backspace Nov 1, 2019
9e28e07
Change stories titles for consistency
backspace Nov 4, 2019
1567fa0
Add missing buttons stories
backspace Nov 4, 2019
19a9925
Change to “Standard” standard for first story
backspace Nov 4, 2019
d827856
Change story title case to be consistent
backspace Nov 4, 2019
c86a311
Update missed story title
backspace Nov 4, 2019
6e4c114
Remove addon-related story-generation code
backspace Nov 4, 2019
385eef9
Add handling for charts in documentation generator
backspace Nov 4, 2019
4caa869
Remove “main index” from notes template
backspace Nov 4, 2019
cd9b181
Fix data for line chart with gaps
backspace Nov 4, 2019
ace7a18
Remove notes
backspace Nov 4, 2019
ad94ee6
Change storybook port to new default
backspace Nov 4, 2019
0538f14
Remove --ci flag post-development

backspace Nov 4, 2019
965c4a1
Revert mistaken changes
backspace Nov 4, 2019
954b746
Remove outdated TODO
backspace Nov 4, 2019
9db5e63
Move dependency
backspace Nov 4, 2019
e1ddb05
Add ESLint configuration for stories directory
backspace Nov 4, 2019
3ed7648
Remove FIXMEs relating to using Freestyle elements
backspace Nov 4, 2019
3c41ffc
Update tabs to not navigate when clicking
backspace Nov 4, 2019
8afc706
Fix boxed section contexts
backspace Nov 4, 2019
58b9758
Fix table sorting and pagination
backspace Nov 5, 2019
d3a3943
Add hacks to get charts to render properly
backspace Nov 5, 2019
46fc64c
Apply delayer fixes to JSON Viewer stories
backspace Nov 5, 2019
3e82671
Remove unused import
backspace Nov 5, 2019
d58501c
Change story templates to have regular indents
backspace Nov 5, 2019
a9eaddd
Fix more indentation
backspace Nov 6, 2019
8dbe4dd
Remove unused property
backspace Nov 6, 2019
1f8b992
Fix StatsTimeSeries chart data
backspace Nov 6, 2019
e140675
Move story panel before knobs panel
backspace Nov 6, 2019
85183a8
Change addons panel to show by default
backspace Nov 6, 2019
6d6e649
Fix more links to not promote iframe to parent
backspace Nov 6, 2019
0c7bb66
Update Storybook and addon versions
backspace Nov 6, 2019
cadbd6a
Restore root URL
backspace Nov 6, 2019
ed41dca
Remove FIXME about Babel configuration
backspace Nov 7, 2019
2ec98df
Rename container element
backspace Nov 7, 2019
a680cf0
Add explanation of sorting
backspace Nov 7, 2019
d5073d9
Restore addons panel for JSON Viewer story
backspace Nov 7, 2019
f9d8c3b
Update theme elements
backspace Nov 7, 2019
46ae4a3
Add missing dependencies
backspace Nov 7, 2019
93fb49f
Remove in-repo-addon-related code from blueprint
backspace Nov 7, 2019
d9450f3
Change blueprint to generate into subdirectory
backspace Nov 7, 2019
0a3fece
Restore true root URL
backspace Nov 7, 2019
16be24e
Remove unused variable
backspace Nov 7, 2019
b0b1ba3
Remove superfluous resolution
backspace Nov 7, 2019
9f8f151
Change wrapper namings for clarity
backspace Nov 7, 2019
a7fa713
Remove superfluous comment
backspace Nov 7, 2019
905a98b
Move delay utilities into subdirectory
backspace Nov 7, 2019
788baae
Change delay utilities to use next vs later
backspace Nov 7, 2019
75202cb
Add spacing between fonts
backspace Nov 7, 2019
ec544c8
Add explanations of delay utilities
backspace Nov 7, 2019
5f9a00b
Remove Freestyle template, components, and route
backspace Nov 7, 2019
ecf8d2f
Fix story title
backspace Nov 18, 2019
f5174a9
Change environment to not be test
backspace Nov 21, 2019
58b3c4f
Change environment to not be test
backspace Nov 21, 2019
08c1ae2
Update to latest release of ember-cli-storybook
backspace Nov 21, 2019
2efc14a
Restore removed assertion
backspace Nov 21, 2019
12dcc4f
Add Storybook-specific configuration
backspace Nov 25, 2019
4f25b48
Add base href for Ember iframe
backspace Nov 25, 2019
b6bb0ad
Remove target for iframe base element
backspace Nov 26, 2019
14efc18
Add explanation of base element changes
backspace Nov 26, 2019
5dd310b
Remove --ci flag from Storybook script
backspace Nov 26, 2019
45e038b
Change const to let
backspace Dec 2, 2019
b5f3d8c
Add Storybook details to README
backspace Dec 2, 2019
2a09d08
Move Storybook packages to optionalDependencies
backspace Dec 2, 2019
d3804a8
Change static build to be production
backspace Dec 12, 2019
f7e2f31
Merge branch 'master' into f-ui/storybook
backspace Dec 12, 2019
a3acaba
Return to development build
backspace Dec 12, 2019
5f53b31
Move ember-cli-storybook to devDependencies
backspace Dec 12, 2019
879c4ea
Remove Freestyle templates
backspace Dec 13, 2019
0184ef8
Fix colour name
backspace Dec 13, 2019
0661843
Merge branch 'master' into f-ui/storybook
backspace Dec 13, 2019
a657fa9
Update class attributes to be double-quoted
backspace Jan 17, 2020
f8258f0
Update ember-cli-storybook
backspace Jan 17, 2020
8d7def2
Merge branch 'master' into f-ui/storybook
backspace Jan 21, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ui/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
STORYBOOK_NAME=nomad-ui
13 changes: 13 additions & 0 deletions ui/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,18 @@ module.exports = {
'node/no-unpublished-require': 'off'
}),
},
{
files: [
'stories/**/*.js'
],
parserOptions: {
sourceType: 'module',
},
env: {
browser: false,
node: true,
},
plugins: ['node'],
},
],
};
3 changes: 3 additions & 0 deletions ui/.storybook/addons.js
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';
27 changes: 27 additions & 0 deletions ui/.storybook/babel.config.js
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 }],
],
};
69 changes: 69 additions & 0 deletions ui/.storybook/config.js
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);
};
Copy link
Contributor

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.

Copy link
Contributor Author

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.


/**
* 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);
22 changes: 22 additions & 0 deletions ui/.storybook/preview-head.html
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>
35 changes: 35 additions & 0 deletions ui/.storybook/theme.js
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/',
});
10 changes: 10 additions & 0 deletions ui/.storybook/webpack.config.js
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;
};
6 changes: 6 additions & 0 deletions ui/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ Nomad UI releases are in lockstep with Nomad releases and are integrated into th

* UI branches should be prefix with `f-ui-` for feature work and `b-ui-` for bug fixes. This instructs CI to skip running nomad backend tests.

### Storybook UI Library

The Storybook project provides a browser to see what components and patterns are present in the application and how to use them. You can run it locally with `yarn storybook`. The latest version from the `master` branch is at [`nomad-storybook.netlify.com`](https://nomad-storybook.netlify.com/).

To generate a new story for a component, run `ember generate story component-name`. You can use the existing stories as a guide.

### Troubleshooting

#### The UI is running, but none of the API requests are working
Expand Down
6 changes: 0 additions & 6 deletions ui/app/components/freestyle/sg-accordion.js

This file was deleted.

27 changes: 0 additions & 27 deletions ui/app/components/freestyle/sg-boxed-section.js

This file was deleted.

97 changes: 0 additions & 97 deletions ui/app/components/freestyle/sg-colors.js

This file was deleted.

Loading