-
Notifications
You must be signed in to change notification settings - Fork 4
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
update emotion 11, and vulnerable deps #147
Conversation
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.
Several files, mostly the same @emotion/core
to @emotion/react
change... along with a couple extra changes to help typescript and emotion get along.
{ | ||
'preset-react': { | ||
runtime: 'automatic', | ||
importSource: '@emotion/react', |
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.
New JSX runtime 🎉
@@ -20,7 +20,7 @@ | |||
*/ | |||
|
|||
import React, { ReactNode, ReactNodeArray } from 'react'; | |||
import { css } from '@emotion/core'; | |||
import { css } from '@emotion/react'; |
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.
plenty of this same change to go around... (i.e. most files have this line)
${({ theme, size }: { theme: typeof defaultTheme; size: ErrorSize }) => css` | ||
const ErrorContentContainer = styled('div')<{ size: ErrorSize }>` |
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.
styled components now have the theme type defined internally, from emotion.d.ts
@@ -303,26 +302,22 @@ const ApiTokenInfo = () => { | |||
return ( | |||
<div> | |||
<h2 | |||
css={(theme) => |
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 pattern is unnecessary when using useTheme
import { DMSThemeInterface } from '.'; | ||
|
||
declare module '@emotion/react' { | ||
export interface Theme extends DMSThemeInterface {} |
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.
adds the theme typing to the Emotion internals (styled etc.)
"@emotion/react": "^11.8.2", | ||
"@emotion/styled": "^11.8.1", |
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.
The main purpose of this PR.
"jsonwebtoken": "^8.5.1", | ||
"jwt-decode": "^3.1.2", | ||
"lodash": "^4.17.21", | ||
"next": "^12.0.10", | ||
"next": "^12.1.2", |
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.
little extra goodie 🍪
@@ -13,8 +17,16 @@ | |||
"resolveJsonModule": true, | |||
"isolatedModules": true, | |||
"jsx": "preserve", | |||
"jsxImportSource": "@emotion/react", |
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.
TSX Runtime 🎉
Of notice, NextJS enforces "jsx": "preserve"
which is required for the Emotion css
props.
@@ -111,82 +110,88 @@ const ErrorTitle = styled('h1')` | |||
|
|||
const ErrorNotification = ({ | |||
children, | |||
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.
Not sure when/if things changed within emotion
, but passing css
into a non-styled
component now requires for you to define a className
props, else you get a cryptic message saying css does not exist on type...
.
Chatting with their team to amend their documentation to make that detail crystal clear explicit.
/> | ||
</span> | ||
}) => { | ||
const theme = useTheme(); |
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 change here triggered a whole lot of indentation. The reason why this matter is because the component needs to get the theme from the provider, rather than loading it directly from the default theme object, lest it won't get customisations made on runtime.
@@ -62,7 +62,7 @@ export const ErrorPageLayout = ({ | |||
<ErrorNotification | |||
size="lg" | |||
title={errorTitle} | |||
styles={` | |||
css={css` |
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.
pass the styles as css classname
components/ErrorNotification.tsx
Outdated
@@ -111,82 +110,88 @@ const ErrorTitle = styled('h1')` | |||
|
|||
const ErrorNotification = ({ | |||
children, | |||
className, | |||
title, | |||
size, | |||
styles = '', |
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.
is styles still needed here? @caravinci
doesn't seem to be in use and I think Emotion is handling all the styles well
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.
Likely not. I left it there to support earlier implementation, but you're right, we needn't it anymore.
good call! will amend asap.
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.
tested, looks great. one small comment about style prop if you think it's a change
6a7c874
to
bd7dc46
Compare
Updates to Emotion 11 and applies theme type correctly through the internals.
Bonus: Updates a few vulnerable/outdated components.