-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
[system] Fix various issues reported by using @mui/styled-engine-sc #29035
[system] Fix various issues reported by using @mui/styled-engine-sc #29035
Conversation
…tyled-engine-sc/better-support-styled-components-ts
…tyled-engine-sc/better-support-styled-components-ts
Latest commit using The failing CI checks are because of the unresolved issues described in the PR description. There is nothing we can do about them at this moment, but the important bits are that those are not revelnt to the users of the packages. |
</Box> | ||
</ThemeProvider> | ||
</CacheProvider> | ||
<StyleSheetManager stylisPlugins={[rtlPluginSc]}> |
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.
Adding the StyleSheetManager
too so that we can support styled-components
in the future too.
@@ -537,10 +537,11 @@ describe('styled', () => { | |||
|
|||
const classList = Array.from(container.firstChild.classList); | |||
const regExp = new RegExp(`.*-MuiComponent-slot$`); | |||
const regExpSC = new RegExp(`MuiComponent-slot.*`); |
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.
emotion
appends, but styled-components
prepends the label.
} | ||
|
||
export function shouldForwardProp(propName: PropertyKey): boolean; | ||
export type CreateMUIStyled<T extends object = DefaultTheme> = CreateMUIStyledStyledEngine< |
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 now using the CreateMUIStyled
coming from the styled engine.
@@ -6,3 +10,170 @@ export { default as StyledEngineProvider } from './StyledEngineProvider'; | |||
|
|||
export { default as GlobalStyles } from './GlobalStyles'; | |||
export * from './GlobalStyles'; | |||
|
|||
export interface SerializedStyles { |
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.
These are basically just copied from the packages/mui-system/createStyled.d.ts
.
export { default as GlobalStyles } from './GlobalStyles'; | ||
export * from './GlobalStyles'; | ||
|
||
// These are the same as the ones in @mui/styled-engine |
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.
These are the same as the ones in @mui/styled-engine
just using styled-components
.
@@ -95,7 +95,7 @@ const StoreTemplateLink = React.forwardRef< | |||
|
|||
const StoreTemplateImage = React.forwardRef< | |||
HTMLImageElement, | |||
{ brand: TemplateBrand } & JSX.IntrinsicElements['img'] | |||
{ brand: TemplateBrand } & Omit<JSX.IntrinsicElements['img'], 'ref'> |
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 changes on the ref
s are related to this issue: https://codesandbox.io/s/elegant-matan-k7mw4?file=/src/App.tsx
See styled-components/styled-components#3191 (comment)
We can also use React.ComponentPropsWithoutRef<'img'>
instead. I will update if we decide to go with this option.
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.
We can also use React.ComponentPropsWithoutRef<'img'> instead. I will update if we decide to go with this option.
Sounds good to me.
@@ -120,7 +121,7 @@ const monthMap = [ | |||
function CalendarPickerSkeleton(props: CalendarPickerSkeletonProps) { | |||
const { className, ...other } = useThemeProps< | |||
Theme, | |||
JSX.IntrinsicElements['div'], | |||
Omit<JSX.IntrinsicElements['div'], 'ref'> & { ref?: React.Ref<HTMLDivElement> }, |
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'm curious, how is it different from JSX.IntrinsicElements['div']
? I saw that JSX.IntrinsicElements['div']
has a ref of type string | Ref<T>
- does the string makes a difference that breaks things here?
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.
type Ref<T> = RefCallback<T> | RefObject<T> | null;
type LegacyRef<T> = string | Ref<T>; // this is the ref type of JSX.IntrinsicElements
the LegacyRef is wider than Ref, that's why there is a type error. The other way to fix is to define LegacyRef
in packages/mui-styled-engine/src/index.d.ts
. Not sure if this is a good idea.
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 other way to fix is to define LegacyRef in packages/mui-styled-engine/src/index.d.ts. Not sure if this is a good idea.
I would be scared to do this, mainly because then if you switch to mui's styled() to styled-components styled() it would break, but we would like those two to behave the same.
docs/src/pages/premium-themes/onepirate/modules/views/ProductHeroLayout.tsx
Outdated
Show resolved
Hide resolved
Not able to integrate make style for v5.2 in typescript. |
@NikhilKale123 please open an issue with a reproduction and we can take a look |
Fixing some issues found by using
@mui/styled-engine-sc
directly in the@mui/system
. Inspired by #29036. The changes from #29036 are also included here. The purpose is to battle test how well the integration withstyled-components
is really working.Fixes #28905
Fixes #27167
List of problems found:
styled-component
's utils should be compatible with mui'sstyled()
if@mui/styled-engine-sc
is usedIssues found:
React.HTMLProps
The issues (not blocking) that I could not resolve are: