-
Notifications
You must be signed in to change notification settings - Fork 538
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(Token): Migrate to CSS modules behind feature flag Pt 1 #5251
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
85a0d46
Migrate container and remove button to CSS modules
randall-krauskopf 1f0afd8
fix format
randall-krauskopf 67d0c7d
update to use vars
randall-krauskopf c53d37d
update related snapshots
randall-krauskopf e081bd0
Merge branch 'main' into token-css-modules-1
hussam-i-am 7ed1d98
Merge branch 'main' into token-css-modules-1
randall-krauskopf 5ea31e8
Merge branch 'main' into token-css-modules-1
randall-krauskopf 3d65c72
small refactor
randall-krauskopf 3f48964
Merge branch 'main' into token-css-modules-1
randall-krauskopf 0628003
remove dead code
randall-krauskopf 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,50 @@ | ||
.TokenButton { | ||
display: inline-flex; | ||
padding: 0; | ||
margin-left: var(--base-size-4); | ||
font-family: inherit; | ||
color: currentColor; | ||
text-decoration: none; | ||
cursor: pointer; | ||
user-select: none; | ||
background-color: transparent; | ||
border: 0; | ||
border-radius: var(--borderRadius-full); | ||
justify-content: center; | ||
align-items: center; | ||
appearance: none; | ||
align-self: baseline; | ||
} | ||
|
||
.TokenButton[data-size='small'] { | ||
width: var(--base-size-16); | ||
height: var(--base-size-16); | ||
} | ||
|
||
.TokenButton[data-size='medium'] { | ||
width: 20px; | ||
height: 20px; | ||
} | ||
|
||
.TokenButton[data-size='large'] { | ||
width: var(--base-size-24); | ||
height: var(--base-size-24); | ||
margin-left: var(--base-size-8); | ||
} | ||
|
||
.TokenButton[data-size='xlarge'] { | ||
width: var(--base-size-32); | ||
height: var(--base-size-32); | ||
margin-left: var(--base-size-8); | ||
} | ||
|
||
.TokenButton:hover, | ||
.TokenButton:focus { | ||
/* TODO: choose a better functional color variable for this */ | ||
background-color: var(--bgColor-neutral-muted); | ||
} | ||
|
||
.TokenButton:active { | ||
/* TODO: choose a better functional color variable for this */ | ||
background-color: var(--bgColor-neutral-muted); | ||
} |
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,46 @@ | ||
.TokenTextContainer { | ||
width: auto; | ||
min-width: 0; | ||
padding: 0; | ||
margin: 0; | ||
overflow: hidden; | ||
font: inherit; | ||
/* stylelint-disable-next-line primer/typography */ | ||
line-height: normal; | ||
color: inherit; | ||
|
||
/* reset anchor styles */ | ||
color: currentColor; | ||
text-decoration: none; | ||
text-overflow: ellipsis; | ||
white-space: nowrap; | ||
|
||
/* reset button styles, make the cursor a pointer, and add line-height */ | ||
background: transparent; | ||
border: none; | ||
flex-grow: 1; | ||
-webkit-font-smoothing: inherit; | ||
-moz-osx-font-smoothing: inherit; | ||
appearance: none; | ||
} | ||
|
||
/* Position psuedo-element above text content, but below the | ||
remove button. | ||
This ensures the <a> or <button> receives the click no | ||
matter where on the token the user clicks. */ | ||
.TokenTextContainer:is(a, button, [tabIndex='0']) { | ||
cursor: pointer; | ||
} | ||
|
||
/* Position psuedo-element above text content, but below the | ||
remove button. | ||
This ensures the <a> or <button> receives the click no | ||
matter where on the token the user clicks. */ | ||
.TokenTextContainer:is(a, button, [tabIndex='0'])::after { | ||
position: absolute; | ||
top: 0; | ||
right: 0; | ||
bottom: 0; | ||
left: 0; | ||
content: ''; | ||
} |
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,46 +1,67 @@ | ||
import styled from 'styled-components' | ||
import type {TokenBaseProps} from './TokenBase' | ||
import {toggleStyledComponent} from '../internal/utils/toggleStyledComponent' | ||
import React from 'react' | ||
import classes from './_TokenTextContainer.module.css' | ||
import {useFeatureFlag} from '../FeatureFlags' | ||
import {clsx} from 'clsx' | ||
|
||
const TokenTextContainer = styled('span')<Partial<TokenBaseProps>>` | ||
flex-grow: 1; | ||
min-width: 0; | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
white-space: nowrap; | ||
|
||
// reset button styles, make the cursor a pointer, and add line-height | ||
background: transparent; | ||
border: none; | ||
color: inherit; | ||
font: inherit; | ||
margin: 0; | ||
padding: 0; | ||
width: auto; | ||
-webkit-font-smoothing: inherit; | ||
-moz-osx-font-smoothing: inherit; | ||
-webkit-appearance: none; | ||
line-height: normal; | ||
|
||
// reset anchor styles | ||
color: currentColor; | ||
text-decoration: none; | ||
|
||
// Position psuedo-element above text content, but below the | ||
// remove button. | ||
// This ensures the <a> or <button> receives the click no | ||
// matter where on the token the user clicks. | ||
&:is(a, button, [tabIndex='0']) { | ||
cursor: pointer; | ||
|
||
&:after { | ||
content: ''; | ||
position: absolute; | ||
left: 0; | ||
top: 0; | ||
right: 0; | ||
bottom: 0; | ||
const CSS_MODULES_FEATURE_FLAG = 'primer_react_css_modules_team' | ||
|
||
const StyledTokenTextContainer = toggleStyledComponent( | ||
CSS_MODULES_FEATURE_FLAG, | ||
'span', | ||
styled('span')` | ||
flex-grow: 1; | ||
min-width: 0; | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
white-space: nowrap; | ||
|
||
// reset button styles, make the cursor a pointer, and add line-height | ||
background: transparent; | ||
border: none; | ||
color: inherit; | ||
font: inherit; | ||
margin: 0; | ||
padding: 0; | ||
width: auto; | ||
-webkit-font-smoothing: inherit; | ||
-moz-osx-font-smoothing: inherit; | ||
-webkit-appearance: none; | ||
line-height: normal; | ||
|
||
// reset anchor styles | ||
color: currentColor; | ||
text-decoration: none; | ||
|
||
// Position psuedo-element above text content, but below the | ||
// remove button. | ||
// This ensures the <a> or <button> receives the click no | ||
// matter where on the token the user clicks. | ||
&:is(a, button, [tabIndex='0']) { | ||
cursor: pointer; | ||
|
||
&:after { | ||
content: ''; | ||
position: absolute; | ||
left: 0; | ||
top: 0; | ||
right: 0; | ||
bottom: 0; | ||
} | ||
} | ||
} | ||
` | ||
`, | ||
) | ||
|
||
const TokenTextContainer = ({children, ...props}: React.PropsWithChildren<Partial<TokenBaseProps>>) => { | ||
const enabled = useFeatureFlag(CSS_MODULES_FEATURE_FLAG) | ||
|
||
return ( | ||
<StyledTokenTextContainer className={clsx(enabled && classes.TokenTextContainer)} {...props}> | ||
{children} | ||
</StyledTokenTextContainer> | ||
) | ||
} | ||
|
||
export default TokenTextContainer |
Oops, something went wrong.
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.
Curious could you add this to the
.TokenButton[data-size='xlarge']
and.TokenButton[data-size='large']
selectors instead of adding.Bigger
?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.
Good callout! Update