Skip to content

Commit 6e432fe

Browse files
committed
Create JSS-styled base
1 parent 224e64a commit 6e432fe

23 files changed

Lines changed: 4924 additions & 0 deletions

.babelrc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
presets: [
3+
'react',
4+
],
5+
plugins: [
6+
'transform-es2015-modules-commonjs',
7+
'transform-class-properties',
8+
['transform-object-rest-spread', { useBuiltIns: true }],
9+
]
10+
}

.eslintrc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
extends: '@lttb/default'
2+
3+
rules:
4+
react/prop-types:
5+
- 2
6+
- skipUndeclared: true
7+
8+
env:
9+
jest: true

.flowconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[ignore]
2+
.*/node_modules/.*
3+
<PROJECT_ROOT>/coverage/
4+
<PROJECT_ROOT>/examples/
5+
6+
<PROJECT_ROOT>/lib/
7+
8+
[options]
9+
all=true

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
npm-debug.log
2+
3+
yarn.lock
4+
5+
node_modules
6+
lib
7+
coverage

.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
yarn.lock

README.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# Styled JSS
2+
3+
## Usage
4+
5+
### With Styled Creator
6+
7+
Styled Creator allows to share classes between styled primitives
8+
9+
```jsx
10+
import Styled from 'styled-jss'
11+
import injectSheet from 'react-jss'
12+
13+
// Base styles, like a regular jss object.
14+
const styled = Styled({
15+
root: {
16+
margin: 10
17+
},
18+
baseButton: {
19+
padding: 10
20+
}
21+
})
22+
23+
const NormalButton = styled('button', {
24+
composes: '$baseButton',
25+
border: '1px solid grey'
26+
color: 'black'
27+
})
28+
29+
// Composition over styled() same like styled-components
30+
const PrimaryButton = styled(NormalButton, {
31+
color: 'red'
32+
})
33+
34+
// One can use classes AND styled primitives.
35+
const MyComponent = ({classes}) => (
36+
<div className={classes.root}>
37+
<PrimaryButton>
38+
</div>
39+
)
40+
41+
const MyStyledComponent = injectSheet(styled.styles)(MyComponent)
42+
```
43+
44+
### With default styled function
45+
46+
```jsx
47+
import { styled } from 'styled-jss'
48+
49+
const Button = styled('button', {
50+
fontSize: 12,
51+
color: (props) => props.theme.textColor
52+
})
53+
54+
const PrimaryButton = styled(Button, {
55+
color: 'red'
56+
})
57+
```
58+
59+
### With custom JSS setup:
60+
61+
#### For Styled Creator:
62+
```jsx
63+
import {create as createJss} from 'jss'
64+
import {create as createInjectSheet} from 'react-jss'
65+
import vendorPrefixer from 'jss-vendor-prefixer'
66+
67+
import { setStyledCreator, prepareStyled } from 'styled-jss'
68+
69+
const jss = createJss()
70+
jss.use(vendorPrefixer())
71+
72+
const injectSheet = createInjectSheet(jss)
73+
74+
export const styled = prepareStyled(injectSheet)
75+
76+
const Styled = setStyledCreator(styled)
77+
export default Styled
78+
```
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// flow-typed signature: 247bd0f0fb67c476dd58bf82ba5163ed
2+
// flow-typed version: <<STUB>>/@lttb/eslint-config-default_vgithub:lttb/configs#js/flow_v0.44.2
3+
4+
/**
5+
* This is an autogenerated libdef stub for:
6+
*
7+
* '@lttb/eslint-config-default'
8+
*
9+
* Fill this stub out by replacing all the `any` types.
10+
*
11+
* Once filled out, we encourage you to share your work with the
12+
* community by sending a pull request to:
13+
* https://github.com/flowtype/flow-typed
14+
*/
15+
16+
declare module '@lttb/eslint-config-default' {
17+
declare module.exports: any;
18+
}

flow-typed/npm/babel-cli_vx.x.x.js

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
// flow-typed signature: d0500d72eccbf8f597f96e1bf847cb49
2+
// flow-typed version: <<STUB>>/babel-cli_v^6.23.0/flow_v0.44.2
3+
4+
/**
5+
* This is an autogenerated libdef stub for:
6+
*
7+
* 'babel-cli'
8+
*
9+
* Fill this stub out by replacing all the `any` types.
10+
*
11+
* Once filled out, we encourage you to share your work with the
12+
* community by sending a pull request to:
13+
* https://github.com/flowtype/flow-typed
14+
*/
15+
16+
declare module 'babel-cli' {
17+
declare module.exports: any;
18+
}
19+
20+
/**
21+
* We include stubs for each file inside this npm package in case you need to
22+
* require those files directly. Feel free to delete any files that aren't
23+
* needed.
24+
*/
25+
declare module 'babel-cli/bin/babel-doctor' {
26+
declare module.exports: any;
27+
}
28+
29+
declare module 'babel-cli/bin/babel-external-helpers' {
30+
declare module.exports: any;
31+
}
32+
33+
declare module 'babel-cli/bin/babel-node' {
34+
declare module.exports: any;
35+
}
36+
37+
declare module 'babel-cli/bin/babel' {
38+
declare module.exports: any;
39+
}
40+
41+
declare module 'babel-cli/lib/_babel-node' {
42+
declare module.exports: any;
43+
}
44+
45+
declare module 'babel-cli/lib/babel-external-helpers' {
46+
declare module.exports: any;
47+
}
48+
49+
declare module 'babel-cli/lib/babel-node' {
50+
declare module.exports: any;
51+
}
52+
53+
declare module 'babel-cli/lib/babel/dir' {
54+
declare module.exports: any;
55+
}
56+
57+
declare module 'babel-cli/lib/babel/file' {
58+
declare module.exports: any;
59+
}
60+
61+
declare module 'babel-cli/lib/babel/index' {
62+
declare module.exports: any;
63+
}
64+
65+
declare module 'babel-cli/lib/babel/util' {
66+
declare module.exports: any;
67+
}
68+
69+
// Filename aliases
70+
declare module 'babel-cli/bin/babel-doctor.js' {
71+
declare module.exports: $Exports<'babel-cli/bin/babel-doctor'>;
72+
}
73+
declare module 'babel-cli/bin/babel-external-helpers.js' {
74+
declare module.exports: $Exports<'babel-cli/bin/babel-external-helpers'>;
75+
}
76+
declare module 'babel-cli/bin/babel-node.js' {
77+
declare module.exports: $Exports<'babel-cli/bin/babel-node'>;
78+
}
79+
declare module 'babel-cli/bin/babel.js' {
80+
declare module.exports: $Exports<'babel-cli/bin/babel'>;
81+
}
82+
declare module 'babel-cli/index' {
83+
declare module.exports: $Exports<'babel-cli'>;
84+
}
85+
declare module 'babel-cli/index.js' {
86+
declare module.exports: $Exports<'babel-cli'>;
87+
}
88+
declare module 'babel-cli/lib/_babel-node.js' {
89+
declare module.exports: $Exports<'babel-cli/lib/_babel-node'>;
90+
}
91+
declare module 'babel-cli/lib/babel-external-helpers.js' {
92+
declare module.exports: $Exports<'babel-cli/lib/babel-external-helpers'>;
93+
}
94+
declare module 'babel-cli/lib/babel-node.js' {
95+
declare module.exports: $Exports<'babel-cli/lib/babel-node'>;
96+
}
97+
declare module 'babel-cli/lib/babel/dir.js' {
98+
declare module.exports: $Exports<'babel-cli/lib/babel/dir'>;
99+
}
100+
declare module 'babel-cli/lib/babel/file.js' {
101+
declare module.exports: $Exports<'babel-cli/lib/babel/file'>;
102+
}
103+
declare module 'babel-cli/lib/babel/index.js' {
104+
declare module.exports: $Exports<'babel-cli/lib/babel/index'>;
105+
}
106+
declare module 'babel-cli/lib/babel/util.js' {
107+
declare module.exports: $Exports<'babel-cli/lib/babel/util'>;
108+
}

0 commit comments

Comments
 (0)