Skip to content

Commit

Permalink
feat: provide full font characters set as alternative (#2573)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeripeierSBB authored Apr 11, 2024
1 parent 3d4c8ab commit 4047883
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/components/core/styles/core/font-face.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,29 @@
font-display: swap;
}
}

@mixin font-declarations-full {
@font-face {
font-family: 'SBBWeb Roman';
src:
url('https://cdn.app.sbb.ch/fonts/v1/SBBWeb-Roman.woff2') format('woff2'),
url('https://cdn.app.sbb.ch/fonts/v1/SBBWeb-Roman.woff') format('woff');
font-display: fallback;
}

@font-face {
font-family: 'SBBWeb Bold';
src:
url('https://cdn.app.sbb.ch/fonts/v1/SBBWeb-Bold.woff2') format('woff2'),
url('https://cdn.app.sbb.ch/fonts/v1/SBBWeb-Bold.woff') format('woff');
font-display: swap;
}

@font-face {
font-family: 'SBBWeb Light';
src:
url('https://cdn.app.sbb.ch/fonts/v1/SBBWeb-Light.woff2') format('woff2'),
url('https://cdn.app.sbb.ch/fonts/v1/SBBWeb-Light.woff') format('woff');
font-display: swap;
}
}
3 changes: 3 additions & 0 deletions src/components/core/styles/fullfont.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@use './core/font-face';

@include font-face.font-declarations-full;
3 changes: 3 additions & 0 deletions src/components/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ export default defineConfig((config) =>
'./typography.css': {
style: './typography.css',
},
'./fullfont.css': {
style: './fullfont.css',
},
},
}),
copyAssets(['_index.scss', '../../README.md']),
Expand Down
9 changes: 9 additions & 0 deletions tools/vite/typography.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ export function typography(): PluginOption {
fileName: 'typography.css',
source: globalCss.css,
});

const fullFont = sass.compile(join(viteConfig.root, 'core/styles/fullfont.scss'), {
loadPaths: [root.pathname, join(root.pathname, '/node_modules/')],
});
this.emitFile({
type: 'asset',
fileName: 'fullfont.css',
source: fullFont.css,
});
},
};
}

0 comments on commit 4047883

Please sign in to comment.