Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Storybook] Update styles to be more accurate to prod #1945

Merged
merged 8 commits into from
Dec 5, 2024
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
5 changes: 5 additions & 0 deletions .changeset/shiny-sloths-obey.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@khanacademy/perseus": patch
---

Add global styles to reflect prod styling
12 changes: 11 additions & 1 deletion .storybook/preview.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as React from "react";

Check warning on line 1 in .storybook/preview.tsx

View workflow job for this annotation

GitHub Actions / Lint, Typecheck, Format, and Test (ubuntu-latest, 20.x)

File ignored by default.
import {color} from "@khanacademy/wonder-blocks-tokens";
import {RenderStateRoot} from "@khanacademy/wonder-blocks-core";
import {Dependencies} from "@khanacademy/perseus";
Expand All @@ -23,7 +23,17 @@
(Story) => (
<RenderStateRoot>
<DependenciesContext.Provider value={storybookDependenciesV2}>
<Story />
{/* Most of our components have an expectation to be
rendered inside of a .framework-perseus container.
We want to make sure we can include it here, since it
can also affect the styling.

Inclue box-sizing-border-box-reset to reflect
the global styles from prod.
*/}
<div className="framework-perseus box-sizing-border-box-reset">
<Story />
</div>
</DependenciesContext.Provider>
</RenderStateRoot>
),
Expand Down
42 changes: 42 additions & 0 deletions packages/perseus/src/styles/global.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/**
* This file contains styles that are used in prod that ultimately
* get passed onto Perseus components. This file is imported in the
* .storybook/preview.js file so that the components can have the same
* styles as prod when viewed within Storybook.
*/

// Variables
@offBlack: #21242c;
@wonderBlocksFontFamily: "Lato", "Noto Sans", "Helvetica", "Corbel", sans-serif;

// Layers
@layer reset, shared, legacy;

@layer reset {
// A CSS reset. Needed for every page.
@import (inline) "./reset.css";
}

@layer shared {
html,
body {
height: 100%;
}

body {
font-family: @wonderBlocksFontFamily, "Helvetica", "Corbel", sans-serif;
font-size: 14px;
margin: 0;
color: @offBlack;
line-height: 1.4;
min-width: 0;
}

.box-sizing-border-box-reset {
box-sizing: border-box;
}

.box-sizing-border-box-reset * {
box-sizing: inherit;
}
}
1 change: 1 addition & 0 deletions packages/perseus/src/styles/perseus-renderer.less
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

@import "./variables.less";
@import "./util.less";
@import "./global.less";

@import "./styles.less";

Expand Down
131 changes: 131 additions & 0 deletions packages/perseus/src/styles/reset.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
/* http://meyerweb.com/eric/tools/css/reset/
v2.0 | 20110126
License: none (public domain)
*/

html,
body,
div,
span,
applet,
object,
iframe,
h1,
h2,
h3,
h4,
h5,
h6,
p,
blockquote,
pre,
a,
abbr,
acronym,
address,
big,
cite,
code,
del,
dfn,
em,
img,
ins,
kbd,
q,
s,
samp,
small,
strike,
strong,
sub,
sup,
tt,
var,
b,
u,
i,
center,
dl,
dt,
dd,
ol,
ul,
li,
fieldset,
form,
label,
legend,
table,
caption,
tbody,
tfoot,
thead,
tr,
th,
td,
article,
aside,
canvas,
details,
embed,
figure,
figcaption,
footer,
header,
hgroup,
menu,
nav,
output,
ruby,
section,
summary,
time,
mark,
audio,
video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article,
aside,
details,
figcaption,
figure,
footer,
header,
hgroup,
menu,
nav,
section {
display: block;
}
body {
line-height: 1;
}
ol,
ul {
list-style: none;
}
blockquote,
q {
quotes: none;
}
blockquote:before,
blockquote:after,
q:before,
q:after {
content: "";
content: none;
}
table {
border-collapse: collapse;
border-spacing: 0;
}

/* End Reset */
Loading