-
Notifications
You must be signed in to change notification settings - Fork 1
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
UNSAFE classname test #1826
base: main
Are you sure you want to change the base?
UNSAFE classname test #1826
Conversation
✅ Deploy Preview for spirit-design-system ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for spirit-design-system-storybook ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
@@ -52,4 +52,6 @@ const _Button = <T extends ElementType = 'button', C = void, S = void>( | |||
|
|||
const Button = forwardRef<HTMLButtonElement, SpiritButtonProps<ElementType>>(_Button); | |||
|
|||
Button.isSystemComponent = true; |
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.
suggestion: I think, we will use something like Button.spiritComponent = Button
for cases where we want to check if it is a Spirit component or if we want a name.
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.
Or we can use Button.isSpiritComponent
first and reimplement it when needed.
const styleProps = { | ||
style: Object.keys(style).length > 0 ? style : undefined, | ||
className: classNames(UNSAFE_className, ...styleUtilities) || undefined, | ||
const rimmerProps = { |
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.
suggestion: Please, remove this.
...(UNSAFE_style !== undefined && { UNSAFE_style }), | ||
...(UNSAFE_className !== undefined && { UNSAFE_className }), | ||
}, | ||
props: rimmerProps as HTMLAttributes<HTMLElement>, |
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.
suggestion: This should be refactored back.
// For backward compatibility! | ||
/** Sets the CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the element. Only use as a **last resort**. Use style props instead. */ | ||
UNSAFE_className?: string; | ||
/** Sets inline [style](https://developer.mozilla.org/en-US/docs/Web/API/Element/style) for the element. Only use as a **last resort**. Use style props instead. */ | ||
UNSAFE_style?: CSSProperties; | ||
useUnsafe?: boolean; |
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.
suggestion: We do not need this anymore.
props: HTMLAttributes<HTMLElement>; | ||
}; | ||
|
||
export function useStyleProps<T extends StyleProps>(props: T): StylePropsResult { | ||
const classNamePrefix = useContext(ClassNamePrefixContext); | ||
const { UNSAFE_className, UNSAFE_style, ...otherProps } = props; | ||
const { UNSAFE_className, UNSAFE_style, ElementTag, ...otherProps } = props; |
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.
suggestion: I think we should pass here only the bool value and not the entire ElementTag/Component.
Description
UNSAFE_className
,UNSAFE_style
className
,style
, etc.Warning
Some components are still broken and will need to be fixed in upcoming changes.
The problem is that some components spread their props, while others combine classes inline.
Additional context
Note
Testing demo available at Next.js app router: http://localhost:3000/test1
Issue reference
(UNSAFE_)className v elementType komponentach