Skip to content

Commit

Permalink
⬆️ Styled components v6 (#3050)
Browse files Browse the repository at this point in the history
* try updating styled components

* ♻️ Icon was tricky

* only changed import

* only change import

* only change import

* replaced CSSObject with StyledObject<any>

* refactoring needed due to new types

* refactoring due to new types

* fixing transient props

* replace removed FlattenSimpleInterpolation with 'any'

* Accordion: transient props

* Input: transient props

* Chip: transient props

* Checkbox: transient props

* Autocomplete: transient props

* Radio: transient props

* Avatar, Banner, ButtonGroup, Card: transient props

* breadcrumbs: fix deprecated event

* Storybook Stack: transient props

* pagination, progress: transient props

* sidesheet, slider, snackbar: transient props

* Switch, table: transient props

* TableOfContents, TopBar: transient props

* Tabs, TextArea, TextField: transient props

* Lab storybook: "stack" sc6 compatible

* Datepicker: filter styled propsforwarding

* Lab Button/Table stories: use style instead of css

* core-react: update snapshots

* Fix tests after sc6

* Data-grid: usse transient props

* use default export for styled again

* Table/Caption: fixed transient prop

* ⬆️ Update styled-components latest patch

* add back CSSObject type after patch added it back

* update snapshot
  • Loading branch information
oddvernes authored Sep 18, 2023
1 parent 5829e26 commit 251ddef
Show file tree
Hide file tree
Showing 112 changed files with 5,177 additions and 3,970 deletions.
4 changes: 4 additions & 0 deletions assets/font/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 20 additions & 6 deletions packages/eds-core-react/.storybook/components/Stack.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,32 @@
import styled, { CSSProperties } from 'styled-components'
import styled, { CSSObject } from 'styled-components'

type StackProps = {
direction?: CSSProperties['flexDirection']
align?: CSSProperties['alignItems']
direction?: CSSObject['flexDirection']
align?: CSSObject['alignItems']
children: React.ReactNode
} & React.HTMLAttributes<HTMLDivElement>

type StyledStackProps = {
$direction?: CSSObject['flexDirection']
$align?: CSSObject['alignItems']
}

export const Stack = styled.div<StackProps>`
const StyledStack = styled.div<StyledStackProps>`
display: flex;
flex-direction: column;
justify-content: center;
align-items: ${({ align }) => align || 'center'};
align-items: ${({ $align }) => $align || 'center'};
gap: 1rem;
flex-wrap: wrap;
@media screen and (min-width: 600px) {
flex-direction: ${({ direction }) => direction || 'row'};
flex-direction: ${({ $direction }) => $direction || 'row'};
}
`

export const Stack = ({ children, direction, align, ...rest }: StackProps) => {
return (
<StyledStack $direction={direction} $align={align} {...rest}>
{children}
</StyledStack>
)
}
5 changes: 2 additions & 3 deletions packages/eds-core-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@
"@types/ramda": "^0.29.2",
"@types/react": "^18.0.21",
"@types/react-dom": "^18.0.10",
"@types/styled-components": "^5.1.26",
"@types/testing-library__jest-dom": "^5.14.6",
"babel-loader": "^9.1.2",
"babel-plugin-styled-components": "^2.1.4",
Expand All @@ -82,14 +81,14 @@
"rollup-plugin-delete": "^2.0.0",
"rollup-plugin-postcss": "^4.0.2",
"storybook": "^7.3.0",
"styled-components": "5.3.9",
"styled-components": "6.0.8",
"tsc-watch": "^6.0.4",
"typescript": "^5.1.6"
},
"peerDependencies": {
"react": ">=16.8",
"react-dom": ">=16.8",
"styled-components": ">=4.2 < 6"
"styled-components": ">=4.2"
},
"dependencies": {
"@babel/runtime": "^7.22.5",
Expand Down
Loading

0 comments on commit 251ddef

Please sign in to comment.