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

Theme-ability progress #3572

Merged
merged 55 commits into from
May 19, 2018
Merged
Show file tree
Hide file tree
Changes from 53 commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
e51b713
MOVE & REFACTOR addon-panels to lib/component & glamorous
ndelangen May 10, 2018
16c257e
MOVE & REFACTOR layout component to lib/components & style using glam…
ndelangen May 10, 2018
0fa6a51
MOVE header to lib/component & REFACTOR to use glamorous && ADD glamo…
ndelangen May 10, 2018
4aa547b
UPGRADE glamorous
ndelangen May 11, 2018
67935e7
IMPROVE styling of storysource
ndelangen May 11, 2018
3b461e2
IMRPOVE scrolling behavior
ndelangen May 11, 2018
5f131ca
IMPROVE scrolling of storysource
ndelangen May 11, 2018
d7fe462
FIX a minor alignment issue
ndelangen May 11, 2018
f417484
REFACTOR StoriesPanel to use glamorous && CHANGE mobile layout so pre…
ndelangen May 11, 2018
22f412e
REFACTOR searchbox & shortcutshelp & treeheader to use glamorous && A…
ndelangen May 11, 2018
a5f3cd5
REMOVE babel-plugin-glamorous-displayname from test and prod (has a b…
ndelangen May 11, 2018
0ee32b3
FIX snapshots not updating even when passing in --update
ndelangen May 11, 2018
c7b8d59
CHANGE ui for easier themeing
ndelangen May 11, 2018
7dd7426
FIX proptype warning
ndelangen May 11, 2018
ecdb576
REFACTOR preview wrapper to use glamorous
ndelangen May 11, 2018
fe39ac8
FIX tests && FIX snapshots
ndelangen May 11, 2018
c710cb9
CLEANUP previous mobile nav
ndelangen May 11, 2018
9d7d724
REFACTOR mobile layout to use glamorous
ndelangen May 11, 2018
21bc78f
FIX typo
ndelangen May 11, 2018
fb3c3fc
ADD a placeholder component & use it at places where a 'this is empty…
ndelangen May 11, 2018
88fedce
CHANGE styling of shortcuthelp component
ndelangen May 11, 2018
d0426ba
FIX snapshots
ndelangen May 11, 2018
e0e77b6
ADD 'jest-glamor-react' to get more meaningful snapshots
ndelangen May 11, 2018
60e37f9
FIX babelrc environments
ndelangen May 11, 2018
5aee773
REMOVE dist from test-coverage
ndelangen May 11, 2018
adf9ad7
FIX PropTable & Table/Td/Th
ndelangen May 11, 2018
ea7be29
RENAME RoutedLink & MenuLink
ndelangen May 11, 2018
96f130f
CLEANUP
ndelangen May 11, 2018
679da71
Update storyshots
Hypnosphi May 12, 2018
7559374
REFACTOR to use emotion, see: https://github.com/paypal/glamorous/iss…
ndelangen May 14, 2018
2876570
Merge branch 'feature/more-components' of github.com:storybooks/story…
ndelangen May 14, 2018
30a9899
FIX snapshots
ndelangen May 14, 2018
35049e2
Merge branch 'master' into feature/more-components
ndelangen May 14, 2018
086b74c
FIX linting
ndelangen May 14, 2018
5c974a9
FIX padding
ndelangen May 14, 2018
5eec2c8
FIX styling issue in storysource addon && CLEANUP && ADD emotion-theming
ndelangen May 15, 2018
d28d788
REFACTOR knobs to use emotion for styling
ndelangen May 16, 2018
359f12c
Merge branch 'master' into feature/more-components
ndelangen May 16, 2018
3b517a7
REFACTOR notes to use emotion for styling
ndelangen May 16, 2018
09e3d8e
REFACTOR viewport addon to use emotion for styling && FIX overflow of…
ndelangen May 16, 2018
c6b2b6c
Merge branch 'master' into feature/more-components
ndelangen May 16, 2018
9b01c75
REFACTOR a11y addon to use emotion for styling
ndelangen May 16, 2018
4002f50
REFACTOR background addon to use emotion for styling
ndelangen May 16, 2018
6783d9b
REFACTOR event addon to use emotion for styling
ndelangen May 16, 2018
de48f96
FIX snaphots & tests & linting
ndelangen May 16, 2018
e86936c
IMPROVE desktop layout
ndelangen May 16, 2018
5b10805
FIX double-escaping
ndelangen May 16, 2018
3925f5a
CHANGE package.json files so they are sorted nicely
ndelangen May 16, 2018
d69c0d8
REFACTOR to use emotion for Logger.js
ndelangen May 16, 2018
903d6b1
FIX snapshots
ndelangen May 16, 2018
d33d53b
REFACTOR addon viewport story to use emotion for styling
ndelangen May 16, 2018
aec2521
Merge branch 'master' into feature/more-components
ndelangen May 17, 2018
7d971b8
FIX snapshots
ndelangen May 17, 2018
43279a3
Merge branch 'master' into feature/more-components
ndelangen May 18, 2018
552a01c
FIX review comments
ndelangen May 19, 2018
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
17 changes: 10 additions & 7 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
{
"presets": ["env", "stage-0", "react"],
"plugins": [
"babel-plugin-macros",
["transform-runtime", {
"polyfill": false,
"regenerator": true
}]
]
"env": {
"plugins": [
"emotion",
"babel-plugin-macros",
["transform-runtime", {
"polyfill": false,
"regenerator": true
}]
]
}
}
12 changes: 6 additions & 6 deletions addons/a11y/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
"bugs": {
"url": "https://github.com/storybooks/storybook/issues"
},
"license": "MIT",
"main": "dist/index.js",
"jsnext:main": "src/index.js",
"repository": {
"type": "git",
"url": "git+https://github.com/storybooks/storybook.git"
},
"license": "MIT",
"main": "dist/index.js",
"jsnext:main": "src/index.js",
"scripts": {
"prepare": "node ../../scripts/prepare.js"
},
Expand All @@ -31,10 +31,10 @@
"@storybook/core-events": "4.0.0-alpha.6",
"axe-core": "^3.0.2",
"babel-runtime": "^6.26.0",
"glamor": "^2.20.40",
"glamorous": "^4.12.5",
"emotion": "^9.1.3",
"global": "^4.3.2",
"prop-types": "^15.6.1"
"prop-types": "^15.6.1",
"react-emotion": "^9.1.3"
},
"peerDependencies": {
"react": "*",
Expand Down
21 changes: 11 additions & 10 deletions addons/a11y/src/components/Panel.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
import React, { Component } from 'react';
import addons from '@storybook/addons';

import styled from 'react-emotion';

import { CHECK_EVENT_ID } from '../shared';

import Tabs from './Tabs';
import Report from './Report';

const styles = {
passes: {
color: '#0D6731',
},
violations: {
color: '#AC2300',
},
};
const Passes = styled('span')({
color: '#0D6731',
});

const Violations = styled('span')({
color: '#AC2300',
});

class Panel extends Component {
constructor(props, ...args) {
Expand Down Expand Up @@ -49,11 +50,11 @@ class Panel extends Component {
<Tabs
tabs={[
{
label: <span style={styles.violations}>{violations.length} Violations</span>,
label: <Violations>{violations.length} Violations</Violations>,
panel: <Report passes={false} items={violations} empty="No a11y violations found." />,
},
{
label: <span style={styles.passes}>{passes.length} Passes</span>,
label: <Passes>{passes.length} Passes</Passes>,
panel: <Report passes items={passes} empty="No a11y check passed" />,
},
]}
Expand Down
43 changes: 21 additions & 22 deletions addons/a11y/src/components/Report/Elements.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
import React from 'react';
import PropTypes from 'prop-types';

import styled from 'react-emotion';

import Rules from './Rules';

const styles = {
element: {
fontWeight: 600,
},
target: {
borderBottom: '1px solid rgb(130, 130, 130)',
width: '100%',
display: 'inline-block',
paddingBottom: '4px',
marginBottom: '4px',
},
};
const Item = styled('li')({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is entirely based on code only: Is there a specific reason why the li element is styled instead of the ol? The previous implementation had the styles.element injected into both of them which looked redundant, so removing one of them is great. But functionality wise it doesn't seem like there's a difference between putting it on the li and ol. Readability wise this looks better, but is there any possible downside (performance/verbose output for DOM of the user) for not doing so or any explicit reason to do so? Mostly questions out of curiosity!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the li actually has user-agent styling applied to it, the ol doesn't as much.

fontWeight: 600,
});
const ItemTitle = styled('span')({
borderBottom: '1px solid rgb(130, 130, 130)',
width: '100%',
display: 'inline-block',
paddingBottom: '4px',
marginBottom: '4px',
});

function Element({ element, passes }) {
const { any, all, none } = element;

const rules = [...any, ...all, ...none];

return (
<li style={styles.element}>
<span style={styles.target}>{element.target[0]}</span>
<Item>
<ItemTitle>{element.target[0]}</ItemTitle>
<Rules rules={rules} passes={passes} />
</li>
</Item>
);
}
Element.propTypes = {
Expand All @@ -38,13 +38,12 @@ Element.propTypes = {
};

/* eslint-disable react/no-array-index-key */
function Elements({ elements, passes }) {
return (
<ol style={styles.element}>
{elements.map((element, index) => <Element passes={passes} element={element} key={index} />)}
</ol>
);
}
const Elements = ({ elements, passes }) => (
<ol>
{elements.map((element, index) => <Element passes={passes} element={element} key={index} />)}
</ol>
);

Elements.propTypes = {
elements: PropTypes.arrayOf(
PropTypes.shape({
Expand Down
42 changes: 21 additions & 21 deletions addons/a11y/src/components/Report/Info.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
import React from 'react';
import PropTypes from 'prop-types';

const styles = {
info: {
backgroundColor: 'rgb(234, 234, 234)',
padding: '12px',
marginBottom: '10px',
},
help: {
margin: '0 0 12px',
},
helpUrl: {
marginTop: '12px',
textDecoration: 'underline',
color: 'rgb(130, 130, 130)',
display: 'block',
},
};
import styled from 'react-emotion';

const Wrapper = styled('div')({
backgroundColor: 'rgb(234, 234, 234)',
padding: '12px',
marginBottom: '10px',
});
const Help = styled('p')({
margin: '0 0 12px',
});
const Link = styled('a')({
marginTop: '12px',
textDecoration: 'underline',
color: 'rgb(130, 130, 130)',
display: 'block',
});

function Info({ item }) {
return (
<div style={styles.info}>
<p style={styles.help}>{item.help}</p>
<a style={styles.helpUrl} href={item.helpUrl} target="_blank">
<Wrapper>
<Help>{item.help}</Help>
<Link href={item.helpUrl} target="_blank">
More info...
</a>
</div>
</Link>
</Wrapper>
);
}

Expand Down
47 changes: 21 additions & 26 deletions addons/a11y/src/components/Report/Item.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';

import styled from 'react-emotion';

import Info from './Info';
import Tags from './Tags';
import Elements from './Elements';

const styles = {
item: {
padding: '0 14px',
cursor: 'pointer',
borderBottom: '1px solid rgb(234, 234, 234)',
},
headerBar: {
padding: '12px 0px',
display: 'block',
width: '100%',
border: 0,
background: 'none',
},
};
const Wrapper = styled('div')({
padding: '0 14px',
cursor: 'pointer',
borderBottom: '1px solid rgb(234, 234, 234)',
});

const HeaderBar = styled('button')({
padding: '12px 0px',
display: 'block',
width: '100%',
border: 0,
background: 'none',
});

class Item extends Component {
static propTypes = {
Expand All @@ -30,13 +31,9 @@ class Item extends Component {
passes: PropTypes.bool.isRequired,
};

constructor() {
super();

this.state = {
open: false,
};
}
state = {
open: false,
};

onToggle = () =>
this.setState(prevState => ({
Expand All @@ -48,14 +45,12 @@ class Item extends Component {
const { open } = this.state;

return (
<div style={styles.item}>
<button style={styles.headerBar} onClick={() => this.onToggle()}>
{item.description}
</button>
<Wrapper>
<HeaderBar onClick={this.onToggle}>{item.description}</HeaderBar>
{open && <Info item={item} />}
{open && <Elements elements={item.nodes} passes={passes} />}
{open && <Tags tags={item.tags} />}
</div>
</Wrapper>
);
}
}
Expand Down
4 changes: 2 additions & 2 deletions addons/a11y/src/components/Report/RerunButton.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import glamorous from 'glamorous';
import styled from 'react-emotion';

const RerunButton = glamorous.button({
const RerunButton = styled('button')({
position: 'absolute',
bottom: 0,
right: 0,
Expand Down
Loading