Skip to content

Commit 2d65b97

Browse files
committed
Adjust docs
1 parent 9650f49 commit 2d65b97

13 files changed

+79
-103
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ fast af css-in-js in 1kb
1515
const rule = cxs(`color: tomato`)
1616
```
1717

18-
CXS is a minimal CSS-in-JS solution that uses
18+
CXS is a minimal CSS-in-JS solution with
1919
an API that closely follows the native CSSStyleSheet API
2020
to maximize performance and reduce bloat.
2121

docs/About.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import Column from './Column'
77
const About = () => (
88
<section id='about'>
99
<Box pt={5} pb={5}>
10-
<Text f={4} bold>
10+
<Text f={4}>
1111
CXS is a minimal CSS-in-JS solution with an API that closely follows the native CSSStyleSheet API to maximize performance and reduce bloat.
1212
</Text>
1313
</Box>

docs/Pre.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import cxs from 'cxs/component'
22
import Text from './Text'
33

4+
const wrap = props => props.wrap ? { whiteSpace: 'pre-wrap' } : null
45
const Pre = cxs(Text)`
56
font-family: 'Roboto Mono', 'SF Mono', Menlo, monospace;
67
margin: 0;
78
overflow: auto;
9+
${wrap}
810
`
911

1012
Pre.defaultProps = {

docs/Stats.js

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ class Stats extends React.Component {
1313
}
1414

1515
componentDidMount () {
16+
console.timeEnd('mount')
1617
const css = cxs.css
1718
this.setState({
1819
css,
@@ -25,6 +26,7 @@ class Stats extends React.Component {
2526

2627
return (
2728
<Pre f={0}
29+
wrap
2830
title={css}
2931
onClick={e => alert(css) }>
3032
CXS generated {format(bytes)} bytes of CSS to render this page.

docs/bundle.js

+39
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/index.html

+1
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@
1212
<meta name='twitter:description' content='Fast af css-in-js in 1kb'>
1313
<meta name='twitter:image' content='http://jxnblk.com/cxs/card.png'>
1414
<div id=app></div>
15+
<script>console.time('mount')</script>
1516
<script src=bundle.js></script>
1617
<script>window.twttr = (function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0], t = window.twttr || {}; if (d.getElementById(id)) return t; js = d.createElement(s); js.id = id; js.src = "https://platform.twitter.com/widgets.js"; fjs.parentNode.insertBefore(js, fjs); t._e = []; t.ready = function(f) { t._e.push(f); }; return t; }(document, "script", "twitter-wjs"));</script>

object.js

-1
This file was deleted.

package.json

+1-5
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"main": "dist/index.js",
66
"scripts": {
77
"prepublish": "babel src -d dist",
8-
"build": "webpack -p",
8+
"build": "NODE_ENV=production webpack -p",
99
"start": "webpack-dev-server",
1010
"size": "npm run prepublish && bundlesize",
1111
"standard": "standard",
@@ -61,10 +61,6 @@
6161
"path": "./dist/component.js",
6262
"maxSize": "1.1 kb"
6363
},
64-
{
65-
"path": "./dist/object.js",
66-
"maxSize": "2 kb"
67-
},
6864
{
6965
"path": "./dist/atomic.js",
7066
"maxSize": "2 kb"

src/atomic.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import cxs from './index'
22

3-
const atomic = (styles, { media, child = '' } = {}) => {
3+
const atomic = (styles, opts = {}) => {
4+
const { media, child = '' } = opts
45
const classNames = []
56

67
for (let key in styles) {
@@ -51,7 +52,7 @@ export const combine = (s = '') => (...args) => args
5152
.trim()
5253

5354
const RE = /[^a-zA-Z0-9-_]/g
54-
export const clean = str => str.replace(RE, '-')
55+
export const clean = str => ('' + str).replace(RE, '-')
5556

5657
export const abbrMedia = media => {
5758
if (!media) return ''

src/object.js

-86
This file was deleted.

test/atomic.js

-1
Original file line numberDiff line numberDiff line change
@@ -135,4 +135,3 @@ test('addPx adds px unit to number values', t => {
135135
t.is(a, '32px')
136136
t.is(b, 1.5)
137137
})
138-

test/cxs.js

+15
Original file line numberDiff line numberDiff line change
@@ -163,3 +163,18 @@ test('cache returns a rule object', t => {
163163
t.is(typeof cached, 'object')
164164
t.is(cached.toString(), a.toString())
165165
})
166+
167+
test('keyframes', t => {
168+
const rule = cxs('transform:scale(.75);opacity:.5', {
169+
selector: 'from',
170+
media: '@keyframes glow'
171+
}).push('transform: scale(1);opacity:1', {
172+
selector: 'to',
173+
media: '@keyframes glow'
174+
})
175+
const css = cxs.css
176+
t.is(typeof css, 'string')
177+
t.regex(css, /@keyframes glow/)
178+
t.regex(css, /glow{from{/)
179+
t.regex(css, /glow{to{/)
180+
})

webpack.config.js

+14-6
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
const path = require('path')
2+
const webpack = require('webpack')
23

34
const config = {
4-
entry: {
5-
bundle: './docs/entry.js'
6-
},
5+
entry: './docs/entry.js',
76
output: {
8-
path: path.join(__dirname, '/example'),
9-
filename: '[name].js'
7+
path: path.join(__dirname, '/docs'),
8+
filename: 'bundle.js'
109
},
1110
resolve: {
1211
alias: {
1312
'cxs': path.join(__dirname, 'src')
14-
// 'cxs/component': path.join(__dirname, 'src')
1513
}
1614
},
1715

@@ -21,9 +19,19 @@ const config = {
2119
test: /\.js$/,
2220
exclude: /node_modules/,
2321
loader: 'babel-loader'
22+
},
23+
{
24+
test: /\.js$/,
25+
include: /objss/,
26+
loader: 'babel-loader'
2427
}
2528
]
2629
},
30+
plugins: [
31+
new webpack.DefinePlugin({
32+
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
33+
})
34+
],
2735
devServer: {
2836
contentBase: 'docs'
2937
}

0 commit comments

Comments
 (0)