-
Notifications
You must be signed in to change notification settings - Fork 15
Create JSS-styled prototype #1
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
Merged
Merged
Changes from 9 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
6e432fe
Create JSS-styled base
lttb 6a80dd8
Create JSS-styled prototype
lttb 89a3dd7
Remove pure component and support custom className
lttb e960f4b
Upgrade deps and use eslint-config-jss
lttb 4b9b6ad
Update flow-typed
lttb 3fe85ad
Implement property validation with is-native-prop
lttb f756cef
Use is-react-prop
lttb f8a7e59
Implement common style sheets
lttb 682aee9
Use common dynamic stylesheet
lttb 0e45a63
Fix naming
lttb e87dc0e
Use updateRule from jss
lttb 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 hidden or 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 @@ | ||
| { | ||
| presets: [ | ||
| 'react', | ||
| ], | ||
| plugins: [ | ||
| 'transform-es2015-modules-commonjs', | ||
| 'transform-class-properties', | ||
| ['transform-object-rest-spread', { useBuiltIns: true }], | ||
| ] | ||
| } |
This file contains hidden or 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,5 @@ | ||
| extends: 'jss' | ||
| parser: babel-eslint | ||
|
|
||
| env: | ||
| jest: true |
This file contains hidden or 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 @@ | ||
| [ignore] | ||
| .*/node_modules/.* | ||
| <PROJECT_ROOT>/coverage/ | ||
| <PROJECT_ROOT>/examples/ | ||
|
|
||
| <PROJECT_ROOT>/lib/ | ||
|
|
||
| [options] | ||
| all=true |
This file contains hidden or 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,7 @@ | ||
| npm-debug.log | ||
|
|
||
| yarn.lock | ||
|
|
||
| node_modules | ||
| lib | ||
| coverage |
This file contains hidden or 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 @@ | ||
| yarn.lock |
This file contains hidden or 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,78 @@ | ||
| # Styled JSS | ||
|
|
||
| ## Usage | ||
|
|
||
| ### With Styled Creator | ||
|
|
||
| Styled Creator allows to share classes between styled primitives | ||
|
|
||
| ```jsx | ||
| import Styled from 'styled-jss' | ||
| import injectSheet from 'react-jss' | ||
|
|
||
| // Base styles, like a regular jss object. | ||
| const styled = Styled({ | ||
| root: { | ||
| margin: 10 | ||
| }, | ||
| baseButton: { | ||
| padding: 10 | ||
| } | ||
| }) | ||
|
|
||
| const NormalButton = styled('button', { | ||
| composes: '$baseButton', | ||
| border: '1px solid grey' | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lets leverage jss-default-unit? |
||
| color: 'black' | ||
| }) | ||
|
|
||
| // Composition over styled() same like styled-components | ||
| const PrimaryButton = styled(NormalButton, { | ||
| color: 'red' | ||
| }) | ||
|
|
||
| // One can use classes AND styled primitives. | ||
| const MyComponent = ({classes}) => ( | ||
| <div className={classes.root}> | ||
| <PrimaryButton> | ||
| </div> | ||
| ) | ||
|
|
||
| const MyStyledComponent = injectSheet(styled.styles)(MyComponent) | ||
| ``` | ||
|
|
||
| ### With default styled function | ||
|
|
||
| ```jsx | ||
| import { styled } from 'styled-jss' | ||
|
|
||
| const Button = styled('button', { | ||
| fontSize: 12, | ||
| color: (props) => props.theme.textColor | ||
| }) | ||
|
|
||
| const PrimaryButton = styled(Button, { | ||
| color: 'red' | ||
| }) | ||
| ``` | ||
|
|
||
| ### With custom JSS setup: | ||
|
|
||
| #### For Styled Creator: | ||
| ```jsx | ||
| import {create as createJss} from 'jss' | ||
| import {create as createInjectSheet} from 'react-jss' | ||
| import vendorPrefixer from 'jss-vendor-prefixer' | ||
|
|
||
| import { setStyledCreator, prepareStyled } from 'styled-jss' | ||
|
|
||
| const jss = createJss() | ||
| jss.use(vendorPrefixer()) | ||
|
|
||
| const injectSheet = createInjectSheet(jss) | ||
|
|
||
| export const styled = prepareStyled(injectSheet) | ||
|
|
||
| const Styled = setStyledCreator(styled) | ||
| export default Styled | ||
| ``` | ||
This file contains hidden or 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,18 @@ | ||
| // flow-typed signature: 247bd0f0fb67c476dd58bf82ba5163ed | ||
| // flow-typed version: <<STUB>>/@lttb/eslint-config-default_vgithub:lttb/configs#js/flow_v0.44.2 | ||
|
|
||
| /** | ||
| * This is an autogenerated libdef stub for: | ||
| * | ||
| * '@lttb/eslint-config-default' | ||
| * | ||
| * Fill this stub out by replacing all the `any` types. | ||
| * | ||
| * Once filled out, we encourage you to share your work with the | ||
| * community by sending a pull request to: | ||
| * https://github.com/flowtype/flow-typed | ||
| */ | ||
|
|
||
| declare module '@lttb/eslint-config-default' { | ||
| declare module.exports: any; | ||
| } |
This file contains hidden or 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,108 @@ | ||
| // flow-typed signature: d0500d72eccbf8f597f96e1bf847cb49 | ||
| // flow-typed version: <<STUB>>/babel-cli_v^6.23.0/flow_v0.44.2 | ||
|
|
||
| /** | ||
| * This is an autogenerated libdef stub for: | ||
| * | ||
| * 'babel-cli' | ||
| * | ||
| * Fill this stub out by replacing all the `any` types. | ||
| * | ||
| * Once filled out, we encourage you to share your work with the | ||
| * community by sending a pull request to: | ||
| * https://github.com/flowtype/flow-typed | ||
| */ | ||
|
|
||
| declare module 'babel-cli' { | ||
| declare module.exports: any; | ||
| } | ||
|
|
||
| /** | ||
| * We include stubs for each file inside this npm package in case you need to | ||
| * require those files directly. Feel free to delete any files that aren't | ||
| * needed. | ||
| */ | ||
| declare module 'babel-cli/bin/babel-doctor' { | ||
| declare module.exports: any; | ||
| } | ||
|
|
||
| declare module 'babel-cli/bin/babel-external-helpers' { | ||
| declare module.exports: any; | ||
| } | ||
|
|
||
| declare module 'babel-cli/bin/babel-node' { | ||
| declare module.exports: any; | ||
| } | ||
|
|
||
| declare module 'babel-cli/bin/babel' { | ||
| declare module.exports: any; | ||
| } | ||
|
|
||
| declare module 'babel-cli/lib/_babel-node' { | ||
| declare module.exports: any; | ||
| } | ||
|
|
||
| declare module 'babel-cli/lib/babel-external-helpers' { | ||
| declare module.exports: any; | ||
| } | ||
|
|
||
| declare module 'babel-cli/lib/babel-node' { | ||
| declare module.exports: any; | ||
| } | ||
|
|
||
| declare module 'babel-cli/lib/babel/dir' { | ||
| declare module.exports: any; | ||
| } | ||
|
|
||
| declare module 'babel-cli/lib/babel/file' { | ||
| declare module.exports: any; | ||
| } | ||
|
|
||
| declare module 'babel-cli/lib/babel/index' { | ||
| declare module.exports: any; | ||
| } | ||
|
|
||
| declare module 'babel-cli/lib/babel/util' { | ||
| declare module.exports: any; | ||
| } | ||
|
|
||
| // Filename aliases | ||
| declare module 'babel-cli/bin/babel-doctor.js' { | ||
| declare module.exports: $Exports<'babel-cli/bin/babel-doctor'>; | ||
| } | ||
| declare module 'babel-cli/bin/babel-external-helpers.js' { | ||
| declare module.exports: $Exports<'babel-cli/bin/babel-external-helpers'>; | ||
| } | ||
| declare module 'babel-cli/bin/babel-node.js' { | ||
| declare module.exports: $Exports<'babel-cli/bin/babel-node'>; | ||
| } | ||
| declare module 'babel-cli/bin/babel.js' { | ||
| declare module.exports: $Exports<'babel-cli/bin/babel'>; | ||
| } | ||
| declare module 'babel-cli/index' { | ||
| declare module.exports: $Exports<'babel-cli'>; | ||
| } | ||
| declare module 'babel-cli/index.js' { | ||
| declare module.exports: $Exports<'babel-cli'>; | ||
| } | ||
| declare module 'babel-cli/lib/_babel-node.js' { | ||
| declare module.exports: $Exports<'babel-cli/lib/_babel-node'>; | ||
| } | ||
| declare module 'babel-cli/lib/babel-external-helpers.js' { | ||
| declare module.exports: $Exports<'babel-cli/lib/babel-external-helpers'>; | ||
| } | ||
| declare module 'babel-cli/lib/babel-node.js' { | ||
| declare module.exports: $Exports<'babel-cli/lib/babel-node'>; | ||
| } | ||
| declare module 'babel-cli/lib/babel/dir.js' { | ||
| declare module.exports: $Exports<'babel-cli/lib/babel/dir'>; | ||
| } | ||
| declare module 'babel-cli/lib/babel/file.js' { | ||
| declare module.exports: $Exports<'babel-cli/lib/babel/file'>; | ||
| } | ||
| declare module 'babel-cli/lib/babel/index.js' { | ||
| declare module.exports: $Exports<'babel-cli/lib/babel/index'>; | ||
| } | ||
| declare module 'babel-cli/lib/babel/util.js' { | ||
| declare module.exports: $Exports<'babel-cli/lib/babel/util'>; | ||
| } |
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 this should be a second separate example, because user will think he needs to do that.
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 would try to make clear that the API is mostly compatible with styled
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.
And this feature is on top of it.