Open eendkonijn opened 3 years ago
Does anyone have an idea what might be the happening here?
Still looking for support on this one
Did you create a manager-head.html
file and put the google font link inside it?
<link href="https://fonts.googleapis.com/css2?family=Roboto&display=swap" rel="stylesheet">
Thank you scottvincent, I will try but I have the fonts locally and load them in .storybook/storybook.scss:
@font-face {
font-family: "Ciutadella";
src: url("../assets/fonts/Ciutadella/35A006_0_0.woff2") format("woff2"),
url("../assets/fonts/Ciutadella/35A006_0_0.woff") format("woff");
font-weight: $font-weight-light;
font-style: normal;
}
@font-face {
font-family: "Ciutadella";
src: url("../assets/fonts/Ciutadella/35A006_2_0.woff2") format("woff2"),
url("../assets/fonts/Ciutadella/35A006_2_0.woff") format("woff");
font-weight: $font-weight-regular;
font-style: normal;
}
@font-face {
font-family: "Ciutadella";
src: url("../assets/fonts/Ciutadella/CiutadellaRounded-SmBd.woff2")
format("woff2"),
url("../assets/fonts/Ciutadella/CiutadellaRounded-SmBd.woff")
format("woff");
font-weight: $font-weight-semibold;
font-style: normal;
}
@font-face {
font-family: "Ciutadella";
src: url("../assets/fonts/Ciutadella/35A006_1_0.woff2") format("woff2"),
url("../assets/fonts/Ciutadella/35A006_1_0.woff") format("woff");
font-weight: $font-weight-bold;
font-style: normal;
}
@font-face {
font-family: "Roboto";
src: url("../assets/fonts/Roboto/roboto-v18-latin-300.woff2")
format("woff2"),
url("../assets/fonts/Roboto/roboto-v18-latin-300.woff") format("woff");
font-weight: $font-weight-light;
font-style: normal;
}
@font-face {
font-family: "Roboto";
src: url("../assets/fonts/Roboto/roboto-v18-latin-regular.woff2")
format("woff2"),
url("../assets/fonts/Roboto/roboto-v18-latin-regular.woff")
format("woff");
font-weight: $font-weight-regular;
font-style: normal;
}
@font-face {
font-family: "Roboto";
src: url("../assets/fonts/Roboto/roboto-v18-latin-500.woff2")
format("woff2"),
url("../assets/fonts/Roboto/roboto-v18-latin-500.woff") format("woff");
font-weight: $font-weight-medium;
font-style: normal;
}
Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!
I am on Storybook 6.2.1 and I am finding that the Storybook theming fontBase
property set to the 'Roboto'
font works in the left sidebar and the Canvas tab (including Controls panel content) and for the styling of the font of the Docs tab itself but it does not carry over to the content on the Docs page when using an MDX stories file. There, the crazy default values are in effect:
font-family: "Nunito Sans",-apple-system,".SFNSText-Regular","San Francisco",BlinkMacSystemFont,"Segoe UI","Helvetica Neue",Helvetica,Arial,sans-serif;
Seems like a bug with MDX.
FYI to @shilman and @jonniebigodes.
@KenACollins you've read this? https://storybook.js.org/docs/react/configure/theming#theming-docs
Hi @shilman ,
Ooooh!! Okay. Thank you for pointing this out. I did read that page, Mike, before posting my comment above, but obviously did not read it as carefully as I should have. I had the manager.js
file reference my custom theme file, but did not realize that I needed to make the change in two places, the preview.js
file too. It works! I have Roboto font everywhere now - sidebar, Canvas tab, Controls panel, Docs tab, and Docs MDX content. Okay, this issue no longer exists.
Hi @shilman ,
Ooooh!! Okay. Thank you for pointing this out. I did read that page, Mike, before posting my comment above, but obviously did not read it as carefully as I should have. I had the
manager.js
file reference my custom theme file, but did not realize that I needed to make the change in two places, thepreview.js
file too. It works! I have Roboto font everywhere now - sidebar, Canvas tab, Controls panel, Docs tab, and Docs MDX content. Okay, this issue no longer exists.
How did you change the font-family on the Docs tab? My MDX is always getting the default font-family from Storybook 🤔
Hi Victor (@vctormb),
Sorry for the delay, I have been swamped at work so my only recourse was to log in a Saturday.
You configure your Storybook environment through a half dozen files that you create in the .storybook folder located in the root of your project. See screenshot below of the folder structure.
Some of these files may be created for you initially, but there is still configuration you will need to perform.
To answer your question, altering the font for both the Canvas and Docs tabs requires configuration in the preview-head.html file. Here is what mine looks like:
<!-- preview-head.html: Overrides content of preview IFRAME HTML page's <head> tag, affecting rendered component(s) below Canvas and Docs tabs. -->
<!-- Link tag that points to Roboto font resolves to src/assets/fonts/ folder based on start command defined with '-s src/assets' parameter in package.json. -->
<link rel="stylesheet" href="fonts/Roboto/Roboto.css">
<style>
body {
font-family: Roboto, sans-serif;
}
</style>
Hope this helps. Let me know if you get stuck.
@KenACollins Thanks this works for me
Hi @KenACollins, Thanks! it's helpful!
Hello, I am trying to customize the Storybook UI. Customization works, but my custom font won't seem to load. Am I forgetting something? I don't have a reproducible repo, but I followed the steps on this page. This is how my theming file looks:
storybookCustomTheme.js
:import { create } from "@storybook/theming/create"; import logo from "../assets/images/storybook-icon.png";
export default create({ base: "light", colorPrimary: " #aa418c", colorSecondary: "#00526e",
});`
As you can see it falls back to Helvetica:
Versions: