-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added a font-weight variation in typography documentation (#156)
- Loading branch information
Showing
5 changed files
with
94 additions
and
0 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
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,18 @@ | ||
import "@hopper-ui/tokens/fonts.css"; | ||
import "./preview.css"; | ||
|
||
interface FontWeightPreviewProps { | ||
values?: TypographyValues; | ||
style?: React.CSSProperties; | ||
} | ||
|
||
interface TypographyValues { | ||
fontWeight?: string; | ||
} | ||
|
||
const FontWeightPreview = ({ values, style }: FontWeightPreviewProps) => { | ||
return <div className="hd-preview hd-preview--font hd-preview--typography" style={{ fontWeight: values?.fontWeight, ...style }}>Aa</div>; | ||
}; | ||
|
||
export default FontWeightPreview; | ||
|
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,64 @@ | ||
"use client"; | ||
|
||
import React from "react"; | ||
import TypographyPreview from "@/components/preview/TypographyPreview"; | ||
import Code from "@/components/ui/code/Code"; | ||
|
||
import "./table.css"; | ||
|
||
interface TypographyVariantTableProps { | ||
data: Record<string, { name: string; value: string }[]>; | ||
type: string; | ||
} | ||
|
||
const TypographyVariantTable = ({ type, data }: TypographyVariantTableProps) => { | ||
const tokenData = data["fontWeight"]; | ||
|
||
const filteredDataByType: Array<{ name: string; value: string }> = tokenData.filter(item => | ||
item.name.includes(type) | ||
); | ||
|
||
const filteredDataByWeightVariation: Array<{ name: string; value: string }> = filteredDataByType.filter(item => | ||
item.name.includes("bold") || | ||
item.name.includes("semibold") || | ||
item.name.includes("medium") | ||
); | ||
|
||
const listItems = filteredDataByWeightVariation.map(item => { | ||
const fontWeight = item.value; | ||
|
||
return ( | ||
<React.Fragment key={`${item.name}`}> | ||
<tr className="hd-typo__row hd-top__row"> | ||
<td className="hd-table__cell hd-typo__cell">{item.name}</td> | ||
<td className="hd-table__cell hd-typo__cell rowSpan={2}"> | ||
<Code value={`--${item.name}`}>{`--${item.name}`}</Code> | ||
</td> | ||
<td className="hd-table__cell hd-typo__cell"> | ||
{item.value} | ||
</td> | ||
<td className="hd-table__cell hd-typo__cell"> | ||
<TypographyPreview values={{ fontWeight }} /> | ||
</td> | ||
</tr> | ||
</React.Fragment> | ||
); | ||
}); | ||
|
||
return ( | ||
<table className="hd-table hd-typo-table" aria-label="Tokens"> | ||
<thead> | ||
<tr> | ||
<th className="hd-table__column">Name</th> | ||
<th className="hd-table__column" colSpan={2}>Value</th> | ||
<th className="hd-table__column">Preview</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{listItems} | ||
</tbody> | ||
</table> | ||
); | ||
}; | ||
|
||
export default TypographyVariantTable; |
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