-
Notifications
You must be signed in to change notification settings - Fork 347
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into release-dropdown-v2
- Loading branch information
Showing
115 changed files
with
3,655 additions
and
1,933 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 |
---|---|---|
@@ -1,5 +1,3 @@ | ||
coverage | ||
docs/build | ||
docs/.next | ||
docs/docs-components/metadata.js | ||
flow-typed | ||
|
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 |
---|---|---|
@@ -1,3 +1 @@ | ||
coverage | ||
docs/build | ||
node_modules |
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
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,47 @@ | ||
// @flow strict | ||
import { type Node as ReactNode } from 'react'; | ||
import { Fragment, type Node as ReactNode } from 'react'; | ||
import { Box, Text } from 'gestalt'; | ||
import tokens from 'gestalt-design-tokens/dist/json/variables.json'; | ||
import ColorTile from './ColorTile'; | ||
|
||
type Props = { | ||
name: string, | ||
tokenId: string, | ||
tokenData: $ReadOnlyArray<string>, | ||
}; | ||
|
||
function ColorPalette({ name, tokenId }: Props): ReactNode { | ||
const tokenNumbers = [0, 50, 100, 200, 300, 400, 500, 550, 600, 700, 800, 900]; | ||
const colorId = `${tokenId}-${name.toLowerCase()}`; | ||
function ColorPalette({ name, tokenId, tokenData }: Props): ReactNode { | ||
if (tokenData) { | ||
const tiles = tokenData.map((token) => { | ||
const regex = /\d+(?=\D*$)/; | ||
const grade = (token.match(regex) || [])[0]; | ||
const isTransparent = tokenId === 'transparent'; | ||
const textColor = Number(grade) <= 400 || isTransparent ? 'dark' : 'light'; | ||
|
||
const isTransparent = tokenId === 'transparent'; | ||
if (isTransparent || (grade !== '450' && !Number.isNaN(Number(grade)))) { | ||
return ( | ||
<ColorTile | ||
key={token} | ||
description={grade || 'transparent'} | ||
number={Number(grade) || 0} | ||
textColor={textColor} | ||
token={token} | ||
/> | ||
); | ||
} | ||
|
||
return ( | ||
<Box marginBottom={8} marginTop={8}> | ||
<Text weight="bold"> | ||
{name} ({tokenId}) | ||
</Text> | ||
{isTransparent ? ( | ||
<Box marginTop={2}> | ||
<ColorTile description="" fullTokenName="color-transparent" number={0} /> | ||
</Box> | ||
) : ( | ||
<Box marginTop={2}> | ||
{tokenNumbers.map((number) => { | ||
const textColor = number > 400 ? 'light' : 'dark'; | ||
const colorVariableName = `color-${colorId}-${number}`; | ||
return tokens[colorVariableName] ? ( | ||
<ColorTile | ||
description={`${number}`} | ||
fullTokenName={colorVariableName} | ||
number={number} | ||
textColor={textColor} | ||
/> | ||
) : null; | ||
})} | ||
return null; | ||
}); | ||
|
||
return ( | ||
<Fragment> | ||
<Box marginBottom={8} marginTop={8}> | ||
<Text weight="bold"> | ||
{name} ({tokenId}) | ||
</Text> | ||
</Box> | ||
)} | ||
</Box> | ||
); | ||
{tiles} | ||
</Fragment> | ||
); | ||
} | ||
} | ||
export default ColorPalette; |
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
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
Oops, something went wrong.