-
Notifications
You must be signed in to change notification settings - Fork 584
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(BaseStyles): Fix Typography and Common props when CSS modules fe…
…ature flag is enabled (#5444) * Fix Typography and Common props for BaseStyles behind feature flag * Update Text to use util includesSystemProps * Fix whiteSpace prop for BaseStyles * Add changeset * Fix color ts error * Updated color variable in AnchoredOverlay
- Loading branch information
1 parent
f9e193b
commit 8e481ca
Showing
8 changed files
with
152 additions
and
48 deletions.
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} |