-
Notifications
You must be signed in to change notification settings - Fork 646
feat(Pagehead): Convert Pagehead component to CSS Modules behind feature flag
#5197
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
Merged
Merged
Changes from all commits
Commits
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 hidden or 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 `Pagehead` to CSS Modules |
This file contains hidden or 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,17 @@ | ||
| import React from 'react' | ||
| import type {Meta} from '@storybook/react' | ||
| import Pagehead from './Pagehead' | ||
| import Heading from '../Heading' | ||
|
|
||
| export default { | ||
| title: 'Deprecated/Components/Pagehead/Dev', | ||
| component: Pagehead, | ||
| } as Meta<typeof Pagehead> | ||
|
|
||
| export const Default = () => ( | ||
| <Pagehead sx={{color: 'red'}}> | ||
| <Heading as="h2" variant="small"> | ||
| Pagehead | ||
| </Heading> | ||
| </Pagehead> | ||
| ) |
This file contains hidden or 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,8 @@ | ||
| .Pagehead { | ||
| position: relative; | ||
| padding-top: var(--base-size-24); | ||
| padding-bottom: var(--base-size-24); | ||
| margin-bottom: var(--base-size-24); | ||
| /* stylelint-disable-next-line primer/borders */ | ||
| border-bottom: 1px solid var(--borderColor-default); | ||
| } |
This file contains hidden or 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,23 +1,42 @@ | ||
| import styled from 'styled-components' | ||
| import React, {type ComponentProps} from 'react' | ||
| import {clsx} from 'clsx' | ||
| import {get} from '../constants' | ||
| import type {SxProp} from '../sx' | ||
| import sx from '../sx' | ||
| import type {ComponentProps} from '../utils/types' | ||
| import sx, {type SxProp} from '../sx' | ||
| import {toggleStyledComponent} from '../internal/utils/toggleStyledComponent' | ||
| import classes from './Pagehead.module.css' | ||
| import {useFeatureFlag} from '../FeatureFlags' | ||
|
|
||
| const CSS_MODULES_FEATURE_FLAG = 'primer_react_css_modules_team' | ||
|
|
||
| /** | ||
| * @deprecated | ||
| */ | ||
| const Pagehead = styled.div<SxProp>` | ||
| position: relative; | ||
| padding-top: ${get('space.4')}; | ||
| padding-bottom: ${get('space.4')}; | ||
| margin-bottom: ${get('space.4')}; | ||
| border-bottom: 1px solid ${get('colors.border.default')}; | ||
| ${sx}; | ||
| ` | ||
| const StyledComponentPagehead = toggleStyledComponent( | ||
| CSS_MODULES_FEATURE_FLAG, | ||
| 'div', | ||
| styled.div<SxProp>` | ||
| position: relative; | ||
| padding-top: ${get('space.4')}; | ||
| padding-bottom: ${get('space.4')}; | ||
| margin-bottom: ${get('space.4')}; | ||
| border-bottom: 1px solid ${get('colors.border.default')}; | ||
| ${sx}; | ||
| `, | ||
| ) | ||
|
|
||
| const Pagehead = ({className, ...rest}: PageheadProps) => { | ||
| const enabled = useFeatureFlag(CSS_MODULES_FEATURE_FLAG) | ||
|
|
||
| if (enabled) { | ||
| return <StyledComponentPagehead className={clsx(classes.Pagehead, className)} {...rest} /> | ||
| } | ||
|
|
||
| return <StyledComponentPagehead {...rest} /> | ||
| } | ||
|
|
||
| /** | ||
| * @deprecated | ||
| */ | ||
| export type PageheadProps = ComponentProps<typeof Pagehead> | ||
| export type PageheadProps = ComponentProps<typeof StyledComponentPagehead> & SxProp | ||
| export default Pagehead |
This file contains hidden or 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
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.
Torn on this change, cause it now will technically accept the system props we were blocking before. I think the change comes from the toggleStyledComponent somewhere. But this is temporary. When we remove the feature flag it will be an error again.
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 can hold off on this and try and find a solution if you like? I don't mind, the temporary change could be in place for awhile depending on how things go?
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.
Na, if we work fast enough on this, it won't make a difference. and I don't think folks are adding these attributes in dotcom much anymore. if at all