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 #95

Merged
merged 6 commits into from
Nov 11, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
14 changes: 14 additions & 0 deletions template/packages/frontend/.storybook/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module.exports = {
typescript: {
check: false,
checkOptions: {},
reactDocgen: "react-docgen-typescript",
reactDocgenTypescriptOptions: {
shouldExtractLiteralValuesFromEnum: true,
propFilter: prop =>
prop.parent ? !/node_modules/.test(prop.parent.fileName) : true,
},
},
addons: ["storybook-css-modules-preset"],
stories: ["../stories/*.stories.@(ts|tsx)"],
xasopheno marked this conversation as resolved.
Show resolved Hide resolved
}
16 changes: 16 additions & 0 deletions template/packages/frontend/components/Title.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import * as React from "react"
import styles from "./title.module.css"

type Props = {
text: string
}

const Title = ({ text }: Props) => {
return (
<div>
<h2 className={styles.title}>{text}</h2>
</div>
)
}
xasopheno marked this conversation as resolved.
Show resolved Hide resolved

export default Title
9 changes: 9 additions & 0 deletions template/packages/frontend/components/title.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.title {
color: blue;
font-weight: bold;
font-size: 30px;
}

.title:hover {
color: red;
}
10 changes: 9 additions & 1 deletion template/packages/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"codegen:watch": "nodemon --ext ts,tsx --exec yarn codegen --ignore '/__generated__/'",
"typecheck": "echo next && tsc -p .",
"typecheck:watch": "yarn typecheck --watch",
"lint": "eslint --cache --ext .ts,.tsx --ignore-pattern __generated__ ."
"lint": "eslint --cache --ext .ts,.tsx --ignore-pattern __generated__ .",
"storybook": "start-storybook -p 6006 -c .storybook"
},
"dependencies": {
"@apollo/client": "^3.2.5",
Expand All @@ -23,12 +24,19 @@
"react-dom": "16.13.1"
},
"devDependencies": {
"@babel/core": "^7.12.3",
"@hallettj/eslint-plugin-ts-graphql": "^0.1.1",
"@storybook/addon-docs": "^6.0.28",
"@storybook/react": "^6.0.28",
"@types/node": "^14.14.6",
"@types/react": "^16.9.55",
"@types/react-dom": "^16.9.9",
"@types/storybook__react": "^5.2.1",
"babel-loader": "^8.2.0",
"babel-preset-react-app": "^10.0.0",
Comment on lines +35 to +36
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit bothered by adding these babel dependencies if we don't directly reference them. Are they necessary? This applies to @babel/core too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems that babel is required for storybook.
storybookjs/storybook#7156

"concurrently": "^5.3.0",
"eslint-plugin-graphql": "^4.0.0",
"storybook-css-modules-preset": "^1.0.2",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be dropped if we opt for another css framework.

"ts-graphql-plugin": "^2.0.2"
}
}
3 changes: 2 additions & 1 deletion template/packages/frontend/pages/recipes/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { gql, useQuery, useMutation } from "@apollo/client"
import Link from "next/link"
import Title from "components/Title"

const getRecipesQuery = gql`
query getRecipes {
Expand Down Expand Up @@ -56,7 +57,7 @@ export default function RecipesList() {
}
return (
<div>
<h1>Recipes</h1>
<Title text={"Recipes"} />
{loading ? "Loading..." : null}
{data
? data.recipes.map(recipe => <Recipe {...recipe} key={recipe.id} />)
Expand Down
19 changes: 19 additions & 0 deletions template/packages/frontend/pages/recipes/recipes.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.inputText {
padding: 0.3rem;
font-size: 20px;
}

.submitButton {
background-color: #6db9ee; /* Green */
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
}

.submitButton:hover {
background-color: #2f79ad;
}
7 changes: 7 additions & 0 deletions template/packages/frontend/stories/Title.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import * as React from "react"
import { storiesOf } from "@storybook/react"
import Title from "../components/Title"

storiesOf("Title", module).add("with text", () => {
return <Title text={"My Title"} />
})
Loading