Skip to content

Commit

Permalink
storybook styles (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
nishanths authored May 2, 2020
1 parent 3b5d467 commit d928eca
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 22 deletions.
9 changes: 9 additions & 0 deletions web/.storybook/base.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// base styles

@import '../scss/vars.scss';
@import '../static/font/font.css';

body {
font-family: $font-family;
margin: $body-margin-w;
}
8 changes: 3 additions & 5 deletions web/.storybook/config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { configure } from '@storybook/react'

const req = require.context('../components', true, /.stories.tsx$/)

const loadStories = () => {
req.keys().forEach(req)
}
import '!style-loader!css-loader!sass-loader!./base.scss';

const req = require.context('../components', true, /.stories.tsx$/)
const loadStories = () => { req.keys().forEach(req) }
configure(loadStories, module)
25 changes: 17 additions & 8 deletions web/.storybook/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,23 @@ module.exports = ({ config }) => {
config.module.rules.push({
test: /\.(ts|tsx)$/,
include: [srcPath],
use: [
{
loader: require.resolve('awesome-typescript-loader'),
options: {
configFileName: './.storybook/tsconfig.json',
}
},
]
use: [
{
loader: require.resolve('awesome-typescript-loader'),
options: {
configFileName: './.storybook/tsconfig.json',
}
},
]
});
config.module.rules.push({
test: /\.scss$/,
use: [
// creates style nodes from JS strings
{ loader: "style-loader" },
{ loader: "css-loader", options: { sourceMap: true }}, // translates CSS into CommonJS
{ loader: "sass-loader", options: { sourceMap: true }} // compiles Sass to CSS
]
});
config.resolve.extensions.push('.ts', '.tsx');
return config;
Expand Down
3 changes: 2 additions & 1 deletion web/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ fmt:

.PHONY: sb
sb:
npm run storybook
npx start-storybook -p 9001 -c .storybook \
-s static # https://storybook.js.org/docs/configurations/serving-static-files/
3 changes: 1 addition & 2 deletions web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
"version": "1.0.0",
"description": "",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"storybook": "start-storybook -p 9001 -c .storybook"
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"dependencies": {
Expand Down
12 changes: 6 additions & 6 deletions web/static/font/font.css
Original file line number Diff line number Diff line change
Expand Up @@ -30,38 +30,38 @@
@font-face {
font-family: cooper-hewitt;
font-weight: 400;
src: url("/static/font/cooper-hewitt/CooperHewitt-Book.otf") format("opentype");
src: url("cooper-hewitt/CooperHewitt-Book.otf") format("opentype");
}

@font-face {
font-family: cooper-hewitt;
font-weight: 500;
src: url("/static/font/cooper-hewitt/CooperHewitt-Medium.otf") format("opentype");
src: url("cooper-hewitt/CooperHewitt-Medium.otf") format("opentype");
}

@font-face {
font-family: cooper-hewitt;
font-weight: 600;
src: url("/static/font/cooper-hewitt/CooperHewitt-Semibold.otf") format("opentype");
src: url("cooper-hewitt/CooperHewitt-Semibold.otf") format("opentype");
}

@font-face {
font-family: cooper-hewitt;
font-weight: 700;
src: url("/static/font/cooper-hewitt/CooperHewitt-Bold.otf") format("opentype");
src: url("cooper-hewitt/CooperHewitt-Bold.otf") format("opentype");
}


@font-face {
font-family: 'proxima-nova';
font-weight: normal;
font-style: normal;
src: url("/static/font/proxima-nova/2F00B2_0_0.woff2") format("woff2"), url("/static/font/proxima-nova/2F00B2_0_0.woff") format("woff"), url("/static/font/proxima-nova/2F00B2_0_0.ttf") format("truetype");
src: url("proxima-nova/2F00B2_0_0.woff2") format("woff2"), url("proxima-nova/2F00B2_0_0.woff") format("woff"), url("proxima-nova/2F00B2_0_0.ttf") format("truetype");
}

@font-face {
font-family: 'proxima-nova';
font-weight: bold;
font-style: normal;
src: url("/static/font/proxima-nova/2F00B2_1_0.woff2") format("woff2"), url("/static/font/proxima-nova/2F00B2_1_0.woff") format("woff"), url("/static/font/proxima-nova/2F00B2_1_0.ttf") format("truetype");
src: url("proxima-nova/2F00B2_1_0.woff2") format("woff2"), url("proxima-nova/2F00B2_1_0.woff") format("woff"), url("proxima-nova/2F00B2_1_0.ttf") format("truetype");
}

0 comments on commit d928eca

Please sign in to comment.