-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
badge: chonkify badge and tags #86207
Conversation
return { | ||
...props, | ||
type: | ||
props.type === 'highlight' | ||
? 'info' | ||
: props.type === 'error' | ||
? 'danger' | ||
: props.type === 'white' | ||
? 'default' | ||
: props.type === 'black' | ||
? 'default' | ||
: props.type === undefined | ||
? 'default' | ||
: props.type, |
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.
can we use a mapping instead 🫠
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 the main reason why no-nested-ternary
exists. Any reason it’s not turned on in sentry?
return { | ||
...props, | ||
type: | ||
props.type === 'highlight' | ||
? 'info' | ||
: props.type === 'error' | ||
? 'danger' | ||
: props.type === 'white' | ||
? 'default' | ||
: props.type === 'black' | ||
? 'default' | ||
: props.type === undefined | ||
? 'default' | ||
: props.type, |
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.
return { | |
...props, | |
type: | |
props.type === 'highlight' | |
? 'info' | |
: props.type === 'error' | |
? 'danger' | |
: props.type === 'white' | |
? 'default' | |
: props.type === 'black' | |
? 'default' | |
: props.type === undefined | |
? 'default' | |
: props.type, | |
const legacyTypeMapping = { | |
highlight: 'info', | |
error: 'danger', | |
white: 'default', | |
black: 'default', | |
[undefined]: 'default' | |
}; | |
return { | |
...props, | |
type: legacyTypeMapping[props.type] ?? props.type, |
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.
What is this [undefined]: 'default'
😂 ?
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.
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.
if we make type
optional in ChonkTagProps
and then destruct it to ’default’
where necessary, we can do this:
const legacyTypeMapping: Partial<Record<NonNullable<TagProps['type']>, TagType>> = {
highlight: 'info',
error: 'danger',
white: 'default',
black: 'default',
};
export function chonkTagPropMapping(props: TagProps): ChonkTagProps {
return {
...props,
type: props.type && legacyTypeMapping[props.type],
};
}
Bundle ReportChanges will increase total bundle size by 2.01kB (0.0%) ⬆️. This is within the configured threshold ✅ Detailed changes
Affected Assets, Files, and Routes:view changes for bundle: app-webpack-bundle-array-pushAssets Changed:
|
Designs have changed, this PR adjusts them to the latest spec
Designs have changed, this PR adjusts them to the latest spec