Skip to content

Commit

Permalink
feat: like v8.0.4 but without sc@4 support #9
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeysova committed Nov 13, 2018
1 parent 545c3b8 commit 921b15d
Show file tree
Hide file tree
Showing 6 changed files with 323 additions and 3,216 deletions.
31 changes: 3 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ The original `normalize.css` is pulled from [necolas/normalize.css](https://gith
npm install --save styled-normalize
```

### styled-components v2 and v3
### styled-components v3

```js
// ----- styles/index.js
Expand All @@ -29,37 +29,12 @@ injectGlobal`
`
```

### styled-components v4

styled-components [createGlobalStyle documentation](https://www.styled-components.com/docs/api#createglobalstyle)

> This is just usage example
```js
// ----- index.js
import React from 'react'
import { Normalize } from 'styled-normalize'

import { App } from './app'

const Root = () => (
<React.Fragment>
<Normalize />
<App />
</React.Fragment>
)
```

> For older version of styled-components this API renders to `null`
You can also use named imports:

```js
// ES Modules
import { normalize, Normalize } from 'styled-normalize'
import { normalize } from 'styled-normalize'

// CommonJS
const { normalize, Normalize } = require('styled-normalize')
const { normalize } = require('styled-normalize')
```

## License
Expand Down
9 changes: 1 addition & 8 deletions bin/fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,15 @@ const normalizePackage = JSON.parse(fs.readFileSync('./node_modules/normalize.cs
const normalizeMain = path.join('./node_modules/normalize.css', normalizePackage.main)
const normalizeContent = fs.readFileSync(normalizeMain, 'utf8')

const normalizeVersion = normalizePackage.version
const cleanedContent = normalizeContent.replace(cleanRegexp, '').replace(/^\s*\n/gm, '')

const resultContent = `
import { css, createGlobalStyle } from 'styled-components'
export const version = '${normalizeVersion}'
import { css } from 'styled-components'
export const normalize = css\`
${cleanedContent}
\`
export const Normalize = createGlobalStyle
? createGlobalStyle\`\${normalize}\`
: () => null
export default normalize
`

Expand Down
7 changes: 2 additions & 5 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { InterpolationValue, GlobalStyleClass, DefaultTheme } from 'styled-components'

export const version: string
import { InterpolationValue } from 'styled-components'

declare const normalize: InterpolationValue
declare const Normalize: (() => null) | GlobalStyleClass<{}, DefaultTheme>

export { normalize, Normalize }
export { normalize }
export default normalize
Loading

0 comments on commit 921b15d

Please sign in to comment.