mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-09 00:19:13 +08:00
add the font for the storybook manager UI, add a reference to it in the template
Co-authored-by: Valentin Palkovic <valentin@chromatic.com>
This commit is contained in:
parent
768d4324f9
commit
ea6dffba23
@ -12,6 +12,10 @@
|
|||||||
<link rel="icon" type="image/x-icon" href="./<%= favicon %>">
|
<link rel="icon" type="image/x-icon" href="./<%= favicon %>">
|
||||||
<% } %>
|
<% } %>
|
||||||
|
|
||||||
|
<link rel="preload" href="./sb-manager-assets/nunitosans-regular.woff2" as="font" type="font/woff2" crossorigin>
|
||||||
|
<link rel="preload" href="./sb-manager-assets/nunitosans-black.woff2" as="font" type="font/woff2" crossorigin>
|
||||||
|
<link rel="stylesheet" href="./sb-manager-assets/fonts.css" />
|
||||||
|
|
||||||
<% if (typeof head !== 'undefined') { %> <%- head %> <% } %>
|
<% if (typeof head !== 'undefined') { %> <%- head %> <% } %>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
@ -13,14 +13,23 @@ import type {
|
|||||||
CoreConfig,
|
CoreConfig,
|
||||||
Options,
|
Options,
|
||||||
StorybookConfig,
|
StorybookConfig,
|
||||||
|
PresetPropertyFn,
|
||||||
} from '@storybook/types';
|
} from '@storybook/types';
|
||||||
import { loadCsf } from '@storybook/csf-tools';
|
import { loadCsf } from '@storybook/csf-tools';
|
||||||
import { join } from 'path';
|
import { dirname, join } from 'path';
|
||||||
import { dedent } from 'ts-dedent';
|
import { dedent } from 'ts-dedent';
|
||||||
import { parseStaticDir } from '../utils/server-statics';
|
import { parseStaticDir } from '../utils/server-statics';
|
||||||
|
|
||||||
const defaultFavicon = require.resolve('@storybook/core-server/public/favicon.svg');
|
const defaultFavicon = require.resolve('@storybook/core-server/public/favicon.svg');
|
||||||
|
|
||||||
|
export const staticDirs: PresetPropertyFn<'staticDirs'> = async (values = []) => [
|
||||||
|
{
|
||||||
|
from: join(dirname(require.resolve('@storybook/manager/package.json')), 'static'),
|
||||||
|
to: '/sb-manager-assets',
|
||||||
|
},
|
||||||
|
...values,
|
||||||
|
];
|
||||||
|
|
||||||
export const favicon = async (
|
export const favicon = async (
|
||||||
value: string,
|
value: string,
|
||||||
options: Pick<Options, 'presets' | 'configDir' | 'staticDir'>
|
options: Pick<Options, 'presets' | 'configDir' | 'staticDir'>
|
||||||
@ -28,17 +37,17 @@ export const favicon = async (
|
|||||||
if (value) {
|
if (value) {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
const staticDirs = await options.presets.apply<StorybookConfig['staticDirs']>('staticDirs');
|
const staticDirsValue = await options.presets.apply<StorybookConfig['staticDirs']>('staticDirs');
|
||||||
|
|
||||||
const statics = staticDirs
|
const statics = staticDirsValue
|
||||||
? staticDirs.map((dir) => (typeof dir === 'string' ? dir : `${dir.from}:${dir.to}`))
|
? staticDirsValue.map((dir) => (typeof dir === 'string' ? dir : `${dir.from}:${dir.to}`))
|
||||||
: options.staticDir;
|
: options.staticDir;
|
||||||
|
|
||||||
if (statics && statics.length > 0) {
|
if (statics && statics.length > 0) {
|
||||||
const lists = await Promise.all(
|
const lists = await Promise.all(
|
||||||
statics.map(async (dir) => {
|
statics.map(async (dir) => {
|
||||||
const results = [];
|
const results = [];
|
||||||
const relativeDir = staticDirs
|
const relativeDir = staticDirsValue
|
||||||
? getDirectoryFromWorkingDir({
|
? getDirectoryFromWorkingDir({
|
||||||
configDir: options.configDir,
|
configDir: options.configDir,
|
||||||
workingDir: process.cwd(),
|
workingDir: process.cwd(),
|
||||||
|
@ -44,6 +44,7 @@
|
|||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
"files": [
|
"files": [
|
||||||
"dist/**/*",
|
"dist/**/*",
|
||||||
|
"static/**/*",
|
||||||
"README.md",
|
"README.md",
|
||||||
"*.js",
|
"*.js",
|
||||||
"*.d.ts"
|
"*.d.ts"
|
||||||
|
15
code/ui/manager/static/fonts.css
Normal file
15
code/ui/manager/static/fonts.css
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
@font-face {
|
||||||
|
font-family: 'Nunito Sans';
|
||||||
|
font-style: normal;
|
||||||
|
font-weight: 400;
|
||||||
|
font-display: swap;
|
||||||
|
src: url('./nunitosans-regular.woff2') format('woff2');
|
||||||
|
}
|
||||||
|
|
||||||
|
@font-face {
|
||||||
|
font-family: 'Nunito Sans';
|
||||||
|
font-style: normal;
|
||||||
|
font-weight: 900;
|
||||||
|
font-display: swap;
|
||||||
|
src: url('./nunitosans-black.woff2') format('woff2');
|
||||||
|
}
|
BIN
code/ui/manager/static/nunitosans-black.woff2
Normal file
BIN
code/ui/manager/static/nunitosans-black.woff2
Normal file
Binary file not shown.
BIN
code/ui/manager/static/nunitosans-regular.woff2
Normal file
BIN
code/ui/manager/static/nunitosans-regular.woff2
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user