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

Add light-mobile theme with text overrides #11325

Closed
wants to merge 2 commits into from
Closed
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
5 changes: 5 additions & 0 deletions .changeset/shiny-moose-relate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@shopify/polaris-tokens': patch
---

POC to enable Inter variable `font-weight`s in React Native
15 changes: 11 additions & 4 deletions polaris-tokens/src/themes/base/font.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ export type FontLetterSpacingAlias = 'densest' | 'denser' | 'dense' | 'normal';
export type FontWeightPrefix = 'font-weight';
export type FontWeightAlias = 'regular' | 'medium' | 'semibold' | 'bold';

export const fontWeightAliasMap: {[F in FontWeightAlias]: `${number}`} = {
regular: '450',
medium: '550',
semibold: '650',
bold: '700',
};

export type FontPrefix =
| FontFamilyPrefix
| FontLetterSpacingPrefix
Expand Down Expand Up @@ -94,16 +101,16 @@ export const font: {
value: size[1000],
},
'font-weight-regular': {
value: '450',
value: fontWeightAliasMap.regular,
},
'font-weight-medium': {
value: '550',
value: fontWeightAliasMap.medium,
},
'font-weight-semibold': {
value: '650',
value: fontWeightAliasMap.semibold,
},
'font-weight-bold': {
value: '700',
value: fontWeightAliasMap.bold,
},
'font-letter-spacing-densest': {
value: '-0.54px',
Expand Down
1 change: 1 addition & 0 deletions polaris-tokens/src/themes/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ export const themeNameDefault = themeNameLight;

export const themeNames = [
themeNameLight,
'light-mobile',
'light-high-contrast-experimental',
] as const;
6 changes: 6 additions & 0 deletions polaris-tokens/src/themes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,22 @@ import {
metaThemeLightHighContrast,
metaThemeLightHighContrastPartial,
} from './light-high-contrast';
import {
metaThemeLightMobile,
metaThemeLightMobilePartial,
} from './light-mobile';

export {createMetaTheme} from './utils';

export const metaThemes: MetaThemes = {
light: metaThemeLight,
'light-mobile': metaThemeLightMobile,
'light-high-contrast-experimental': metaThemeLightHighContrast,
};

export const metaThemePartials: MetaThemePartials = {
light: metaThemeLightPartial,
'light-mobile': metaThemeLightMobilePartial,
'light-high-contrast-experimental': metaThemeLightHighContrastPartial,
};

Expand Down
46 changes: 46 additions & 0 deletions polaris-tokens/src/themes/light-mobile.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import type {FontWeightAlias} from './base/font';
import {fontWeightAliasMap} from './base/font';
import {createMetaTheme, createMetaThemePartial} from './utils';

export const metaThemeLightMobilePartial = createMetaThemePartial({
text: {
'text-heading-3xl-font-family': {
value: getWeightedFontFamily('bold'),
},
'text-heading-2xl-font-family': {
value: getWeightedFontFamily('bold'),
},
'text-heading-xl-font-family': {
value: getWeightedFontFamily('bold'),
},
'text-heading-lg-font-family': {
value: getWeightedFontFamily('semibold'),
},
'text-heading-md-font-family': {
value: getWeightedFontFamily('semibold'),
},
'text-heading-sm-font-family': {
value: getWeightedFontFamily('semibold'),
},
'text-body-lg-font-family': {
value: getWeightedFontFamily('regular'),
},
'text-body-md-font-family': {
value: getWeightedFontFamily('regular'),
},
'text-body-sm-font-family': {
value: getWeightedFontFamily('regular'),
},
'text-body-xs-font-family': {
value: getWeightedFontFamily('regular'),
},
},
});

export const metaThemeLightMobile = createMetaTheme(
metaThemeLightMobilePartial,
);

function getWeightedFontFamily(fontWeightAlias: FontWeightAlias) {
return `Inter-${fontWeightAliasMap[fontWeightAlias]}, -apple-system, BlinkMacSystemFont, 'San Francisco', 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif`;
}
Loading