-
Notifications
You must be signed in to change notification settings - Fork 538
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Details): Convert Details to css module behind feature flag (#5167)
* Convert Details component to CSS modules behind team flag * Update snapshot name * Create clean-mails-accept.md * test(vrt): update snapshots * Fixing the type to not allow styled system * Fix for sxProp --------- Co-authored-by: jonrohan <jonrohan@users.noreply.github.com>
- Loading branch information
Showing
23 changed files
with
117 additions
and
44 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": minor | ||
--- | ||
|
||
Convert Details to css module behind feature flag |
Binary file added
BIN
+6.11 KB
...Details.test.ts-snapshots/Details-SX-Prop-Stress-Test-dark-colorblind-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+8.16 KB
...ls.test.ts-snapshots/Details-SX-Prop-Stress-Test-dark-colorblind-open-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+6.09 KB
...nts/Details.test.ts-snapshots/Details-SX-Prop-Stress-Test-dark-dimmed-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+8.27 KB
...etails.test.ts-snapshots/Details-SX-Prop-Stress-Test-dark-dimmed-open-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+6.14 KB
...ails.test.ts-snapshots/Details-SX-Prop-Stress-Test-dark-high-contrast-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+8.63 KB
...test.ts-snapshots/Details-SX-Prop-Stress-Test-dark-high-contrast-open-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+6.11 KB
...components/Details.test.ts-snapshots/Details-SX-Prop-Stress-Test-dark-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+8.16 KB
...nents/Details.test.ts-snapshots/Details-SX-Prop-Stress-Test-dark-open-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+6.11 KB
...Details.test.ts-snapshots/Details-SX-Prop-Stress-Test-dark-tritanopia-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+8.16 KB
...ls.test.ts-snapshots/Details-SX-Prop-Stress-Test-dark-tritanopia-open-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+6.19 KB
...etails.test.ts-snapshots/Details-SX-Prop-Stress-Test-light-colorblind-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+7.03 KB
...s.test.ts-snapshots/Details-SX-Prop-Stress-Test-light-colorblind-open-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+6.21 KB
...ils.test.ts-snapshots/Details-SX-Prop-Stress-Test-light-high-contrast-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+8.01 KB
...est.ts-snapshots/Details-SX-Prop-Stress-Test-light-high-contrast-open-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+6.19 KB
...omponents/Details.test.ts-snapshots/Details-SX-Prop-Stress-Test-light-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+7.03 KB
...ents/Details.test.ts-snapshots/Details-SX-Prop-Stress-Test-light-open-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+6.19 KB
...etails.test.ts-snapshots/Details-SX-Prop-Stress-Test-light-tritanopia-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+7.03 KB
...s.test.ts-snapshots/Details-SX-Prop-Stress-Test-light-tritanopia-open-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,27 @@ | ||
import React from 'react' | ||
import type {StoryFn, Meta} from '@storybook/react' | ||
import Details from './Details' | ||
import {Button} from '../Button' | ||
import useDetails from '../hooks/useDetails' | ||
|
||
export default { | ||
title: 'Components/Details/Dev', | ||
component: Details, | ||
} as Meta<typeof Details> | ||
|
||
export const SxPropStressTest: StoryFn<typeof Details> = () => { | ||
const {getDetailsProps} = useDetails({closeOnOutsideClick: true}) | ||
return ( | ||
<Details | ||
{...getDetailsProps()} | ||
sx={{ | ||
backgroundColor: 'accent.emphasis', | ||
color: 'accent.fg', | ||
p: 4, | ||
}} | ||
> | ||
<Button as="summary">See Details</Button> | ||
This is some content | ||
</Details> | ||
) | ||
} |
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,7 @@ | ||
.Details > summary { | ||
list-style: none; | ||
} | ||
|
||
.Details > summary::-webkit-details-marker { | ||
display: none; | ||
} |
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,20 +1,41 @@ | ||
import React, {type ComponentPropsWithoutRef, type ReactElement} from 'react' | ||
import styled from 'styled-components' | ||
import type {SxProp} from '../sx' | ||
import sx from '../sx' | ||
import type {ComponentProps} from '../utils/types' | ||
import {toggleStyledComponent} from '../internal/utils/toggleStyledComponent' | ||
import {useFeatureFlag} from '../FeatureFlags' | ||
import {clsx} from 'clsx' | ||
import classes from './Details.module.css' | ||
|
||
const Details = styled.details<SxProp>` | ||
& > summary { | ||
list-style: none; | ||
} | ||
& > summary::-webkit-details-marker { | ||
display: none; | ||
} | ||
const CSS_MODULES_FEATURE_FLAG = 'primer_react_css_modules_team' | ||
|
||
${sx}; | ||
` | ||
const StyledDetails = toggleStyledComponent( | ||
CSS_MODULES_FEATURE_FLAG, | ||
'details', | ||
styled.details<SxProp>` | ||
& > summary { | ||
list-style: none; | ||
} | ||
& > summary::-webkit-details-marker { | ||
display: none; | ||
} | ||
${sx}; | ||
`, | ||
) | ||
|
||
const Details = React.forwardRef<HTMLDetailsElement, DetailsProps>( | ||
({className, children, ...rest}, ref): ReactElement => { | ||
const enabled = useFeatureFlag(CSS_MODULES_FEATURE_FLAG) | ||
return ( | ||
<StyledDetails className={clsx(className, {[classes.Details]: enabled})} {...rest} ref={ref}> | ||
{children} | ||
</StyledDetails> | ||
) | ||
}, | ||
) | ||
|
||
Details.displayName = 'Details' | ||
|
||
export type DetailsProps = ComponentProps<typeof Details> | ||
export type DetailsProps = ComponentPropsWithoutRef<'details'> & SxProp | ||
export default Details |