mirror of
https://github.com/zhigang1992/styled-components.git
synced 2026-04-26 14:05:05 +08:00
* Initial work to add createGlobalStyle functionality * Delete global styles when component returned from createGlobalStyle is unmounted * Check context for stylesheet instance * Adjust the size of the browser style sheet after removing a textNode * Add initial implementation of removeComponent to ServerStyleSheet * Tidy up code as part of createGlobalStyle addition * Added printWidth to .prettierrc * Add createGlobalStyle information to CHANGELOG * Increase bundle size * Remove duplicate inject property * Add missing removeComponent method * Add basic test cases for createGlobalStyle * Add mutation test cases * fixup! Make tests work by pulling CONTEXT_KEY into StyleSheetManager locally * Basic implementation for interpolation and theme support * Test and WIP implementation for theme updates * Use correct theme update color * Add missing type annotations * Reimplement on top of GlobalStyle and StyleSheet * Add failing case for multiple rules * Use CSSConstructor correctly * Remove unused imports * Revert obsolete change * Improve test harness * Add support for multiple GlobalStyle components * Update test results * Revert obsolete change * Revert unrelated change * Explain purpose of static execution context * Fix flow issues * Fall back to null when children are not passed * Increase bundle size limit to 16.5kB * Be more explicit about getCSS scope * Avoid type errors for subscribe ob production builds * Mark withTheme usage as stop-gap measure * Warn about createGlobalStyle children being ignored * Add SSR test for createGlobalStyle * Increase commonjs bundle size to 12kB * Add a deprecation warning on `injectGlobal`. Resolve unrelated typo. * adjust changelog * Remove unnecessary ThemeProvider usage in Test case * Decrement start index in removeRules * Merge changes from develop * Update createGlobalStyle to new Context api * Fix typo in CHANGELOG.md * Remove package-lock.json and add to gitignore * Move global style updation into render method for GlobalStyleComponent * Throw error if children passed as props for createGlobalStyle component * Remove package.lock.json from sandbox * Remove injectGlobal API, replace it with createGlobalStyle in test cases * Unskip working test cases * Make changes based on feedback to PR * Remove injectGlobal.test.js.snap from tests * Replace injectglobal with createGlobalStyle in example * Add createGlobalStyle to standalone and no tags builds * adjust changelog
38 lines
917 B
JavaScript
38 lines
917 B
JavaScript
import React from 'react'
|
|
import styled, { createGlobalStyle, keyframes } from '..'
|
|
|
|
export default () => {
|
|
const GlobalStyle = createGlobalStyle`
|
|
body {
|
|
font-family: sans-serif;
|
|
}
|
|
`
|
|
|
|
// Create a <Title> react component that renders an <h1> which is
|
|
// centered, palevioletred and sized at 1.5em
|
|
const Title = styled.h1`
|
|
font-size: 1.5em;
|
|
text-align: center;
|
|
color: palevioletred;
|
|
animation: ${keyframes`from { opacity: 0; }`} 1s both;
|
|
`
|
|
|
|
// Create a <Wrapper> react component that renders a <section> with
|
|
// some padding and a papayawhip background
|
|
const Wrapper = styled.section`
|
|
padding: 4em;
|
|
background: papayawhip;
|
|
`
|
|
|
|
return class Example extends React.Component {
|
|
render() {
|
|
return (
|
|
<Wrapper>
|
|
<GlobalStyle />
|
|
<Title>Hello World, this is my first styled component!</Title>
|
|
</Wrapper>
|
|
)
|
|
}
|
|
}
|
|
}
|