Skip to content

Commit

Permalink
docs: update styled-components example to work without a wrapper
Browse files Browse the repository at this point in the history
Before 2.2.1-alpha.1 SC components needed to be wrapped by a function or class components to be used with the Props components.

2.2.1-alpha.1 fixes it, this commit showcases sc working without a hack.
  • Loading branch information
rakannimer committed Dec 12, 2019
1 parent a913102 commit 64d05e9
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 9 deletions.
2 changes: 1 addition & 1 deletion examples/styled-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"build": "docz build"
},
"dependencies": {
"docz": "latest",
"docz": "next",
"prop-types": "^15.7.2",
"react": "^16.8.6",
"react-dom": "^16.8.6",
Expand Down
4 changes: 1 addition & 3 deletions examples/styled-components/src/components/Alert.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,14 @@ const kinds = {
warning: '#FFA502',
}

const AlertStyled = styled('div')`
export const Alert = styled('div')`
padding: 15px 20px;
background: white;
border-radius: 3px;
color: white;
background: ${({ kind = 'info' }) => kinds[kind]};
`

export const Alert = props => <AlertStyled {...props} />

Alert.propTypes = {
kind: t.oneOf(['info', 'positive', 'negative', 'warning']),
}
Expand Down
6 changes: 1 addition & 5 deletions examples/styled-components/src/components/Button.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const kinds = outline => {
const getScale = ({ scale = 'normal' }) => scales[scale]
const getKind = ({ kind = 'primary', outline = false }) => kinds(outline)[kind]

const ButtonStyled = styled('button')`
export const Button = styled('button')`
${getKind};
${getScale};
cursor: pointer;
Expand All @@ -58,10 +58,6 @@ const ButtonStyled = styled('button')`
border-radius: 3px;
`

export const Button = ({ children, ...props }) => (
<ButtonStyled {...props}>{children}</ButtonStyled>
)

Button.propTypes = {
scales: t.oneOf(['small', 'normal', 'big']),
kind: t.oneOf(['primary', 'secondary', 'cancel', 'dark', 'gray']),
Expand Down

0 comments on commit 64d05e9

Please sign in to comment.