Skip to content

Commit

Permalink
Add ::selection background color token (#806)
Browse files Browse the repository at this point in the history
* new selection token

* Create ten-pandas-care.md

* github-actions[bot] Regenerated snapshots

---------

Co-authored-by: langermank <[email protected]>
  • Loading branch information
langermank and langermank authored Feb 16, 2024
1 parent 4fb40ff commit 7016323
Show file tree
Hide file tree
Showing 143 changed files with 143 additions and 34 deletions.
5 changes: 5 additions & 0 deletions .changeset/ten-pandas-care.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@primer/primitives": patch
---

Add `::selection` background color token
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ export const Foreground = () => {
})
return (
<Table.Container>
<Table.Title as="h1" id="pattern">
<h1 className="sr-only" id="table-heading">
Foreground
</Table.Title>
</h1>
<DataTable
aria-labelledby="pattern"
data={data}
Expand Down Expand Up @@ -72,9 +72,9 @@ export const Background = () => {
})
return (
<Table.Container>
<Table.Title as="h1" id="pattern">
<h1 className="sr-only" id="table-heading">
Background
</Table.Title>
</h1>
<DataTable
aria-labelledby="pattern"
data={data}
Expand Down Expand Up @@ -118,9 +118,9 @@ export const Border = () => {
})
return (
<Table.Container>
<Table.Title as="h1" id="pattern">
<h1 className="sr-only" id="table-heading">
Border
</Table.Title>
</h1>
<DataTable
aria-labelledby="pattern"
data={data}
Expand Down Expand Up @@ -164,9 +164,9 @@ export const Shadow = () => {
})
return (
<Table.Container>
<Table.Title as="h1" id="pattern">
<h1 className="sr-only" id="table-heading">
Shadow
</Table.Title>
</h1>
<DataTable
aria-labelledby="pattern"
data={data}
Expand Down
96 changes: 71 additions & 25 deletions docs/storybook/stories/Color/Patterns/AllPatterns.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ export const Avatar = () => {
})
return (
<Table.Container>
<Table.Title as="h1" id="pattern">
<h1 className="sr-only" id="table-heading">
Avatar
</Table.Title>
</h1>
<DataTable
aria-labelledby="pattern"
data={data}
Expand Down Expand Up @@ -99,9 +99,9 @@ export const Control = () => {
}))
return (
<Table.Container>
<Table.Title as="h1" id="pattern">
<h1 className="sr-only" id="table-heading">
Control
</Table.Title>
</h1>
<DataTable
aria-labelledby="pattern"
data={data}
Expand Down Expand Up @@ -152,9 +152,9 @@ export const Counter = () => {
})
return (
<Table.Container>
<Table.Title as="h1" id="pattern">
<h1 className="sr-only" id="table-heading">
Counter
</Table.Title>
</h1>
<DataTable
aria-labelledby="pattern"
data={data}
Expand Down Expand Up @@ -217,9 +217,9 @@ export const Button = () => {
}))
return (
<Table.Container>
<Table.Title as="h1" id="pattern">
<h1 className="sr-only" id="table-heading">
Button
</Table.Title>
</h1>
<DataTable
aria-labelledby="pattern"
data={data}
Expand Down Expand Up @@ -270,9 +270,9 @@ export const Focus = () => {
})
return (
<Table.Container>
<Table.Title as="h1" id="pattern">
<h1 className="sr-only" id="table-heading">
Focus
</Table.Title>
</h1>
<DataTable
aria-labelledby="pattern"
data={data}
Expand Down Expand Up @@ -316,9 +316,9 @@ export const Header = () => {
})
return (
<Table.Container>
<Table.Title as="h1" id="pattern">
<h1 className="sr-only" id="table-heading">
Header
</Table.Title>
</h1>
<DataTable
aria-labelledby="pattern"
data={data}
Expand Down Expand Up @@ -369,9 +369,9 @@ export const Menu = () => {
})
return (
<Table.Container>
<Table.Title as="h1" id="pattern">
<h1 className="sr-only" id="table-heading">
Menu
</Table.Title>
</h1>
<DataTable
aria-labelledby="pattern"
data={data}
Expand Down Expand Up @@ -422,9 +422,9 @@ export const Overlay = () => {
})
return (
<Table.Container>
<Table.Title as="h1" id="pattern">
<h1 className="sr-only" id="table-heading">
Overlay
</Table.Title>
</h1>
<DataTable
aria-labelledby="pattern"
data={data}
Expand Down Expand Up @@ -475,9 +475,9 @@ export const SelectMenu = () => {
})
return (
<Table.Container>
<Table.Title as="h1" id="pattern">
<h1 className="sr-only" id="table-heading">
SelectMenu
</Table.Title>
</h1>
<DataTable
aria-labelledby="pattern"
data={data}
Expand Down Expand Up @@ -528,9 +528,9 @@ export const SideNav = () => {
})
return (
<Table.Container>
<Table.Title as="h1" id="pattern">
<h1 className="sr-only" id="table-heading">
SideNav
</Table.Title>
</h1>
<DataTable
aria-labelledby="pattern"
data={data}
Expand Down Expand Up @@ -581,9 +581,9 @@ export const TimelineBadge = () => {
})
return (
<Table.Container>
<Table.Title as="h1" id="pattern">
<h1 className="sr-only" id="table-heading">
TimelineBadge
</Table.Title>
</h1>
<DataTable
aria-labelledby="pattern"
data={data}
Expand Down Expand Up @@ -634,11 +634,11 @@ export const UnderlineNav = () => {
})
return (
<Table.Container>
<Table.Title as="h1" id="pattern">
<h1 className="sr-only" id="table-heading">
UnderlineNav
</Table.Title>
</h1>
<DataTable
aria-labelledby="pattern"
aria-labelledby="table-heading"
data={data}
columns={[
{
Expand Down Expand Up @@ -677,3 +677,49 @@ export const UnderlineNav = () => {
</Table.Container>
)
}

export const Selection = () => {
const data = getTokensByName(colorTokens, 'selection').map(token => {
return {
id: token.name,
...token,
}
})
return (
<Table.Container>
<h1 className="sr-only" id="selection">
Text selection
</h1>
<DataTable
aria-labelledby="selection"
data={data}
columns={[
{
header: 'Sample',
field: 'name',
rowHeader: true,
renderCell: row => {
return <ColorTokenSwatch selectionColor={row.name.includes('bgColor') ? row.name : undefined} />
},
},
{
header: 'Token',
field: 'name',
rowHeader: true,
renderCell: row => {
return <InlineCode value={row.name} copyClipboard />
},
},
{
header: 'Output value',
field: 'value',
rowHeader: true,
renderCell: row => {
return <p>{row.value}</p>
},
},
]}
/>
</Table.Container>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,22 @@
outline-style: solid;
border-radius: var(--borderRadius-small);
}

.ColorTokenSwatch-selection {
font: var(--text-codeBlock-shorthand);
padding-inline: var(--base-size-8);
width: var(--base-size-20);
height: var(--base-size-20);
position: relative;
display: grid;
color: var(--fgColor-default);
}

.ColorTokenSwatch-selection::before {
content: '';
height: 100%;
width: 100%;
background: var(--selection-bgColor);
position: absolute;
border-radius: var(--borderRadius-small);
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,17 @@ export type ColorTokenSwatchProps = {
bgColor?: string
shadowColor?: string
outlineColor?: string
selectionColor?: string
}

export function ColorTokenSwatch({textColor, borderColor, bgColor, shadowColor, outlineColor}: ColorTokenSwatchProps) {
export function ColorTokenSwatch({
textColor,
borderColor,
bgColor,
shadowColor,
outlineColor,
selectionColor,
}: ColorTokenSwatchProps) {
return (
<>
{textColor && (
Expand All @@ -23,6 +31,7 @@ export function ColorTokenSwatch({textColor, borderColor, bgColor, shadowColor,
{outlineColor && (
<div style={{outlineColor: `var(--${outlineColor})`}} className="ColorTokenSwatch-outline"></div>
)}
{selectionColor && <div className="ColorTokenSwatch-selection">Aa</div>}
</>
)
}
Expand Down
15 changes: 15 additions & 0 deletions src/tokens/functional/color/dark/patterns-dark.json5
Original file line number Diff line number Diff line change
Expand Up @@ -2043,4 +2043,19 @@
},
},
},
selection: {
bgColor: {
$value: '{fgColor.link.@}',
$type: 'color',
$extensions: {
'org.primer.figma': {
collection: 'mode',
mode: 'dark',
group: 'component',
scopes: ['bgColor'],
},
},
alpha: 0.2,
},
},
}
15 changes: 15 additions & 0 deletions src/tokens/functional/color/light/patterns-light.json5
Original file line number Diff line number Diff line change
Expand Up @@ -2041,4 +2041,19 @@
},
},
},
selection: {
bgColor: {
$value: '{fgColor.link.@}',
$type: 'color',
$extensions: {
'org.primer.figma': {
collection: 'mode',
mode: 'light',
group: 'component',
scopes: ['bgColor'],
},
},
alpha: 0.1,
},
},
}

0 comments on commit 7016323

Please sign in to comment.