Skip to content
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

chore(docs): add value for color tokens where missing #85

Merged
merged 1 commit into from
Oct 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions packages/module/patternfly-docs/content/tokensTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ const getTokenChain = (themeTokenData) => {
return tokenChain;
};

const showTokenChain = (themeTokenData) => {
const tokenChain = getTokenChain(themeTokenData);
const showTokenChain = (themeTokenData, hasReferences) => {
// Show final value if isColorToken but no references - otherwise color value not displayed in table
const tokenChain = hasReferences ? getTokenChain(themeTokenData) : [themeTokenData.value];
return (
<div>
{tokenChain.map((nextValue, index) => (
Expand Down Expand Up @@ -158,6 +159,7 @@ export const TokensTable = ({ tokenJson, formatThemeText = capitalize }) => {
const hasReferences = tokenThemesArr.some(([_themeName, themeToken]) =>
themeToken.hasOwnProperty('references')
);
const isColorToken = tokenThemesArr[0][1].type === 'color';
const tokenDescription = tokenThemesArr[0][1].description;

return (
Expand All @@ -166,7 +168,7 @@ export const TokensTable = ({ tokenJson, formatThemeText = capitalize }) => {
{/* Expandable row icon */}
<Td
expand={
hasReferences
hasReferences || isColorToken
? {
rowIndex,
isExpanded: isTokenExpanded(tokenName),
Expand Down Expand Up @@ -214,7 +216,7 @@ export const TokensTable = ({ tokenJson, formatThemeText = capitalize }) => {
</Tr>

{/* Expandable token chain */}
{hasReferences && isTokenExpanded(tokenName) && (
{(hasReferences || isColorToken) && isTokenExpanded(tokenName) && (
<Tr isExpanded>
<Td />
<Td colSpan={3}>
Expand All @@ -223,7 +225,7 @@ export const TokensTable = ({ tokenJson, formatThemeText = capitalize }) => {
{tokenThemesArr.map(([themeName, themeToken]) => (
<>
<GridItem span={2}>{formatThemeText(themeName)}:</GridItem>
<GridItem span={10}>{showTokenChain(themeToken)}</GridItem>
<GridItem span={10}>{showTokenChain(themeToken, hasReferences)}</GridItem>
</>
))}
</Grid>
Expand Down
Loading