Skip to content
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
1 change: 0 additions & 1 deletion code/frameworks/nextjs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,6 @@ The following features are not supported (yet). Support for these features might
- [Support font loaders configuration in next.config.js](https://nextjs.org/docs/basic-features/font-optimization#specifying-a-subset)
- [fallback](https://nextjs.org/docs/api-reference/next/font#fallback) option
- [adjustFontFallback](https://nextjs.org/docs/api-reference/next/font#adjustfontfallback) option
- [declarations](https://nextjs.org/docs/api-reference/next/font#declarations) option
- [preload](https://nextjs.org/docs/api-reference/next/font#preload) option gets ignored. Storybook handles Font loading its own way.
- [display](https://nextjs.org/docs/api-reference/next/font#display) option gets ignored. All fonts are loaded with display set to "block" to make Storybook load the font properly.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export async function getFontFaceDeclarations(
: path.dirname(options.filename).replace(rootContext, '');

const { validateData } = require('../utils/local-font-utils');
const { weight, style, variable } = validateData('', options.props);
const { weight, style, variable, declarations = [] } = validateData('', options.props);

const id = `font-${loaderUtils.getHashDigest(
Buffer.from(JSON.stringify(localFontSrc)),
Expand All @@ -30,6 +30,10 @@ export async function getFontFaceDeclarations(
6
)}`;

const fontDeclarations = declarations
.map(({ prop, value }: { prop: string; value: string }) => `${prop}: ${value};`)
.join('\n');

const arePathsWin32Format = /^[a-z]:\\/iu.test(options.filename);
const cleanWin32Path = (pathString: string): string =>
arePathsWin32Format ? pathString.replace(/\\/gu, '/') : pathString;
Expand All @@ -41,6 +45,7 @@ export async function getFontFaceDeclarations(
return `@font-face {
font-family: ${id};
src: url(.${localFontPath});
${fontDeclarations}
}`;
}
return localFontSrc
Expand All @@ -52,6 +57,7 @@ export async function getFontFaceDeclarations(
src: url(.${localFontPath});
${font.weight ? `font-weight: ${font.weight};` : ''}
${font.style ? `font-style: ${font.style};` : ''}
${fontDeclarations}
}`;
})
.join('');
Expand Down