-
Notifications
You must be signed in to change notification settings - Fork 535
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(Details): Convert Details to css module behind feature flag #5167
Merged
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
8c71b03
Convert Details component to CSS modules behind team flag
jonrohan 806acbb
Update snapshot name
jonrohan d6cc8d4
Create clean-mails-accept.md
jonrohan 753a700
test(vrt): update snapshots
jonrohan db5749a
Fixing the type to not allow styled system
jonrohan 1b1eeb8
Fix for sxProp
jonrohan 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": 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'> | ||
export default Details |
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.
Is that a new practise we're exploring that includes the stories in the e2e test file? 👀
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.
Yeah @joshblack started doing this in some of the other tests and thought I would unify around it