Skip to content

Include CSS Custom Property for mono font family #4028

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

Merged
merged 4 commits into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions .changeset/use-css-variable.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
"@primer/react": minor
---
Use a CSS variable for the monospace font stack
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ exports[`BranchName renders consistently 1`] = `
display: inline-block;
padding: 2px 6px;
font-size: 12px;
font-family: SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;
font-family: var(--fontStack-monospace),SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;
color: #0969da;
background-color: #ddf4ff;
border-radius: 6px;
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/__snapshots__/TextInput.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1343,7 +1343,7 @@ exports[`TextInput renders monospace 1`] = `
align-items: stretch;
min-height: 32px;
overflow: hidden;
font-family: SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;
font-family: var(--fontStack-monospace),SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;
}

.c0 input,
Expand Down
10 changes: 9 additions & 1 deletion src/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,15 @@ const fonts = {
'Apple Color Emoji',
'Segoe UI Emoji',
]),
mono: fontStack(['SFMono-Regular', 'Consolas', 'Liberation Mono', 'Menlo', 'Courier', 'monospace']),
mono: fontStack([
'var(--fontStack-monospace)',
'SFMono-Regular',
'Consolas',
'Liberation Mono',
'Menlo',
'Courier',
'monospace',
]),
Comment on lines +25 to +33
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
mono: fontStack([
'var(--fontStack-monospace)',
'SFMono-Regular',
'Consolas',
'Liberation Mono',
'Menlo',
'Courier',
'monospace',
]),
mono: fontStack([
'var(--fontStack-monospace,
SFMono-Regular,
Consolas,
Liberation Mono,
Menlo,
Courier,
monospace)',
]),

I think it should be like this, but I'm not 100% sure.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am now 95% sure I am wrong.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think either version works

}

const fontWeights = {
Expand Down