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

Change default font to Inter #1676

Merged
merged 1 commit into from
Jun 17, 2024
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
7 changes: 5 additions & 2 deletions .storybook/preview-head.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
}

body {
font-family: -apple-system, BlinkMacSystemFont, 'San Francisco', 'Segoe UI',
Roboto, 'Helvetica Neue', sans-serif;
Inter, -apple-system, "system-ui", "San Francisco", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

h1,
Expand Down Expand Up @@ -60,3 +59,7 @@
color: #b3e39a;
}
</style>
<link
rel="stylesheet"
href="https://cdn.shopify.com/static/fonts/inter/v4/styles.css"
/>
2 changes: 1 addition & 1 deletion .storybook/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ export default create({
brandUrl: 'https://github.com/Shopify/polaris-viz',
brandImage: logo,
fontBase:
"-apple-system, BlinkMacSystemFont, 'San Francisco', 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif",
"Inter, -apple-system, 'system-ui', 'San Francisco', 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif",
fontCode: "Monaco, Consolas, 'Lucida Console', monospace",
});
2 changes: 2 additions & 0 deletions packages/polaris-viz-core/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import {InternalChartType, ChartState, Hue} from './types';

export const LINE_HEIGHT = 14;
export const FONT_SIZE = 12;
export const FONT_FAMILY =
'Inter, -apple-system, "system-ui", "San Francisco", "Segoe UI", Roboto, "Helvetica Neue", sans-serif';

export const XMLNS = 'http://www.w3.org/2000/svg';

Expand Down
1 change: 1 addition & 0 deletions packages/polaris-viz-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export {
AREAS_TRANSITION_CONFIG,
STROKE_DOT_ARRAY_WIDTH,
EXTERNAL_EVENTS_SET_HIDDEN_ITEMS,
FONT_FAMILY,
} from './constants';
export {
clamp,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ $color-yellow-150: #1d1f01;
$color-yellow-160: #111200;

// stylelint-disable value-keyword-case
$font-stack-base: -apple-system, BlinkMacSystemFont, 'San Francisco', 'Segoe UI',
$font-stack-base: Inter, -apple-system, 'system-ui', 'San Francisco', 'Segoe UI',
Roboto, 'Helvetica Neue', sans-serif;
// stylelint-enable value-keyword-case

Expand Down
6 changes: 5 additions & 1 deletion packages/polaris-viz/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

<!-- ## Unreleased -->
## Unreleased

### Changed

- Use `Inter` as the default initial font.

## [13.2.1] - 2024-06-17

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// stylelint-disable
// 🔨 copy from storybook table styles
.PropertyTable {
font-family: -apple-system, BlinkMacSystemFont, 'San Francisco', 'Segoe UI',
font-family: Inter, -apple-system, 'system-ui', 'San Francisco', 'Segoe UI',
Roboto, 'Helvetica Neue', sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import {Fragment} from 'react';
import {LINE_HEIGHT, useChartContext} from '@shopify/polaris-viz-core';
import {
FONT_FAMILY,
LINE_HEIGHT,
useChartContext,
} from '@shopify/polaris-viz-core';

import {FONT_SIZE} from '../../constants';

Expand Down Expand Up @@ -45,6 +49,7 @@ export function SingleTextLine({
width={targetWidth}
fill={color}
fontSize={FONT_SIZE}
fontFamily={FONT_FAMILY}
y={y}
x={x}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
}

.FormattedVerticalLabel {
font-weight: 700;
overflow: hidden;
display: -webkit-box;
-webkit-line-clamp: 5;
Expand All @@ -38,7 +37,6 @@
}

.FormattedHorizontalLabel {
font-weight: 700;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
Expand All @@ -58,4 +56,5 @@

.Value {
margin-right: 8px;
font-weight: 650;
}
2 changes: 2 additions & 0 deletions packages/polaris-viz/src/components/TextLine/TextLine.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {Fragment} from 'react';
import {FONT_FAMILY} from '@shopify/polaris-viz-core';

import {useTheme} from '../../hooks';
import {FONT_SIZE} from '../../constants';
Expand Down Expand Up @@ -42,6 +43,7 @@ export function TextLine({index, line}: TextLineProps) {
y={y}
fill={selectedTheme.xAxis.labelColor}
fontSize={FONT_SIZE}
fontFamily={FONT_FAMILY}
transform={transform}
>
{truncatedText}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {useTheme} from '@shopify/polaris-viz-core';
import {useTheme, FONT_FAMILY} from '@shopify/polaris-viz-core';

import type {Trend, TrendDirection} from '../../types';

Expand Down Expand Up @@ -70,7 +70,7 @@ export function TrendIndicator({
fill="currentColor"
fontWeight={FONT_WEIGHT}
dominantBaseline="middle"
fontFamily="-apple-system, BlinkMacSystemFont, 'San Francisco', 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif"
fontFamily={FONT_FAMILY}
textRendering="geometricPrecision"
width={textWidth}
>
Expand Down
3 changes: 3 additions & 0 deletions packages/polaris-viz/src/components/shared/Label/Label.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import {FONT_FAMILY} from '@shopify/polaris-viz-core';

import {HORIZONTAL_BAR_LABEL_HEIGHT, FONT_SIZE} from '../../../constants';

export interface LabelProps {
Expand All @@ -18,6 +20,7 @@ export function Label({barHeight, color, label, labelWidth, y}: LabelProps) {
aria-hidden="true"
y={y + labelYOffset}
fontSize={`${FONT_SIZE}px`}
fontFamily={FONT_FAMILY}
fill={color}
dominantBaseline="central"
>
Expand Down
12 changes: 6 additions & 6 deletions packages/polaris-viz/src/data/character-width-offsets.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@
"40": 3.12
},
"fontWeight": {
"100": 0.96,
"200": 0.97,
"100": 0.97,
"200": 0.98,
"300": 0.99,
"400": 1,
"450": 1.04,
"500": 1.04,
"450": 1.02,
"500": 1.03,
"600": 1.06,
"700": 1.09,
"800": 1.14,
"900": 1.19
"800": 1.13,
"900": 1.16
}
}
2 changes: 1 addition & 1 deletion packages/polaris-viz/src/data/character-widths.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ describe('estimateStringWidthWithOffset()', () => {
describe('fontWeight', () => {
it.each`
fontWeight | expected
${100} | ${63.43}
${100} | ${64.09}
${300} | ${65.41}
${600} | ${70.03}
${900} | ${78.62}
${900} | ${76.64}
`('returns width with $fontWeight offset', ({fontWeight, expected}) => {
const actual = estimateStringWidthWithOffset(
'Hello World',
Expand All @@ -43,10 +43,10 @@ describe('estimateStringWidthWithOffset()', () => {
describe('fontSize & fontWeight', () => {
it.each`
fontSize | fontWeight | expected
${4} | ${100} | ${22.83}
${4} | ${100} | ${23.07}
${10} | ${300} | ${55.6}
${16} | ${600} | ${91.04}
${20} | ${900} | ${125.01}
${20} | ${900} | ${121.86}
`(
'returns width with $fontWeight offset',
({fontSize, fontWeight, expected}) => {
Expand Down
2 changes: 1 addition & 1 deletion scripts/character-widths/build-character-offsets.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

<style>
body {
font-family: -apple-system, BlinkMacSystemFont, 'San Francisco',
font-family: Inter, -apple-system, 'system-ui', 'San Francisco',
'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
}
</style>
Expand Down
2 changes: 1 addition & 1 deletion scripts/character-widths/build-character-widths.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

<style>
body {
font-family: -apple-system, BlinkMacSystemFont, 'San Francisco',
font-family: Inter, -apple-system, 'system-ui', 'San Francisco',
'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
}
</style>
Expand Down
Loading