-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Add addon-a11y to monorepo #2292
Merged
Merged
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
2a434dd
Initial commit
12d989e
Fix wrong import in manager.js
eb76e63
Remove unused preview.js file
0d67ae2
Correct main entry
fae8834
Export shared variables in entry point
0266c97
Create more example stories (#1)
jbovenschen 17acba5
Bump version to 0.0.4
980468b
Update to use Storybook v3. Closes #7
jrwebdev c2aacec
Prepare for release
ndelangen 7bd40cf
Fix git repo paths in package.json
jbovenschen 8d4f74b
Get rid of extra span
zinserjan ea9ac1a
Prepare for release
ndelangen f3a8e48
Fixed typos in README.md
gsimone 6fdc4e3
RENAME package & SYNC versions with monorepo && CHANGE readme
ndelangen 986e552
FIX versions & dependencies for addon-a11y
ndelangen 607f37d
FIX incorrect package names in readme
ndelangen 1561f54
Merge branch 'master' into add-addon-a11y
ndelangen 90f1711
DELETE unnecessary files
ndelangen 88a8f00
Linting
ndelangen 56d13ef
Remove most devDependencies
ndelangen 90e8857
lockfile
ndelangen 5792e09
Linting
ndelangen c3cfd7b
ADD story for addon-a11y to cra-kitchen-sink
ndelangen 3bf698c
Linting
ndelangen 862d4cf
ADD snapshots for new stories
ndelangen 56c14a2
Merge branch 'master' into add-addon-a11y
ndelangen 5ec50a8
FIX fonts (from lib/components)
ndelangen 966c605
IMPROVE tabs visually
ndelangen 857d84d
CHANGE simplify addon namespace
ndelangen 0f30fc9
FIX lockfile
ndelangen 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 @@ | ||
import '../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,47 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
|
||
const styles = { | ||
button: { | ||
padding: '12px 6px', | ||
fontSize: '12px', | ||
lineHeight: '16px', | ||
borderRadius: '5px', | ||
}, | ||
ok: { | ||
backgroundColor: '#028402', | ||
color: '#ffffff', | ||
}, | ||
wrong: { | ||
color: '#ffffff', | ||
backgroundColor: '#4caf50', | ||
} | ||
} | ||
|
||
function Button({ label, content, disabled, contrast }) { | ||
return ( | ||
<button | ||
style={{ | ||
...styles.button, | ||
...styles[contrast], | ||
}} | ||
disabled={disabled} | ||
> | ||
{ content } | ||
</button> | ||
) | ||
} | ||
|
||
Button.propTypes = { | ||
label: PropTypes.string, | ||
content: PropTypes.string, | ||
disabled: PropTypes.bool, | ||
contrast: PropTypes.oneOf(['ok', 'wrong']) | ||
}; | ||
|
||
Button.defaultProps = { | ||
disabled: false, | ||
contrast: 'ok', | ||
}; | ||
|
||
export default Button; |
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,34 @@ | ||
import React from 'react'; | ||
import { storiesOf } from '@storybook/react'; | ||
|
||
import { checkA11y } from './../../../src'; | ||
|
||
import Button from './component'; | ||
|
||
import Faker from 'faker'; | ||
|
||
const text = Faker.lorem.words(); | ||
|
||
storiesOf('<Button />', module) | ||
.addDecorator(checkA11y) | ||
.add('Default', () => ( | ||
<Button /> | ||
)) | ||
.add('Content', () => ( | ||
<Button content={text} /> | ||
)) | ||
.add('Label', () => ( | ||
<Button label={text} /> | ||
)) | ||
.add('Disabled', () => ( | ||
<Button | ||
disabled | ||
content={text} | ||
/> | ||
)) | ||
.add('Invalid contrast', () => ( | ||
<Button | ||
contrast="wrong" | ||
content={Faker.lorem.words()} | ||
/> | ||
)); |
22 changes: 22 additions & 0 deletions
22
addons/a11y/.storybook/components/Form/components/Input.js
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 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
|
||
function Input({ id, value, type, placeholder }) { | ||
return ( | ||
<input | ||
id={id} | ||
value={value} | ||
placeholder={placeholder} | ||
type={type} | ||
/> | ||
); | ||
} | ||
|
||
Input.propTypes = { | ||
type: PropTypes.oneOf(['text', 'password']), | ||
id: PropTypes.string, | ||
value: PropTypes.string, | ||
placeholder: PropTypes.string, | ||
} | ||
|
||
export default Input; |
26 changes: 26 additions & 0 deletions
26
addons/a11y/.storybook/components/Form/components/Label.js
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,26 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
|
||
const styles = { | ||
label: { | ||
padding: '0 6px', | ||
}, | ||
} | ||
|
||
function Label({ id, content }) { | ||
return ( | ||
<label | ||
style={styles.label} | ||
htmlFor={id} | ||
> | ||
{ content } | ||
</label> | ||
) | ||
} | ||
|
||
Label.propTypes = { | ||
content: PropTypes.string, | ||
id: PropTypes.string, | ||
}; | ||
|
||
export default Label; |
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,21 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
|
||
import Label from './Label'; | ||
import Input from './Input'; | ||
|
||
function Row({ label, input }) { | ||
return ( | ||
<div> | ||
{label} | ||
{input} | ||
</div> | ||
); | ||
} | ||
|
||
Row.propTypes = { | ||
label: PropTypes.instanceOf(Label), | ||
input: PropTypes.instanceOf(Input), | ||
} | ||
|
||
export default Row; |
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,9 @@ | ||
import Input from './Input'; | ||
import Label from './Label'; | ||
import Row from './Row'; | ||
|
||
export { | ||
Input, | ||
Label, | ||
Row, | ||
}; |
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,36 @@ | ||
import React from 'react'; | ||
|
||
import * as Form from './components'; | ||
|
||
import { storiesOf } from '@storybook/react'; | ||
import { checkA11y } from './../../../src'; | ||
|
||
import Faker from 'faker'; | ||
|
||
const label = Faker.lorem.word(); | ||
const placeholder = Faker.lorem.word(); | ||
|
||
storiesOf('<Form />', module) | ||
.addDecorator(checkA11y) | ||
.add('Without Label', () => ( | ||
<Form.Row | ||
input={<Form.Input />} | ||
/> | ||
)) | ||
.add ('With label', () => ( | ||
<Form.Row | ||
label={<Form.Label | ||
content={label} | ||
id="1" | ||
/>} | ||
input={<Form.Input id="1" />} | ||
/> | ||
)) | ||
.add ('With placeholder', () => ( | ||
<Form.Row | ||
input={<Form.Input | ||
id="1" | ||
placeholder={placeholder} | ||
/>} | ||
/> | ||
)) |
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,20 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
|
||
function Image({ src, alt, presentation }) { | ||
return ( | ||
<img | ||
src={src} | ||
alt={alt} | ||
role={presentation && 'presentation'} | ||
/> | ||
); | ||
} | ||
|
||
Image.propTypes = { | ||
src: PropTypes.string.isRequired, | ||
alt: PropTypes.string, | ||
presentation: PropTypes.bool, | ||
}; | ||
|
||
export default Image; |
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,29 @@ | ||
import React from 'react'; | ||
import { storiesOf } from '@storybook/react'; | ||
|
||
import { checkA11y } from './../../../src'; | ||
|
||
import Image from './component'; | ||
|
||
import Faker from 'faker'; | ||
|
||
const image = Faker.image.animals(); | ||
const alt = Faker.lorem.words(); | ||
|
||
storiesOf('<Image />', module) | ||
.addDecorator(checkA11y) | ||
.add('Without alt', () => ( | ||
<Image src={image} /> | ||
)) | ||
.add('With alt', () => ( | ||
<Image | ||
src={image} | ||
alt={alt} | ||
/> | ||
)) | ||
.add('Presentation', () => ( | ||
<Image | ||
presentation | ||
src={image} | ||
/> | ||
)); |
24 changes: 24 additions & 0 deletions
24
addons/a11y/.storybook/components/Typography/components/Heading.js
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,24 @@ | ||
import React, { cloneElement } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
|
||
const headings = { | ||
1: (<h1 />), | ||
2: (<h2 />), | ||
3: (<h3 />), | ||
4: (<h4 />), | ||
}; | ||
|
||
function Heading({ level, children }) { | ||
return cloneElement(headings[level], {}, children) | ||
} | ||
|
||
Heading.propTypes = { | ||
level: PropTypes.oneOf([1, 2, 3, 4]), | ||
children: PropTypes.any, | ||
}; | ||
|
||
Heading.defaultProps = { | ||
level: 1, | ||
}; | ||
|
||
export default Heading; |
17 changes: 17 additions & 0 deletions
17
addons/a11y/.storybook/components/Typography/components/Link.js
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,17 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
|
||
function Link({ href, content }) { | ||
return ( | ||
<a href={href}> | ||
{ content } | ||
</a> | ||
); | ||
} | ||
|
||
Link.propTypes = { | ||
href: PropTypes.string, | ||
content: PropTypes.string, | ||
}; | ||
|
||
export default Link; |
16 changes: 16 additions & 0 deletions
16
addons/a11y/.storybook/components/Typography/components/Text.js
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,16 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
|
||
function Text({ children }) { | ||
return ( | ||
<p> | ||
{children} | ||
</p> | ||
); | ||
} | ||
|
||
Text.propTypes = { | ||
children: PropTypes.any, | ||
}; | ||
|
||
export default Text; |
9 changes: 9 additions & 0 deletions
9
addons/a11y/.storybook/components/Typography/components/index.js
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,9 @@ | ||
import Heading from './Heading'; | ||
import Link from './Link'; | ||
import Text from './Text'; | ||
|
||
export { | ||
Heading, | ||
Link, | ||
Text, | ||
}; |
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,41 @@ | ||
import React from 'react'; | ||
import { storiesOf } from '@storybook/react'; | ||
|
||
import { checkA11y } from './../../../src'; | ||
|
||
import * as Typography from './components'; | ||
|
||
import Faker from 'faker'; | ||
|
||
const href = "javascript:void 0"; | ||
|
||
storiesOf('<Typography />', module) | ||
.addDecorator(checkA11y) | ||
.add('Correct', () => ( | ||
<div> | ||
<Typography.Heading level={1}> | ||
{Faker.lorem.sentence()} | ||
</Typography.Heading> | ||
|
||
<Typography.Text> | ||
{Faker.lorem.paragraph()} | ||
</Typography.Text> | ||
|
||
<Typography.Link | ||
content={`${Faker.lorem.words(4)}...`} | ||
href={href} | ||
/> | ||
</div> | ||
)) | ||
.add('Empty Heading', () => ( | ||
<Typography.Heading level={2} /> | ||
)) | ||
.add('Empty Paragraph', () => ( | ||
<Typography.Text /> | ||
)) | ||
.add('Empty Link', () => ( | ||
<Typography.Link href={href} /> | ||
)) | ||
.add('Link without href', () => ( | ||
<Typography.Link content={`${Faker.lorem.words(4)}...`} /> | ||
)); |
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,9 @@ | ||
import * as storybook from '@storybook/react'; | ||
|
||
const req = require.context('./components/', true, /stories\.js$/) | ||
|
||
const loadStories = () => | ||
req.keys().forEach(req); | ||
|
||
|
||
storybook.configure(loadStories, module) |
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.
I think these a11y stories should be moved over to CRA so we can test them together.
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.
agree
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.
Added, will leave the old storybook, because might copy over some more stories later.