Skip to content

Commit

Permalink
Import fonts from assets package instead of local
Browse files Browse the repository at this point in the history
  • Loading branch information
narin committed Jan 5, 2024
1 parent 22801c0 commit 4d58520
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
17 changes: 17 additions & 0 deletions packages/components/.storybook/web/main.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
const path = require('path')
const CopyPlugin = require('copy-webpack-plugin')

module.exports = {
stories: [
'../../src/components/**/*.stories.mdx',
Expand All @@ -15,4 +18,18 @@ module.exports = {
},
framework: '@storybook/react',
staticDirs: ['../../src/assets'],
webpackFinal: async (config) => {
config.plugins.push(
new CopyPlugin({
patterns: [
{
from: '../../node_modules/@department-of-veterans-affairs/mobile-assets/fonts',
to: 'fonts',
},
],
}),
)

return config
},
}
4 changes: 2 additions & 2 deletions packages/components/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ export const webStorybookColorScheme = () => {
const App = () => {
// Loads in custom fonts async
const [fontsLoaded, fontError] = useFonts({
'SourceSansPro-Bold': require('@department-of-veterans-affairs/va-mobile-assets/fonts/SourceSansPro/SourceSansPro-Bold.ttf'),
'SourceSansPro-Regular': require('@department-of-veterans-affairs/va-mobile-assets/fonts/SourceSansPro/SourceSansPro-Regular.ttf'),
'SourceSansPro-Bold': require('@department-of-veterans-affairs/mobile-assets/fonts/SourceSansPro/SourceSansPro-Bold.ttf'),
'SourceSansPro-Regular': require('@department-of-veterans-affairs/mobile-assets/fonts/SourceSansPro/SourceSansPro-Regular.ttf'),
})

// Holds rendering until custom fonts load
Expand Down

0 comments on commit 4d58520

Please sign in to comment.