Skip to content

Commit

Permalink
Merge pull request #3572 from storybooks/feature/more-components
Browse files Browse the repository at this point in the history
Theme-ability progress
  • Loading branch information
ndelangen authored May 19, 2018
2 parents b414338 + 552a01c commit c821484
Show file tree
Hide file tree
Showing 177 changed files with 6,156 additions and 7,067 deletions.
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.7",
"axe-core": "^3.0.2",
"babel-runtime": "^6.26.0",
"glamor": "^2.20.40",
"glamorous": "^4.13.0",
"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')({
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

0 comments on commit c821484

Please sign in to comment.