Skip to content

Commit

Permalink
Feature/font fallback (#183)
Browse files Browse the repository at this point in the history
  • Loading branch information
fraincs authored Mar 13, 2024
2 parents 54f9446 + 73a19a1 commit 3f0b9be
Show file tree
Hide file tree
Showing 10 changed files with 70 additions and 50 deletions.
6 changes: 6 additions & 0 deletions .changeset/long-pens-punch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@hopper-ui/styled-system": minor
"@hopper-ui/tokens": minor
---

Added font fallback to font tokens
6 changes: 4 additions & 2 deletions apps/docs/components/copyButton/CopyButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import "./copyButton.css";
interface CopyButtonProps {
variant?: "default" | "inline" | "ghost";
text: string;
onDark?: boolean;
className?: string;
onCopy?: () => void;
copyMessage?: string;
Expand All @@ -20,11 +21,12 @@ const CopiedSvg = <svg width="24" height="24" className="hd-copy-button__icon" f
const CopySvg = <svg width="16" height="16" className="hd-copy-button__icon" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M13.3333 6H7.33333C6.59695 6 6 6.59695 6 7.33333V13.3333C6 14.0697 6.59695 14.6667 7.33333 14.6667H13.3333C14.0697 14.6667 14.6667 14.0697 14.6667 13.3333V7.33333C14.6667 6.59695 14.0697 6 13.3333 6Z" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" /><path d="M3.33337 9.99992H2.66671C2.31309 9.99992 1.97395 9.85944 1.7239 9.60939C1.47385 9.35935 1.33337 9.02021 1.33337 8.66659V2.66659C1.33337 2.31296 1.47385 1.97382 1.7239 1.72378C1.97395 1.47373 2.31309 1.33325 2.66671 1.33325H8.66671C9.02033 1.33325 9.35947 1.47373 9.60952 1.72378C9.85956 1.97382 10 2.31296 10 2.66659V3.33325" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" /></svg>;

const CopyButton = (
{ text, className, children, onCopy, variant = "default", copyMessage = "Copied!", ...rest }: React.PropsWithChildren<CopyButtonProps>) => {
{ text, className, children, onCopy, variant = "default", onDark, copyMessage = "Copied!", ...rest }: React.PropsWithChildren<CopyButtonProps>) => {
const [isCopied, setIsCopied] = React.useState(false);

const classes = clsx("hd-copy-button", {
[`hd-copy-button--${variant}`]: variant !== "default"
[`hd-copy-button--${variant}`]: variant !== "default",
"hd-copy-button--on-dark": onDark === true
}, className);

const copy = async () => {
Expand Down
8 changes: 8 additions & 0 deletions apps/docs/components/copyButton/copyButton.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
background-color: var(--hd-color-neutral-surface-weak);
}

.hd-copy-button.hd-copy-button--on-dark:not([disabled]):hover {
background-color: var(--hd-neutral-800);
}

.hd-copy-button__icon {
stroke: currentcolor;
}
Expand All @@ -34,3 +38,7 @@
.hd-copy-button--ghost:not([disabled]):hover {
background-color: transparent;
}

.hd-copy-button--on-dark {
color: #FFFFFF;
}
2 changes: 1 addition & 1 deletion apps/docs/components/ui/pre/Pre.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const Pre = ({ children, title, "data-language": dataLanguage, raw, ...props }:
);

const titleContent = <span className="hd-pre-header__title">{title}</span>;
const copyButton = raw && <CopyButton text={raw} />;
const copyButton = raw && <CopyButton onDark text={raw} />;

return (
<pre {...props} className={classes}>
Expand Down
2 changes: 1 addition & 1 deletion apps/docs/components/ui/table/TypographyTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ const TypographyTable = ({ type, data }: TypographyTableProps) => {
<td className="hd-table__cell hd-typo__cell">
<Code value={`--hop-${type}${displaySize}-font-family`}>{`--hop-${type}${displaySize}-font-family`}</Code>
</td>
<td className="hd-table__cell hd-typo__cell">
<td className="hd-table__cell hd-typo__cell hd-typo__cell-font-family">
{fontFamily}
</td>
</tr>
Expand Down
4 changes: 4 additions & 0 deletions apps/docs/components/ui/table/table.css
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@
border-bottom: 0;
}

.hd-typo__cell-font-family {
max-width: 125px;
}

.hd-top__row .hd-table__cell {
border-top: var(--hd-border-size) solid var(--hd-color-neutral-border);
}
Expand Down
6 changes: 3 additions & 3 deletions apps/docs/datas/tokens-dark.json
Original file line number Diff line number Diff line change
Expand Up @@ -563,15 +563,15 @@
"fontFamily": [
{
"name": "hop-font-family-primary",
"value": "ABC Favorit"
"value": "'ABC Favorit', Helvetica, Arial, sans-serif"
},
{
"name": "hop-font-family-secondary",
"value": "Inter"
"value": "'Inter', Helvetica, Arial, sans-serif"
},
{
"name": "hop-font-family-tertiary",
"value": "ABC Favorit Mono"
"value": "'ABC Favorit Mono', Consolas, 'SF Mono', monospace"
}
],
"fontSize": [
Expand Down
74 changes: 37 additions & 37 deletions apps/docs/datas/tokens.json
Original file line number Diff line number Diff line change
Expand Up @@ -563,15 +563,15 @@
"fontFamily": [
{
"name": "hop-font-family-primary",
"value": "ABC Favorit"
"value": "'ABC Favorit', Helvetica, Arial, sans-serif"
},
{
"name": "hop-font-family-secondary",
"value": "Inter"
"value": "'Inter', Helvetica, Arial, sans-serif"
},
{
"name": "hop-font-family-tertiary",
"value": "ABC Favorit Mono"
"value": "'ABC Favorit Mono', Consolas, 'SF Mono', monospace"
}
],
"fontSize": [
Expand Down Expand Up @@ -2893,135 +2893,135 @@
"fontFamily": [
{
"name": "hop-heading-3xl-font-family",
"value": "ABC Favorit"
"value": "'ABC Favorit', Helvetica, Arial, sans-serif"
},
{
"name": "hop-heading-2xl-font-family",
"value": "ABC Favorit"
"value": "'ABC Favorit', Helvetica, Arial, sans-serif"
},
{
"name": "hop-heading-xl-font-family",
"value": "ABC Favorit"
"value": "'ABC Favorit', Helvetica, Arial, sans-serif"
},
{
"name": "hop-heading-lg-font-family",
"value": "ABC Favorit"
"value": "'ABC Favorit', Helvetica, Arial, sans-serif"
},
{
"name": "hop-heading-md-font-family",
"value": "ABC Favorit"
"value": "'ABC Favorit', Helvetica, Arial, sans-serif"
},
{
"name": "hop-heading-sm-font-family",
"value": "ABC Favorit"
"value": "'ABC Favorit', Helvetica, Arial, sans-serif"
},
{
"name": "hop-heading-xs-font-family",
"value": "ABC Favorit"
"value": "'ABC Favorit', Helvetica, Arial, sans-serif"
},
{
"name": "hop-heading-xs-medium-font-family",
"value": "ABC Favorit"
"value": "'ABC Favorit', Helvetica, Arial, sans-serif"
},
{
"name": "hop-overline-font-family",
"value": "ABC Favorit Mono"
"value": "'ABC Favorit Mono', Consolas, 'SF Mono', monospace"
},
{
"name": "hop-body-2xl-font-family",
"value": "Inter"
"value": "'Inter', Helvetica, Arial, sans-serif"
},
{
"name": "hop-body-xl-font-family",
"value": "Inter"
"value": "'Inter', Helvetica, Arial, sans-serif"
},
{
"name": "hop-body-lg-font-family",
"value": "Inter"
"value": "'Inter', Helvetica, Arial, sans-serif"
},
{
"name": "hop-body-lg-medium-font-family",
"value": "Inter"
"value": "'Inter', Helvetica, Arial, sans-serif"
},
{
"name": "hop-body-lg-semibold-font-family",
"value": "Inter"
"value": "'Inter', Helvetica, Arial, sans-serif"
},
{
"name": "hop-body-lg-bold-font-family",
"value": "Inter"
"value": "'Inter', Helvetica, Arial, sans-serif"
},
{
"name": "hop-body-lg-underline-font-family",
"value": "Inter"
"value": "'Inter', Helvetica, Arial, sans-serif"
},
{
"name": "hop-body-md-font-family",
"value": "Inter"
"value": "'Inter', Helvetica, Arial, sans-serif"
},
{
"name": "hop-body-md-medium-font-family",
"value": "Inter"
"value": "'Inter', Helvetica, Arial, sans-serif"
},
{
"name": "hop-body-md-semibold-font-family",
"value": "Inter"
"value": "'Inter', Helvetica, Arial, sans-serif"
},
{
"name": "hop-body-md-bold-font-family",
"value": "Inter"
"value": "'Inter', Helvetica, Arial, sans-serif"
},
{
"name": "hop-body-md-underline-font-family",
"value": "Inter"
"value": "'Inter', Helvetica, Arial, sans-serif"
},
{
"name": "hop-body-sm-font-family",
"value": "Inter"
"value": "'Inter', Helvetica, Arial, sans-serif"
},
{
"name": "hop-body-sm-medium-font-family",
"value": "Inter"
"value": "'Inter', Helvetica, Arial, sans-serif"
},
{
"name": "hop-body-sm-semibold-font-family",
"value": "Inter"
"value": "'Inter', Helvetica, Arial, sans-serif"
},
{
"name": "hop-body-sm-bold-font-family",
"value": "Inter"
"value": "'Inter', Helvetica, Arial, sans-serif"
},
{
"name": "hop-body-sm-underline-font-family",
"value": "Inter"
"value": "'Inter', Helvetica, Arial, sans-serif"
},
{
"name": "hop-body-xs-font-family",
"value": "Inter"
"value": "'Inter', Helvetica, Arial, sans-serif"
},
{
"name": "hop-body-xs-medium-font-family",
"value": "Inter"
"value": "'Inter', Helvetica, Arial, sans-serif"
},
{
"name": "hop-body-xs-semibold-font-family",
"value": "Inter"
"value": "'Inter', Helvetica, Arial, sans-serif"
},
{
"name": "hop-body-xs-bold-font-family",
"value": "Inter"
"value": "'Inter', Helvetica, Arial, sans-serif"
},
{
"name": "hop-body-xs-underline-font-family",
"value": "Inter"
"value": "'Inter', Helvetica, Arial, sans-serif"
},
{
"name": "hop-accent-lg-font-family",
"value": "ABC Favorit"
"value": "'ABC Favorit', Helvetica, Arial, sans-serif"
},
{
"name": "hop-accent-sm-font-family",
"value": "ABC Favorit"
"value": "'ABC Favorit', Helvetica, Arial, sans-serif"
}
],
"fontSize": [
Expand Down Expand Up @@ -3535,4 +3535,4 @@
}
]
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,9 @@ export const CoreTokens = {
"--hop-shadow-sm": "0 1px 6px 0 rgba(60, 60, 60, 0.10)",
"--hop-shadow-md": "0 4px 10px 4px rgba(60, 60, 60, 0.08)",
"--hop-shadow-lg": "0 10px 18px 8px rgba(60, 60, 60, 0.08)",
"--hop-font-family-primary": "ABC Favorit",
"--hop-font-family-secondary": "Inter",
"--hop-font-family-tertiary": "ABC Favorit Mono",
"--hop-font-family-primary": "'ABC Favorit', Helvetica, Arial, sans-serif",
"--hop-font-family-secondary": "'Inter', Helvetica, Arial, sans-serif",
"--hop-font-family-tertiary": "'ABC Favorit Mono', Consolas, 'SF Mono', monospace",
"--hop-font-size-120": "0.75rem",
"--hop-font-size-140": "0.875rem",
"--hop-font-size-160": "1rem",
Expand Down
6 changes: 3 additions & 3 deletions packages/tokens/src/tokens/core/fonts.tokens.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
"family": {
"primary" : {
"$type": "fontFamily",
"$value": "ABC Favorit"
"$value": "'ABC Favorit', Helvetica, Arial, sans-serif"
},
"secondary" : {
"$type": "fontFamily",
"$value": "Inter"
"$value": "'Inter', Helvetica, Arial, sans-serif"
},
"tertiary" : {
"$type": "fontFamily",
"$value": "ABC Favorit Mono"
"$value": "'ABC Favorit Mono', Consolas, 'SF Mono', monospace"
}
},
"size": {
Expand Down

0 comments on commit 3f0b9be

Please sign in to comment.