-
Notifications
You must be signed in to change notification settings - Fork 602
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
feat(BaseStyles): Fix Typography and Common props when CSS modules feature flag is enabled #5444
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
e15d49a
Fix Typography and Common props for BaseStyles behind feature flag
JelloBagel a990f91
Update Text to use util includesSystemProps
JelloBagel ec5f0c6
Fix whiteSpace prop for BaseStyles
JelloBagel b4fe15c
Add changeset
JelloBagel 1d6f376
Fix color ts error
JelloBagel 5a70234
Updated color variable in AnchoredOverlay
JelloBagel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@primer/react": patch | ||
--- | ||
|
||
Fix Typography and Common props for BaseStyles when CSS modules feature flag is enabled |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,10 @@ | ||
import {BaseStyles} from '.' | ||
import type {Meta} from '@storybook/react' | ||
import React from 'react' | ||
import type {ComponentProps} from './utils/types' | ||
|
||
export default { | ||
title: 'Behaviors/BaseStyles/Dev', | ||
component: BaseStyles, | ||
} as Meta<ComponentProps<typeof BaseStyles>> | ||
|
||
export const Default = () => <BaseStyles>Hello</BaseStyles> | ||
export const Default = () => 'Hello' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import {COMMON, TYPOGRAPHY, type SystemCommonProps, type SystemTypographyProps} from '../constants' | ||
import type {SxProp} from '../sx' | ||
|
||
const COMMON_PROP_NAMES = new Set(Object.keys(COMMON)) | ||
const TYPOGRAPHY_PROP_NAMES = new Set(Object.keys(TYPOGRAPHY)) | ||
|
||
const includesSystemProps = (props: SxProp) => { | ||
if (props.sx) { | ||
return true | ||
} | ||
|
||
return Object.keys(props).some(prop => { | ||
return TYPOGRAPHY_PROP_NAMES.has(prop) || COMMON_PROP_NAMES.has(prop) | ||
}) | ||
} | ||
|
||
type TypographyAndCommonProp = SystemTypographyProps & SystemCommonProps | ||
|
||
const getTypographyAndCommonProps = (props: TypographyAndCommonProp): TypographyAndCommonProp => { | ||
let typographyAndCommonProps = {} as TypographyAndCommonProp | ||
for (const prop of Object.keys(props)) { | ||
if (TYPOGRAPHY_PROP_NAMES.has(prop) || COMMON_PROP_NAMES.has(prop)) { | ||
const p = prop as keyof TypographyAndCommonProp | ||
typographyAndCommonProps = {...typographyAndCommonProps, [p]: props[p]} | ||
} | ||
} | ||
|
||
return typographyAndCommonProps | ||
} | ||
|
||
export {includesSystemProps, getTypographyAndCommonProps} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 explicitly add the system props to
style
becauseBox
does not supportwhiteSpace
when it is passed as a prop. Open to changing this if there are alternatives to this