Skip to content

Commit c9580d5

Browse files
committed
feat: setup project files
1 parent 422f05b commit c9580d5

16 files changed

Lines changed: 356 additions & 3 deletions

.eslintrc.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
extends: eslint:recommended
2+
env:
3+
node: true
4+
browser: true
5+
rules:
6+
block-scoped-var: 2
7+
callback-return: 2
8+
dot-notation: 2
9+
indent: 2
10+
linebreak-style: [2, unix]
11+
new-cap: 2
12+
no-console: [2, allow: [warn, error]]
13+
no-else-return: 2
14+
no-eq-null: 2
15+
no-fallthrough: 2
16+
no-invalid-this: 2
17+
no-return-assign: 2
18+
no-shadow: 1
19+
no-trailing-spaces: 2
20+
no-use-before-define: [2, nofunc]
21+
quotes: [2, single, avoid-escape]
22+
semi: [2, always]
23+
strict: [2, global]
24+
valid-jsdoc: [2, requireReturn: false]
25+
no-control-regex: 0
26+
no-useless-escape: 2
27+

.gitignore

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
.idea
2+
node_modules
3+
/.idea
4+
.nyc_output
5+
coverage
6+
package-lock.json
7+
yarn.lock
8+
yarn-error.log
9+
dist/
10+
.DS_Store
11+
lerna-debug.log
12+
/modules/
13+
/dist/
14+
.vscode/
15+
_book/
16+
/demo/*.js
17+
/demo/*.js.map
18+
/demo/analyzer/

.npmignore

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
node_modules/
2+
/test
3+
.idea
4+
.idea/
5+
__tests__/
6+
__mocks__/
7+
__stories__/
8+
.nyc_output
9+
coverage
10+
package-lock.json
11+
yarn.lock
12+
yarn-error.log
13+
tsconfig.json
14+
.vscode/
15+
/docs/
16+
.storybook/
17+
/build/
18+
/dist/
19+
/demo/
20+
/demo/analyzer/

.storybook/addons.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import '@storybook/addon-actions/register';
2+
import '@storybook/addon-links/register';

.storybook/config.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { configure } from '@storybook/react';
2+
3+
// automatically import all files ending in *.stories.js
4+
const req = require.context('../.storybook', true, /.stories.tsx?$/);
5+
function loadStories() {
6+
req.keys().forEach((filename) => req(filename));
7+
}
8+
9+
configure(loadStories, module);

.storybook/webpack.config.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
module.exports = {
2+
module: {
3+
rules: [
4+
{
5+
test: /\.tsx?$/,
6+
loader: 'ts-loader'
7+
}
8+
]
9+
},
10+
11+
resolve: {
12+
extensions: ['.ts', '.tsx', '.js', '.jsx'],
13+
enforceExtension: false
14+
}
15+
};

.travis.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
language: node_js
2+
os:
3+
- linux
4+
cache:
5+
yarn: true
6+
directories:
7+
- ~/.npm
8+
notifications:
9+
email: false
10+
node_js:
11+
- '8'
12+
script:
13+
- npm run test
14+
- npm run build
15+
matrix:
16+
allow_failures: []
17+
fast_finish: true
18+
after_success:
19+
- npm run semantic-release
20+
branches:
21+
except:
22+
- /^v\d+\.\d+\.\d+$/

LICENSE

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
This is free and unencumbered software released into the public domain.
2+
3+
Anyone is free to copy, modify, publish, use, compile, sell, or
4+
distribute this software, either in source code form or as a compiled
5+
binary, for any purpose, commercial or non-commercial, and by any
6+
means.
7+
8+
In jurisdictions that recognize copyright laws, the author or authors
9+
of this software dedicate any and all copyright interest in the
10+
software to the public domain. We make this dedication for the benefit
11+
of the public at large and to the detriment of our heirs and
12+
successors. We intend this dedication to be an overt act of
13+
relinquishment in perpetuity of all present and future rights to this
14+
software under copyright law.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19+
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20+
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22+
OTHER DEALINGS IN THE SOFTWARE.
23+
24+
For more information, please refer to <https://unlicense.org>

README.md

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
# ezcss
2+
3+
[![][npm-badge]][npm-url] [![][travis-badge]][travis-url]
4+
5+
Super lite CSS-in-JS solution.
6+
7+
8+
## Usage
9+
10+
Import renderer.
11+
12+
```js
13+
import {Renderer} from 'ezcss';
14+
15+
const renderer = new Renderer;
16+
const {rule, sheet, withStyles, useStyles, styled, css} = renderer;
17+
```
18+
19+
Render a single "rule".
20+
21+
```js
22+
const className = rule({
23+
border: '1px solid red'
24+
}, 'MyName');
25+
26+
<div className={className} />
27+
```
28+
29+
Create a "styles sheet" with multiple lazy-evaluating rules.
30+
31+
```js
32+
const styles = sheet({
33+
main: {
34+
border: '1px solid red'
35+
},
36+
element: {
37+
border: '1px solid blue'
38+
}
39+
}, 'MyName');
40+
41+
<div className={styles.main} />
42+
```
43+
44+
Injects `styles` prop into component.
45+
46+
```js
47+
const styles = {
48+
main: {
49+
border: '1px solid red'
50+
}
51+
};
52+
53+
const MyComp = withStyles(styles, function MyComp ({styles}) {
54+
return <div className={styles.main} />
55+
});
56+
```
57+
58+
Use `styles` object in your component.
59+
60+
```js
61+
const styles = {
62+
main: {
63+
border: '1px solid red'
64+
}
65+
};
66+
67+
const MyComp = useStyles(styles, function MyComp (props, styles) {
68+
return <div className={styles.main} />
69+
});
70+
```
71+
72+
Create "styled" components.
73+
74+
```js
75+
const Div = styled('div', {
76+
border: '1px solid red'
77+
}, 'RedBorderDiv');
78+
79+
<Div>Hello world!</Div>
80+
```
81+
82+
Stateful component style decorator.
83+
84+
```js
85+
@css({
86+
border: '1px solid red'
87+
})
88+
class MyComponent extends Component {
89+
render () {
90+
91+
}
92+
}
93+
```
94+
95+
96+
## Server Side Rendering
97+
98+
`excss` works in Node.js environment as well. Use `.raw` property to access raw CSS styles
99+
on server and include then in your template.
100+
101+
```js
102+
const html += `<style>${renderer.raw}</style>`;
103+
```
104+
105+
106+
## License
107+
108+
[Unlicense](./LICENSE) &mdash; public domain.
109+
110+
111+
[npm-url]: https://www.npmjs.com/package/ezcss
112+
[npm-badge]: https://img.shields.io/npm/v/ezcss.svg
113+
[travis-url]: https://travis-ci.org/streamich/ezcss
114+
[travis-badge]: https://travis-ci.org/streamich/ezcss.svg?branch=master

build/gulpfile.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
'use strict';
2+
3+
var gulp = require('gulp');
4+
var ts = require('gulp-typescript');
5+
var config = require('../tsconfig.json');
6+
7+
gulp.task('build-ts', function() {
8+
return gulp
9+
.src(['../src/**/*.ts', '!../src/**/__tests__/**'])
10+
.pipe(
11+
ts(Object.assign({}, config.compilerOptions, {
12+
target: 'es5',
13+
module: 'commonjs',
14+
}))
15+
)
16+
.pipe(gulp.dest('../lib'));
17+
});
18+
19+
gulp.task('build-modules', function() {
20+
return gulp
21+
.src(['../src/**/*.ts', '!../src/**/__tests__/**'])
22+
.pipe(
23+
ts(Object.assign({}, config.compilerOptions, {
24+
target: 'ESNext',
25+
module: 'ESNext',
26+
}))
27+
)
28+
.pipe(gulp.dest('../modules'));
29+
});

0 commit comments

Comments
 (0)