New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Styled Components 5 #1543
Styled Components 5 #1543
Conversation
95c5651
to
b37d81d
Compare
42d9555
to
72abdc0
Compare
01d7540
to
3dbbc18
Compare
d9929ab
to
0827902
Compare
@@ -33,7 +33,7 @@ import { DataTable, DataTableProps } from '../DataTable' | |||
import { columns } from '../../__mocks__/DataTable/columns' | |||
|
|||
const Template: Story<DataTableProps> = ({ ...args }) => ( | |||
<DataTable columns={[]} {...args}> | |||
<DataTable {...args}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TS 3.9 caught this bug (columns
specified twice)
'**/*.story.*', | ||
'**/stories/*', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stories should not end-up in the build artifact.
@@ -72,7 +72,7 @@ | |||
"jest": "^26.5.3", | |||
"jest-canvas-mock": "^2.3.0", | |||
"jest-image-snapshot": "^4.2.0", | |||
"jest-styled-components": "^6.3.4", | |||
"jest-styled-components": "^7.0.3", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
jest-styled-components
7.x is compatible with styled-components
5.x
@@ -68,7 +68,7 @@ const DialogContentLayout: FC<DialogContentLayoutProps> = ({ | |||
|
|||
return ( | |||
<div | |||
className={`${className} ${overflow ? 'overflow' : ''}`} | |||
className={overflow ? `overflow ${className}` : className} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previously was appending extra whitespace for no reason
expect(list).toBeInTheDocument() | ||
expect(list).toHaveStyleRule('list-style-type', 'none') | ||
expect(list).toHaveStyle('list-style-type: none;') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
toHaveStyleRule
wasn't getting picked up properly in SC5. Other clean-ups were just included since I was refactoring anyway.
.c3 input:checked + .c1 { | ||
color: #6C43E0; | ||
} | ||
|
||
.c3 input:not(:checked) + .c1 { | ||
background: #FFFFFF; | ||
border-color: #DEE1E5; | ||
} | ||
|
||
.c3 input:focus + .c1 { | ||
border-color: #9785F2; | ||
box-shadow: 0 0 0 2px #E8E5FF; | ||
outline: none; | ||
} | ||
|
||
.c3 input:disabled + .c1 { | ||
color: #939BA5; | ||
} | ||
|
||
.c3 input:disabled:not(:checked) + .c1 { | ||
background: #F5F6F7; | ||
} | ||
|
||
.c3 input:disabled:not(:checked) + .c1::after { | ||
background: #F5F6F7; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure why this isn't emitted anymore but Components still works so 🤷
I think SC5 might be smart enough to emit the pseudo styles more cleverly now.
.c3 .c1 { | ||
position: absolute; | ||
right: 0.5rem; | ||
top: 0.5rem; | ||
} | ||
|
||
.c4 .c1 { | ||
position: absolute; | ||
right: 0.5rem; | ||
top: 0.5rem; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is used to position alert. Still works even with this snapshot change. Again, I think SC is "tree shaking" unused CSS better now.
@mdodgelooker I'd like to land this today so I can work on the other side of the house. You'll notice some changes to snapshots where some CSS isn't emitted anymore - I'm pretty sure SC5 introduces a better "tree shaking" behavior where it doesn't emit unused CSS in cases where it's not needed. |
@@ -145,11 +145,11 @@ exports[`Avatar AvatarCombo renders Avatar and its secondary avatar 1`] = ` | |||
/> | |||
</div> | |||
<div | |||
className="c4 c5" | |||
className="AvatarCombo__AvatarIconSecondary-gekgjm-0 c4" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it seem like something's not quite working with jest-styled-components
when there's nested styled components? AvatarCombo__AvatarIconSecondary-gekgjm-0
should still be c4
, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactored DialogContent to make remove class component, removed problematic test and replaced with Storybook image-snapshot Remove `FieldText.stories` storybook - it wasn't useful Replaced instances of `toHaveStyle` with `toHaveStyleRule` (former doesn't work well with SC5)
Refactored DialogContent to make remove class component, removed problematic test and replaced with Storybook image-snapshot Remove `FieldText.stories` storybook - it wasn't useful Replaced instances of `toHaveStyle` with `toHaveStyleRule` (former doesn't work well with SC5)
Babel tweak and snapshot updates Upgrade to TS 3.9.4 Snapshot updates
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ship it!
@media screen and (min-width:30rem) { | ||
|
||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is also mentioned in that same issue 🤷♂️
styled-components/jest-styled-components#276
✨ Changes
✅ Requirements
yarn image-snapshots
locally)📷 Screenshots