Skip to content

Commit

Permalink
Merge branch 'next' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
jonniebigodes authored Oct 2, 2023
2 parents 855d053 + e2aa53e commit 8570d0d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export async function getFontFaceDeclarations(options: LoaderOptions, rootContex
const localFontSrc = options.props.src as LocalFontSrc;

// Parent folder relative to the root context
const parentFolder = options.filename.split('/').slice(0, -1).join('/').replace(rootContext, '');
const parentFolder = path.dirname(options.filename).replace(rootContext, '');

const { validateData } = require('../utils/local-font-utils');
const { weight, style, variable } = validateData('', options.props);
Expand All @@ -23,9 +23,13 @@ export async function getFontFaceDeclarations(options: LoaderOptions, rootContex
6
)}`;

const arePathsWin32Format = /^[a-z]:\\/iu.test(options.filename);
const cleanWin32Path = (pathString: string): string =>
arePathsWin32Format ? pathString.replace(/\\/gu, '/') : pathString;

const getFontFaceCSS = () => {
if (typeof localFontSrc === 'string') {
const localFontPath = path.join(parentFolder, localFontSrc);
const localFontPath = cleanWin32Path(path.join(parentFolder, localFontSrc));

return `@font-face {
font-family: ${id};
Expand All @@ -34,7 +38,7 @@ export async function getFontFaceDeclarations(options: LoaderOptions, rootContex
}
return localFontSrc
.map((font) => {
const localFontPath = path.join(parentFolder, font.path);
const localFontPath = cleanWin32Path(path.join(parentFolder, font.path));

return `@font-face {
font-family: ${id};
Expand Down
2 changes: 2 additions & 0 deletions docs/configure/theming.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
title: 'Theming'
---

<YouTubeCallout id="x2nGXHAKOrE" title="Storybook Theming" />

Storybook is theme-able using a lightweight theming API.

## Global theming
Expand Down

0 comments on commit 8570d0d

Please sign in to comment.