Skip to content

Commit a6f1f13

Browse files
committed
chore: add gatsby template site layout
1 parent a4dc661 commit a6f1f13

35 files changed

+680
-250
lines changed

core/webpack-compile/src/index.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { CompileProps, CompileResults, WatchProps } from './types';
22
import { runCompiler } from './utilities';
33
export * from './types';
4-
54
/**
65
* compile the stories with webpack
76
* returns the stories store object

examples/gatsby/.config/main.js

-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
module.exports = {
22
stories: [
3-
'../../../ui/editors/src/**/*.stories.(js|tsx|mdx)',
4-
'../../../ui/components/src/**/*.stories.(js|tsx|mdx)',
5-
'../../../ui/blocks/src/**/*.stories.(js|tsx|mdx)',
6-
'../../../core/specification/src/stories/**/*.stories.(js|tsx|mdx)',
7-
'../../../plugins/axe-plugin/src/stories/**/*.stories.(js|tsx|mdx)',
83
'../../stories/src/**/*.stories.(js|tsx|mdx)',
94
],
105
};

examples/gatsby/gatsby-config.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
module.exports = {
22
siteMetadata: {
3-
title: 'Component Controls Gatsby Starter',
3+
siteTitle: 'Component Controls Gatsby Starter',
44
author: 'Atanas Stoyanov',
55
description: 'A sample site to showcase gatsby stories loading.',
66
siteUrl: 'https://components-storybook-6-no-docs.netlify.app',
77
},
88
plugins: [
9-
'gatsby-plugin-typescript',
10-
'gatsby-plugin-emotion',
119
{
12-
resolve: '@component-controls/gatsby-plugin-stories',
10+
resolve: '@component-controls/gatsby-theme-stories',
1311
options: {
14-
config: '.config',
12+
configPath: '.config',
1513
},
1614
},
1715
],

examples/gatsby/gatsby-node.js

-26
This file was deleted.

examples/gatsby/package.json

+2-4
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,8 @@
1414
"directory": "examples/gatsby"
1515
},
1616
"dependencies": {
17-
"@component-controls/gatsby-plugin-stories": "^1.1.0",
18-
"gatsby": "^2.22.9",
19-
"gatsby-plugin-emotion": "^4.3.2",
20-
"gatsby-plugin-typescript": "^2.4.3",
17+
"@component-controls/gatsby-theme-stories": "^1.1.0",
18+
"gatsby": "^2.22.10",
2119
"react": "^16.13.1",
2220
"react-dom": "^16.13.1"
2321
},

examples/gatsby/src/pages/index.tsx

-6
This file was deleted.

integrations/gatsby-plugin-stories/src/gatsby-node.ts

-18
This file was deleted.

integrations/gatsby-plugin-stories/src/types.ts

-12
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
module.exports = {
2+
siteMetadata: {
3+
siteTitle: `GraphQL Playground`,
4+
siteTitleAlt: `GraphQL Playground - @lekoarts/gatsby-theme-graphql-playground`,
5+
siteHeadline: `GraphQL Playground - Gatsby Theme from @lekoarts`,
6+
siteUrl: `https://gatsby-theme-graphql-playground.netlify.com`,
7+
siteDescription: `GraphQL Playground to showcase the power of GraphQL. Write your queries and documentation with MDX and display queries in an interactive GraphiQL window. It can source from your localhost or a remote URL (e.g. Codesandbox).`,
8+
siteLanguage: `en`,
9+
siteImage: `/banner.jpg`,
10+
author: `@lekoarts_de`,
11+
graphiQLUrl: `https://711808k40x.sse.codesandbox.io/___graphql`,
12+
basePath: options.basePath,
13+
docsPath: options.docsPath,
14+
},
15+
16+
plugins: [
17+
'gatsby-plugin-react-helmet',
18+
'gatsby-plugin-theme-ui',
19+
'gatsby-plugin-typescript',
20+
],
21+
};

integrations/gatsby-plugin-stories/package.json renamed to integrations/gatsby-theme-stories/package.json

+23-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"name": "@component-controls/gatsby-plugin-stories",
2+
"name": "@component-controls/gatsby-theme-stories",
33
"version": "1.1.0",
4-
"description": "Gatsby plugin to collect story files",
4+
"description": "Gatsby theme to create stories documentation sites",
55
"keywords": [
66
"story",
77
"gatsby"
@@ -12,7 +12,9 @@
1212
"files": [
1313
"dist/",
1414
"package.json",
15-
"README.md"
15+
"README.md",
16+
"gatsby-config.js",
17+
"gatsby-node.js"
1618
],
1719
"scripts": {
1820
"build": "yarn cross-env NODE_ENV=production rollup -c",
@@ -30,17 +32,33 @@
3032
"repository": {
3133
"type": "git",
3234
"url": "https://github.com/ccontrols/component-controls.git",
33-
"directory": "integrations/gatsby-source-stories"
35+
"directory": "integrations/gatsby-theme-stories"
3436
},
3537
"license": "MIT",
3638
"dependencies": {
39+
"@component-controls/components": "^1.1.0",
40+
"@component-controls/blocks": "^1.1.0",
3741
"@component-controls/loader": "^1.1.0",
42+
"@component-controls/pages": "^1.1.0",
43+
"@component-controls/specification": "^1.1.0",
3844
"@component-controls/store": "^1.1.0",
39-
"@component-controls/webpack-configs": "^1.1.0"
45+
"@component-controls/webpack-compile": "^1.1.0",
46+
"gatsby": "^2.22.10",
47+
"gatsby-plugin-react-helmet": "^3.3.2",
48+
"gatsby-plugin-theme-ui": "^0.3.0",
49+
"gatsby-plugin-typescript": "^2.4.3",
50+
"theme-ui": "^0.3.1",
51+
"@theme-ui/sidenav": "^0.3.1",
52+
"react": "^16.13.1",
53+
"react-helmet": "^6.0.0"
4054
},
4155
"devDependencies": {
4256
"typescript": "^3.8.3"
4357
},
58+
"peerDependencies": {
59+
"gatsby": "^2.22.10",
60+
"react": "^16.13.1"
61+
},
4462
"publishConfig": {
4563
"access": "public"
4664
},
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
/** @jsx jsx */
2+
import { jsx } from 'theme-ui';
3+
4+
interface Props {
5+
isDark: boolean;
6+
toggle: (e: any) => void;
7+
}
8+
9+
// Adapted from: https://codepen.io/aaroniker/pen/KGpXZo and https://github.com/narative/gatsby-theme-novela/blob/714b6209c5bd61b220370e8a7ad84c0b1407946a/%40narative/gatsby-theme-novela/src/components/Navigation/Navigation.Header.tsx
10+
11+
export const ColorMode = ({ isDark, toggle }: Props) => (
12+
<button
13+
onClick={toggle}
14+
type="button"
15+
aria-label={isDark ? `Activate Light Mode` : `Activate Dark Mode`}
16+
title={isDark ? `Activate Light Mode` : `Activate Dark Mode`}
17+
sx={{
18+
opacity: 0.65,
19+
position: `relative`,
20+
borderRadius: `5px`,
21+
width: `40px`,
22+
height: `25px`,
23+
display: `flex`,
24+
alignItems: `center`,
25+
justifyContent: `center`,
26+
transition: `opacity 0.3s ease`,
27+
border: `none`,
28+
outline: `none`,
29+
background: `none`,
30+
cursor: `pointer`,
31+
padding: 0,
32+
appearance: `none`,
33+
'&:hover, &:focus': { opacity: 1 },
34+
}}
35+
>
36+
<div
37+
sx={{
38+
position: `relative`,
39+
width: `24px`,
40+
height: `24px`,
41+
borderRadius: `50%`,
42+
border: t => (isDark ? `4px solid ${t.colors.toggleIcon}` : `none`),
43+
backgroundColor: isDark ? `toggleIcon` : `transparent`,
44+
transform: isDark ? `scale(0.55)` : `scale(1)`,
45+
transition: `all 0.45s ease`,
46+
overflow: isDark ? `visible` : `hidden`,
47+
boxShadow: t =>
48+
isDark ? `none` : `inset 8px -8px 0px 0px ${t.colors.toggleIcon}`,
49+
'&:before': {
50+
content: `""`,
51+
position: `absolute`,
52+
right: `-9px`,
53+
top: `-9px`,
54+
height: `24px`,
55+
width: `24px`,
56+
border: t => (isDark ? `2px solid ${t.colors.toggleIcon}` : `none`),
57+
borderRadius: `50%`,
58+
transform: isDark ? `translate(14px, -14px)` : `translate(0, 0)`,
59+
opacity: isDark ? 0 : 1,
60+
transition: `transform 0.45s ease`,
61+
},
62+
'&:after': {
63+
content: `""`,
64+
width: `8px`,
65+
height: `8px`,
66+
borderRadius: `50%`,
67+
margin: `-4px 0 0 -4px`,
68+
position: `absolute`,
69+
top: `50%`,
70+
left: `50%`,
71+
boxShadow: t =>
72+
`0 -23px 0 ${t.colors.toggleIcon}, 0 23px 0 ${t.colors.toggleIcon}, 23px 0 0 ${t.colors.toggleIcon}, -23px 0 0 ${t.colors.toggleIcon}, 15px 15px 0 ${t.colors.toggleIcon}, -15px 15px 0 ${t.colors.toggleIcon}, 15px -15px 0 ${t.colors.toggleIcon}, -15px -15px 0 ${t.colors.toggleIcon}`,
73+
transform: isDark ? `scale(1)` : `scale(0)`,
74+
transition: `all 0.35s ease`,
75+
},
76+
}}
77+
/>
78+
</button>
79+
);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/** @jsx jsx */
2+
import { FC } from 'react';
3+
import { jsx, useColorMode, Heading } from 'theme-ui';
4+
import { Flex } from '@theme-ui/components';
5+
import { ColorMode } from './ColorMode';
6+
7+
interface HeaderProps {
8+
title?: string;
9+
}
10+
export const Header: FC<HeaderProps> = ({ title }) => {
11+
const [colorMode, setColorMode] = useColorMode();
12+
const isDark = colorMode === `dark`;
13+
const toggleColorMode = (e: any) => {
14+
e.preventDefault();
15+
setColorMode(isDark ? `light` : `dark`);
16+
};
17+
18+
return (
19+
<header sx={{ px: 3, py: 1 }}>
20+
<Flex sx={{ alignItems: `center`, justifyContent: `space-between` }}>
21+
<Heading>{title}</Heading>
22+
<ColorMode isDark={isDark} toggle={toggleColorMode} />
23+
</Flex>
24+
<div
25+
sx={{
26+
boxSizing: `border-box`,
27+
display: `flex`,
28+
variant: `dividers.bottom`,
29+
alignItems: `center`,
30+
justifyContent: `space-between`,
31+
mt: 3,
32+
color: `secondary`,
33+
a: { color: `secondary`, ':hover': { color: `heading` } },
34+
flexFlow: `wrap`,
35+
}}
36+
>
37+
links
38+
</div>
39+
</header>
40+
);
41+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/** @jsx jsx */
2+
import React, { FC } from 'react';
3+
import { jsx, Container } from 'theme-ui';
4+
import { Global } from '@emotion/core';
5+
import { ThemeProvider } from '@component-controls/components';
6+
import { PageContainer, store } from '@component-controls/blocks';
7+
import { Store } from '@component-controls/store';
8+
import { SEO } from './SEO';
9+
import { Sidebar } from './Sidebar';
10+
import { Header } from './Header';
11+
12+
interface LayoutProps {
13+
children: React.ReactNode;
14+
title?: string;
15+
}
16+
17+
export const Layout: FC<LayoutProps> = ({ children, title }) => {
18+
const storyStore = React.useMemo(
19+
() => new Store({ store, updateLocalStorage: false }),
20+
[],
21+
);
22+
23+
return (
24+
<ThemeProvider>
25+
<Global
26+
styles={() => ({
27+
'*': {
28+
boxSizing: `inherit`,
29+
},
30+
a: {
31+
transition: `all 0.3s ease-in-out`,
32+
},
33+
})}
34+
/>
35+
<SEO title={title} />
36+
<div
37+
sx={{
38+
display: `grid`,
39+
gridTemplateColumns: [`200px 1fr`, `200px 1fr`, `250px 1fr`],
40+
minHeight: `100vh`,
41+
}}
42+
>
43+
<Sidebar />
44+
<Container>
45+
<Header title={title} />
46+
<PageContainer store={storyStore} storyId="id-of-story">
47+
{children}
48+
</PageContainer>
49+
</Container>
50+
</div>
51+
</ThemeProvider>
52+
);
53+
};

0 commit comments

Comments
 (0)