@enhanced-dom/slides 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +21 -0
- package/README.md +1 -0
- package/components/component-wave.component.d.ts +8 -0
- package/components/component-wave.component.js +28 -0
- package/components/image-wave.component.d.ts +5 -0
- package/components/image-wave.component.js +27 -0
- package/components/index.d.ts +3 -0
- package/components/index.js +3 -0
- package/components/toc.component.d.ts +15 -0
- package/components/toc.component.js +14 -0
- package/components/wave.component.d.ts +10 -0
- package/components/wave.component.js +37 -0
- package/index.d.ts +3 -0
- package/index.js +3 -0
- package/package.json +47 -0
- package/shell/header.component.d.ts +7 -0
- package/shell/header.component.js +24 -0
- package/shell/index.d.ts +1 -0
- package/shell/index.js +1 -0
- package/shell/scroll-top/icon.component.d.ts +20 -0
- package/shell/scroll-top/icon.component.js +8 -0
- package/shell/scroll-top/index.d.ts +1 -0
- package/shell/scroll-top/index.js +1 -0
- package/shell/scroll-top/scroll-top.component.d.ts +2 -0
- package/shell/scroll-top/scroll-top.component.js +31 -0
- package/shell/scroll-top/scroll-top.style.scss +26 -0
- package/shell/scroll-top/scroll-top.style.scss.d.ts +2 -0
- package/shell/shell.component.d.ts +16 -0
- package/shell/shell.component.js +51 -0
- package/theme.d.ts +49 -0
- package/theme.js +234 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021-present CD9B4A105290E17E0948E021DF4105107C88693C59C0B891CCC08366C51AEA990902A6A156AC87D88A2FC41422A5E1C3C4071F251F19441C4516000EC25F87DF
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Basic building blocks for html slides
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Wave } from './wave.component';
|
|
3
|
+
export declare class ComponentWave extends Wave {
|
|
4
|
+
static Slot: ({ children }: {
|
|
5
|
+
children: any;
|
|
6
|
+
}) => any;
|
|
7
|
+
protected toColumns: (items: React.ReactElement[]) => [React.ReactElement<any, string | React.JSXElementConstructor<any>>[], React.ReactElement<any, string | React.JSXElementConstructor<any>>[]];
|
|
8
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Wave } from './wave.component';
|
|
3
|
+
const ComponentWaveSlot = ({ children }) => {
|
|
4
|
+
return children || null;
|
|
5
|
+
};
|
|
6
|
+
export class ComponentWave extends Wave {
|
|
7
|
+
constructor() {
|
|
8
|
+
super(...arguments);
|
|
9
|
+
this.toColumns = (items) => {
|
|
10
|
+
const columns = Array(2)
|
|
11
|
+
.fill(null)
|
|
12
|
+
.map(() => []);
|
|
13
|
+
items.forEach((item) => {
|
|
14
|
+
const isComponentSlot = item.type && typeof item.type === typeof ComponentWaveSlot;
|
|
15
|
+
if (isComponentSlot) {
|
|
16
|
+
columns[0].push(item);
|
|
17
|
+
columns[1].push(React.createElement('div', {}, []));
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
const step = columns[0].length - 1;
|
|
21
|
+
columns[1][step].props.children.push(item);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
return columns;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
ComponentWave.Slot = ComponentWaveSlot;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Wave } from './wave.component';
|
|
3
|
+
export declare class ImageWave extends Wave {
|
|
4
|
+
protected toColumns: (items: React.ReactElement[]) => [React.ReactElement<any, string | React.JSXElementConstructor<any>>[], React.ReactElement<any, string | React.JSXElementConstructor<any>>[]];
|
|
5
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Wave } from './wave.component';
|
|
3
|
+
export class ImageWave extends Wave {
|
|
4
|
+
constructor() {
|
|
5
|
+
super(...arguments);
|
|
6
|
+
this.toColumns = (items) => {
|
|
7
|
+
const columns = Array(2)
|
|
8
|
+
.fill(null)
|
|
9
|
+
.map(() => []);
|
|
10
|
+
items.forEach((item) => {
|
|
11
|
+
const isImg = item.props && item.props.mdxType === 'img';
|
|
12
|
+
if (isImg) {
|
|
13
|
+
const img = React.cloneElement(item, {
|
|
14
|
+
style: { objectFit: 'contain', margin: 0 },
|
|
15
|
+
});
|
|
16
|
+
columns[0].push(img);
|
|
17
|
+
columns[1].push(React.createElement('div', {}, []));
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
const step = columns[0].length - 1;
|
|
21
|
+
columns[1][step].props.children.push(item);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
return columns;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
interface TocItemProps {
|
|
3
|
+
heading: string;
|
|
4
|
+
to?: string;
|
|
5
|
+
explanation?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const Toc: {
|
|
8
|
+
({ headings }: {
|
|
9
|
+
headings: TocItemProps[];
|
|
10
|
+
}): JSX.Element;
|
|
11
|
+
Heading: ({ heading }: {
|
|
12
|
+
heading: string;
|
|
13
|
+
}) => JSX.Element;
|
|
14
|
+
};
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
const Heading = ({ heading }) => (React.createElement("h2", null,
|
|
3
|
+
heading,
|
|
4
|
+
React.createElement("a", { style: { display: 'none' }, id: heading.toLowerCase().replace(/\s/, '-') })));
|
|
5
|
+
const TocItem = ({ heading, to, explanation }) => {
|
|
6
|
+
const anchor = to !== null && to !== void 0 ? to : heading;
|
|
7
|
+
return (React.createElement("li", null,
|
|
8
|
+
React.createElement("a", { href: anchor.toLowerCase().replace(/\s/, '-') },
|
|
9
|
+
React.createElement("em", null, heading)),
|
|
10
|
+
explanation ? ': ' : '',
|
|
11
|
+
explanation));
|
|
12
|
+
};
|
|
13
|
+
export const Toc = ({ headings }) => (React.createElement("ul", null, headings.map((h, idx) => (React.createElement(TocItem, Object.assign({ key: idx }, h))))));
|
|
14
|
+
Toc.Heading = Heading;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { jsx } from 'theme-ui';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
export declare abstract class Wave extends React.PureComponent<{
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
}> {
|
|
7
|
+
protected abstract toColumns: (children: React.ReactElement[]) => [React.ReactElement[], React.ReactElement[]];
|
|
8
|
+
private childrenToColumns;
|
|
9
|
+
render(): jsx.JSX.Element;
|
|
10
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { jsx } from 'theme-ui';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import Scroller from 'gatsby-theme-waves/src/components/bar-scroller';
|
|
5
|
+
import BaseWave from 'gatsby-theme-waves/src/components/wave';
|
|
6
|
+
const Sticker = ({ progress = 0, steps, variant = 'default' }) => {
|
|
7
|
+
const currentStep = Math.round(progress);
|
|
8
|
+
const prev = steps[currentStep - 1];
|
|
9
|
+
const curr = steps[currentStep];
|
|
10
|
+
const next = steps[currentStep + 1];
|
|
11
|
+
return (jsx("div", { sx: {
|
|
12
|
+
variant: `styles.waves.${variant}.StickerContainer`,
|
|
13
|
+
} },
|
|
14
|
+
jsx("div", { sx: { variant: `styles.waves.${variant}.Sticker` } },
|
|
15
|
+
prev && (jsx("div", { sx: {
|
|
16
|
+
variant: `styles.waves.${variant}.StickerStep`,
|
|
17
|
+
}, style: { opacity: Math.max(0, currentStep - progress) }, key: currentStep - 1 }, prev)),
|
|
18
|
+
jsx("div", { sx: {
|
|
19
|
+
variant: `styles.waves.${variant}.StickerStep`,
|
|
20
|
+
}, style: { opacity: 1 - Math.abs(currentStep - progress) }, key: currentStep }, curr),
|
|
21
|
+
next && (jsx("div", { sx: {
|
|
22
|
+
variant: `styles.waves.${variant}.StickerStep`,
|
|
23
|
+
}, style: { opacity: Math.max(0, progress - currentStep) }, key: currentStep + 1 }, next)))));
|
|
24
|
+
};
|
|
25
|
+
export class Wave extends React.PureComponent {
|
|
26
|
+
constructor() {
|
|
27
|
+
super(...arguments);
|
|
28
|
+
this.childrenToColumns = (children) => {
|
|
29
|
+
const items = React.Children.toArray(children);
|
|
30
|
+
const columns = this.toColumns(items);
|
|
31
|
+
return columns;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
render() {
|
|
35
|
+
return jsx(BaseWave, Object.assign({ columnComponents: [Sticker, Scroller], childrenToStepColumns: this.childrenToColumns }, this.props));
|
|
36
|
+
}
|
|
37
|
+
}
|
package/index.d.ts
ADDED
package/index.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@enhanced-dom/slides",
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"description": "Basic building blocks for html slides",
|
|
5
|
+
"keywords": [],
|
|
6
|
+
"repository": "https://github.com/enhanced-dom/slides.git",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"author": "CD9B4A105290E17E0948E021DF4105107C88693C59C0B891CCC08366C51AEA990902A6A156AC87D88A2FC41422A5E1C3C4071F251F19441C4516000EC25F87DF",
|
|
9
|
+
"main": "index.js",
|
|
10
|
+
"scripts": {
|
|
11
|
+
"package": "cd dist && npm pack",
|
|
12
|
+
"prebuild": "rimraf dist/*",
|
|
13
|
+
"build": "tsc -p ./tsconfig.json",
|
|
14
|
+
"postbuild": "copyfiles package.json LICENSE.md README.md dist && copyfiles -u 1 src/**/*.scss* dist",
|
|
15
|
+
"lint": "eslint src/** --fix --config eslint.config.js"
|
|
16
|
+
},
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"@emotion/react": "^11.4.0",
|
|
19
|
+
"@enhanced-dom/fontawesome": "^0.0.2",
|
|
20
|
+
"@enhanced-dom/icon": "^0.0.2",
|
|
21
|
+
"@enhanced-dom/react": "^0.0.2",
|
|
22
|
+
"@fontsource/montserrat": "^4.4.5",
|
|
23
|
+
"@fortawesome/free-regular-svg-icons": "^5.15.3",
|
|
24
|
+
"@fortawesome/free-solid-svg-icons": "^5.15.3",
|
|
25
|
+
"@theme-ui/typography": "^0.10.0",
|
|
26
|
+
"deepmerge": "^4.2.2",
|
|
27
|
+
"gatsby-theme-blog": "^3.0.0",
|
|
28
|
+
"gatsby-theme-waves": "^0.1.6",
|
|
29
|
+
"lodash.pick": "^4.4.0",
|
|
30
|
+
"react-card-flip": "^1.1.1",
|
|
31
|
+
"theme-ui": "^0.9.1",
|
|
32
|
+
"typography-theme-wordpress-2016": "^0.16.19"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@enhanced-dom/lint": "^0.0.3",
|
|
36
|
+
"@types/lodash.pick": "^4.4.6",
|
|
37
|
+
"@types/react": "^17.0.8",
|
|
38
|
+
"@types/react-dom": "^17.0.5",
|
|
39
|
+
"copyfiles": "2.4.1",
|
|
40
|
+
"rimraf": "3.0.2",
|
|
41
|
+
"typescript": "4.2.2"
|
|
42
|
+
},
|
|
43
|
+
"engines": {
|
|
44
|
+
"node": ">=14.17.0",
|
|
45
|
+
"npm": ">=8.0.0"
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { Themed, jsx } from 'theme-ui';
|
|
3
|
+
import { SizeVariableNames, ColorVariableNames } from '../theme';
|
|
4
|
+
export const ShellHeader = ({ title, author, date }) => {
|
|
5
|
+
return (jsx("div", { sx: { position: 'relative' } },
|
|
6
|
+
jsx("div", { sx: {
|
|
7
|
+
position: ['static', 'absolute'],
|
|
8
|
+
width: '100%',
|
|
9
|
+
height: ['auto', '100%'],
|
|
10
|
+
right: ['auto', SizeVariableNames.FULL_CONTENT_WIDTH],
|
|
11
|
+
color: ['text', ColorVariableNames.LIGHT_TEXT],
|
|
12
|
+
} },
|
|
13
|
+
jsx("div", { sx: {
|
|
14
|
+
float: ['none', 'right'],
|
|
15
|
+
display: ['block', 'inline-block'],
|
|
16
|
+
textAlign: ['left', 'right'],
|
|
17
|
+
} },
|
|
18
|
+
jsx(Themed.h1, { sx: { paddingBottom: '80px' } }, title))),
|
|
19
|
+
jsx("div", null,
|
|
20
|
+
jsx(Themed.p, { sx: { paddingTop: 1 } },
|
|
21
|
+
jsx(Themed.a, { href: "/", sx: { textDecoration: 'none', color: 'inherit', border: 'none' } }, author),
|
|
22
|
+
jsx("br", null),
|
|
23
|
+
jsx("span", { sx: { fontSize: 1 } }, date)))));
|
|
24
|
+
};
|
package/shell/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './shell.component';
|
package/shell/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './shell.component';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { IconWebComponent, IIconConfig } from '@enhanced-dom/icon';
|
|
3
|
+
import { IconDefinition } from '@fortawesome/fontawesome-common-types';
|
|
4
|
+
declare type IconConfigType = IIconConfig<IconDefinition>;
|
|
5
|
+
declare interface IconAttributes extends Omit<React.DetailedHTMLProps<React.HTMLAttributes<IconWebComponent>, IconWebComponent>, 'class' | 'style'> {
|
|
6
|
+
className?: string;
|
|
7
|
+
style?: React.CSSProperties;
|
|
8
|
+
config: IconConfigType;
|
|
9
|
+
}
|
|
10
|
+
declare global {
|
|
11
|
+
namespace JSX {
|
|
12
|
+
interface IntrinsicElements {
|
|
13
|
+
['enhanced-dom-icon']: IconAttributes;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export declare const Icon: import("react").ComponentType<IconAttributes> & {
|
|
18
|
+
renderer: import("@enhanced-dom/icon").MultiIconRenderer;
|
|
19
|
+
} & Record<string, AnalyserNode>;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { withReactAdapter } from '@enhanced-dom/react';
|
|
2
|
+
import { IconWebComponent } from '@enhanced-dom/icon';
|
|
3
|
+
import { FontawesomeIconRenderer } from '@enhanced-dom/fontawesome';
|
|
4
|
+
IconWebComponent.addIconInterpreter('fa5', new FontawesomeIconRenderer());
|
|
5
|
+
export const Icon = withReactAdapter({
|
|
6
|
+
type: IconWebComponent,
|
|
7
|
+
name: 'enhanced-dom-icon',
|
|
8
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './scroll-top.component';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './scroll-top.component';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import ReactCardFlip from 'react-card-flip';
|
|
3
|
+
import { faArrowAltCircleUp } from '@fortawesome/free-regular-svg-icons';
|
|
4
|
+
import * as styles from './scroll-top.style.scss';
|
|
5
|
+
import { Icon } from './icon.component';
|
|
6
|
+
const getBodyScroll = () => {
|
|
7
|
+
return document.body.scrollTop !== 0 || document.documentElement.scrollTop !== 0;
|
|
8
|
+
};
|
|
9
|
+
const scrollToTop = () => {
|
|
10
|
+
if (getBodyScroll()) {
|
|
11
|
+
window.scrollBy(0, -50);
|
|
12
|
+
requestAnimationFrame(scrollToTop);
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
export const ScrollTop = ({ children }) => {
|
|
16
|
+
const [isFlipped, setFlipped] = React.useState(false);
|
|
17
|
+
const showButton = () => {
|
|
18
|
+
if (getBodyScroll()) {
|
|
19
|
+
setFlipped(true);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
const showFront = () => {
|
|
23
|
+
setFlipped(false);
|
|
24
|
+
};
|
|
25
|
+
const buttonContents = children ? (React.createElement(ReactCardFlip, { isFlipped: isFlipped, flipDirection: "horizontal" },
|
|
26
|
+
React.createElement("div", null, children),
|
|
27
|
+
React.createElement("div", { className: styles.brandingBack },
|
|
28
|
+
React.createElement(Icon, { config: { ...faArrowAltCircleUp, namespace: 'fa5' } })))) : (React.createElement("div", { className: styles.brandingBack },
|
|
29
|
+
React.createElement(Icon, { config: { ...faArrowAltCircleUp, namespace: 'fa5' } })));
|
|
30
|
+
return (React.createElement("div", { className: styles.branding, tabIndex: 0, role: "button", onClick: scrollToTop, onFocus: showButton, onBlur: showFront, onMouseEnter: showButton, onMouseLeave: showFront }, buttonContents));
|
|
31
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
.branding {
|
|
2
|
+
width: 3rem;
|
|
3
|
+
height: 3rem;
|
|
4
|
+
position: fixed;
|
|
5
|
+
bottom: 2.5rem;
|
|
6
|
+
right: 2.5rem;
|
|
7
|
+
z-index: 1;
|
|
8
|
+
outline-color: #e2001a;
|
|
9
|
+
color: #e2001a;
|
|
10
|
+
|
|
11
|
+
> div {
|
|
12
|
+
height: 100%;
|
|
13
|
+
width: 100%;
|
|
14
|
+
display: flex;
|
|
15
|
+
align-items: center;
|
|
16
|
+
justify-content: space-around;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
&-back {
|
|
20
|
+
background-color: transparent;
|
|
21
|
+
font-size: 2rem;
|
|
22
|
+
color: #e2001a;
|
|
23
|
+
cursor: pointer;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
/** @jsxFrag React.Fragment */
|
|
3
|
+
import { Theme } from 'theme-ui';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { ShellHeader } from './header.component';
|
|
6
|
+
declare const BrandingSlot: ({ children }: {
|
|
7
|
+
children: any;
|
|
8
|
+
}) => any;
|
|
9
|
+
declare const ContentsSlot: React.FC<React.ComponentProps<typeof ShellHeader>>;
|
|
10
|
+
export declare const Shell: React.FC<{
|
|
11
|
+
theme?: Theme;
|
|
12
|
+
}> & {
|
|
13
|
+
Branding: typeof BrandingSlot;
|
|
14
|
+
Contents: typeof ContentsSlot;
|
|
15
|
+
};
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
/** @jsxFrag React.Fragment */
|
|
3
|
+
import { jsx, Themed, ThemeProvider } from 'theme-ui';
|
|
4
|
+
import { Global } from '@emotion/react';
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import defaultTheme, { ColorVariableNames, SizeVariableNames } from '../theme';
|
|
7
|
+
import { ShellHeader } from './header.component';
|
|
8
|
+
import { ScrollTop } from './scroll-top';
|
|
9
|
+
const BrandingSlot = ({ children }) => {
|
|
10
|
+
return children || null;
|
|
11
|
+
};
|
|
12
|
+
const ContentsSlot = ({ children, ...rest }) => {
|
|
13
|
+
return (jsx(React.Fragment, null,
|
|
14
|
+
jsx(ShellHeader, Object.assign({}, rest)),
|
|
15
|
+
children || null));
|
|
16
|
+
};
|
|
17
|
+
const getBranding = (children) => React.Children.toArray(children).find((item) => { var _a; return ((_a = item) === null || _a === void 0 ? void 0 : _a.type) === BrandingSlot; });
|
|
18
|
+
const getContents = (children) => React.Children.toArray(children).find((item) => { var _a; return ((_a = item) === null || _a === void 0 ? void 0 : _a.type) === ContentsSlot; });
|
|
19
|
+
export const Shell = ({ children, theme, }) => {
|
|
20
|
+
const branding = getBranding(children);
|
|
21
|
+
const contents = getContents(children);
|
|
22
|
+
return (jsx(ThemeProvider, { theme: theme },
|
|
23
|
+
jsx(Themed.root, { sx: {
|
|
24
|
+
display: 'flex',
|
|
25
|
+
width: '100vw',
|
|
26
|
+
} },
|
|
27
|
+
jsx(Global, { styles: {
|
|
28
|
+
body: { margin: 0, overflowX: 'hidden' },
|
|
29
|
+
} }),
|
|
30
|
+
jsx("aside", { sx: {
|
|
31
|
+
bg: ColorVariableNames.DARK_BACKGROUND,
|
|
32
|
+
color: ColorVariableNames.LIGHT_TEXT,
|
|
33
|
+
width: [0, '40vw'],
|
|
34
|
+
minHeight: '100vh',
|
|
35
|
+
} }),
|
|
36
|
+
jsx("div", { sx: { bg: ColorVariableNames.BACKGROUND, color: ColorVariableNames.TEXT, width: ['100vw', '60vw'] } },
|
|
37
|
+
jsx("main", { sx: {
|
|
38
|
+
py: [5, SizeVariableNames.TOP_MARGIN],
|
|
39
|
+
pl: [0, SizeVariableNames.INNER_MARGIN],
|
|
40
|
+
width: [SizeVariableNames.CONTENT, SizeVariableNames.CONTENT],
|
|
41
|
+
maxWidth: ['80%', 'none'],
|
|
42
|
+
mx: ['auto', 0],
|
|
43
|
+
} },
|
|
44
|
+
contents,
|
|
45
|
+
branding ? jsx(ScrollTop, null, branding) : null)))));
|
|
46
|
+
};
|
|
47
|
+
Shell.defaultProps = {
|
|
48
|
+
theme: defaultTheme,
|
|
49
|
+
};
|
|
50
|
+
Shell.Branding = BrandingSlot;
|
|
51
|
+
Shell.Contents = ContentsSlot;
|
package/theme.d.ts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import '@fontsource/montserrat';
|
|
2
|
+
export declare enum ColorVariableNames {
|
|
3
|
+
BACKGROUND = "background",
|
|
4
|
+
TEXT = "text",
|
|
5
|
+
DARK_BACKGROUND = "darkBackground",
|
|
6
|
+
LIGHT_TEXT = "lightText",
|
|
7
|
+
HIGHLIGHT = "highlight",
|
|
8
|
+
MUTED = "muted",
|
|
9
|
+
LIGHTER_BLUE = "lighterBlue",
|
|
10
|
+
LIGHT_BLUE = "lightBlue",
|
|
11
|
+
HEADING = "heading"
|
|
12
|
+
}
|
|
13
|
+
export declare enum SizeVariableNames {
|
|
14
|
+
CONTENT = "content",
|
|
15
|
+
INNER_MARGIN = "innerMargin",
|
|
16
|
+
CENTRAL_GAP = "centralGap",
|
|
17
|
+
TOP_MARGIN = "topMargin",
|
|
18
|
+
FULL_CONTENT = "fullContent",
|
|
19
|
+
FULL_CONTENT_WIDTH = "fullContentWidth"
|
|
20
|
+
}
|
|
21
|
+
export declare enum FontVariableNames {
|
|
22
|
+
BODY = "body",
|
|
23
|
+
MONOSPACE = "monospace"
|
|
24
|
+
}
|
|
25
|
+
export declare const variables: {
|
|
26
|
+
colors: {
|
|
27
|
+
background: string;
|
|
28
|
+
text: string;
|
|
29
|
+
darkBackground: string;
|
|
30
|
+
lightText: string;
|
|
31
|
+
muted: string;
|
|
32
|
+
lighterBlue: string;
|
|
33
|
+
heading: string;
|
|
34
|
+
lightBlue: string;
|
|
35
|
+
};
|
|
36
|
+
sizes: {
|
|
37
|
+
content: number;
|
|
38
|
+
innerMargin: number;
|
|
39
|
+
topMargin: number;
|
|
40
|
+
centralGap: number;
|
|
41
|
+
fullContentWidth: number;
|
|
42
|
+
};
|
|
43
|
+
fonts: {
|
|
44
|
+
body: string;
|
|
45
|
+
monospace: string;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
declare const theme: any;
|
|
49
|
+
export default theme;
|
package/theme.js
ADDED
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
import { toTheme } from '@theme-ui/typography';
|
|
2
|
+
import typography from 'typography-theme-wordpress-2016';
|
|
3
|
+
import merge from 'deepmerge';
|
|
4
|
+
import '@fontsource/montserrat';
|
|
5
|
+
import pick from 'lodash.pick';
|
|
6
|
+
// @ts-nocheck
|
|
7
|
+
import blogTheme from 'gatsby-theme-blog/src/gatsby-plugin-theme-ui/components';
|
|
8
|
+
const typographyTheme = toTheme(typography);
|
|
9
|
+
export var ColorVariableNames;
|
|
10
|
+
(function (ColorVariableNames) {
|
|
11
|
+
ColorVariableNames["BACKGROUND"] = "background";
|
|
12
|
+
ColorVariableNames["TEXT"] = "text";
|
|
13
|
+
ColorVariableNames["DARK_BACKGROUND"] = "darkBackground";
|
|
14
|
+
ColorVariableNames["LIGHT_TEXT"] = "lightText";
|
|
15
|
+
ColorVariableNames["HIGHLIGHT"] = "highlight";
|
|
16
|
+
ColorVariableNames["MUTED"] = "muted";
|
|
17
|
+
ColorVariableNames["LIGHTER_BLUE"] = "lighterBlue";
|
|
18
|
+
ColorVariableNames["LIGHT_BLUE"] = "lightBlue";
|
|
19
|
+
ColorVariableNames["HEADING"] = "heading";
|
|
20
|
+
})(ColorVariableNames || (ColorVariableNames = {}));
|
|
21
|
+
export var SizeVariableNames;
|
|
22
|
+
(function (SizeVariableNames) {
|
|
23
|
+
SizeVariableNames["CONTENT"] = "content";
|
|
24
|
+
SizeVariableNames["INNER_MARGIN"] = "innerMargin";
|
|
25
|
+
SizeVariableNames["CENTRAL_GAP"] = "centralGap";
|
|
26
|
+
SizeVariableNames["TOP_MARGIN"] = "topMargin";
|
|
27
|
+
SizeVariableNames["FULL_CONTENT"] = "fullContent";
|
|
28
|
+
SizeVariableNames["FULL_CONTENT_WIDTH"] = "fullContentWidth";
|
|
29
|
+
})(SizeVariableNames || (SizeVariableNames = {}));
|
|
30
|
+
export var FontVariableNames;
|
|
31
|
+
(function (FontVariableNames) {
|
|
32
|
+
FontVariableNames["BODY"] = "body";
|
|
33
|
+
FontVariableNames["MONOSPACE"] = "monospace";
|
|
34
|
+
})(FontVariableNames || (FontVariableNames = {}));
|
|
35
|
+
export const variables = {
|
|
36
|
+
colors: {
|
|
37
|
+
[ColorVariableNames.BACKGROUND]: '#f1f5f8',
|
|
38
|
+
[ColorVariableNames.TEXT]: '#3D4851',
|
|
39
|
+
[ColorVariableNames.DARK_BACKGROUND]: '#3D4851',
|
|
40
|
+
[ColorVariableNames.LIGHT_TEXT]: 'white',
|
|
41
|
+
[ColorVariableNames.MUTED]: '#3D4851',
|
|
42
|
+
[ColorVariableNames.LIGHTER_BLUE]: '#ebfcf6',
|
|
43
|
+
[ColorVariableNames.HEADING]: '#e2001a',
|
|
44
|
+
[ColorVariableNames.LIGHT_BLUE]: '#aaf6d9',
|
|
45
|
+
},
|
|
46
|
+
sizes: {
|
|
47
|
+
[SizeVariableNames.CONTENT]: 420,
|
|
48
|
+
[SizeVariableNames.INNER_MARGIN]: 85,
|
|
49
|
+
[SizeVariableNames.TOP_MARGIN]: 256,
|
|
50
|
+
[SizeVariableNames.CENTRAL_GAP]: 85 * 2,
|
|
51
|
+
[SizeVariableNames.FULL_CONTENT_WIDTH]: 85 * 2 + 420,
|
|
52
|
+
},
|
|
53
|
+
fonts: {
|
|
54
|
+
[FontVariableNames.BODY]: 'Montserrat, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, sans-serif',
|
|
55
|
+
[FontVariableNames.MONOSPACE]: `Consolas, Menlo, Monaco, source-code-pro, Courier New, monospace`,
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
const theme = merge.all([
|
|
59
|
+
blogTheme,
|
|
60
|
+
typographyTheme,
|
|
61
|
+
{
|
|
62
|
+
colors: variables.colors,
|
|
63
|
+
space: {
|
|
64
|
+
...typographyTheme.space,
|
|
65
|
+
...pick(variables.sizes, [
|
|
66
|
+
SizeVariableNames.INNER_MARGIN,
|
|
67
|
+
SizeVariableNames.TOP_MARGIN,
|
|
68
|
+
SizeVariableNames.FULL_CONTENT_WIDTH,
|
|
69
|
+
SizeVariableNames.CENTRAL_GAP,
|
|
70
|
+
]),
|
|
71
|
+
},
|
|
72
|
+
sizes: pick(variables.sizes, [SizeVariableNames.CONTENT]),
|
|
73
|
+
fonts: variables.fonts,
|
|
74
|
+
styles: {
|
|
75
|
+
root: {
|
|
76
|
+
fontFamily: FontVariableNames.BODY,
|
|
77
|
+
},
|
|
78
|
+
a: {
|
|
79
|
+
color: 'inherit',
|
|
80
|
+
textDecoration: 'none',
|
|
81
|
+
borderBottom: '1px solid',
|
|
82
|
+
borderColor: ColorVariableNames.MUTED,
|
|
83
|
+
},
|
|
84
|
+
li: {
|
|
85
|
+
marginBottom: '4px',
|
|
86
|
+
code: {
|
|
87
|
+
fontSize: `inherit`,
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
pre: {
|
|
91
|
+
variant: `prism`,
|
|
92
|
+
fontFamily: FontVariableNames.MONOSPACE,
|
|
93
|
+
tabSize: 2,
|
|
94
|
+
hyphens: `none`,
|
|
95
|
+
overflow: `auto`,
|
|
96
|
+
borderRadius: 10,
|
|
97
|
+
p: 0,
|
|
98
|
+
pl: 2,
|
|
99
|
+
color: ColorVariableNames.TEXT,
|
|
100
|
+
backgroundColor: ColorVariableNames.BACKGROUND,
|
|
101
|
+
marginBottom: '28px',
|
|
102
|
+
whiteSpace: 'pre-wrap',
|
|
103
|
+
},
|
|
104
|
+
code: {
|
|
105
|
+
fontFamily: FontVariableNames.MONOSPACE,
|
|
106
|
+
fontSize: `inherit`,
|
|
107
|
+
},
|
|
108
|
+
h1: {
|
|
109
|
+
fontStyle: 'italic',
|
|
110
|
+
color: ColorVariableNames.HEADING,
|
|
111
|
+
},
|
|
112
|
+
h2: {
|
|
113
|
+
marginTop: '60px',
|
|
114
|
+
fontStyle: 'italic',
|
|
115
|
+
},
|
|
116
|
+
h3: {
|
|
117
|
+
marginTop: '4px',
|
|
118
|
+
},
|
|
119
|
+
inlineCode: {
|
|
120
|
+
borderRadius: `0.3em`,
|
|
121
|
+
paddingTop: `0.15em`,
|
|
122
|
+
paddingBottom: `0.05em`,
|
|
123
|
+
paddingX: `0.2em`,
|
|
124
|
+
},
|
|
125
|
+
hr: {
|
|
126
|
+
borderColor: ColorVariableNames.MUTED,
|
|
127
|
+
},
|
|
128
|
+
p: {
|
|
129
|
+
marginBottom: '20px',
|
|
130
|
+
marginTop: '20px',
|
|
131
|
+
code: {
|
|
132
|
+
fontSize: `inherit`,
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
blockquote: {
|
|
136
|
+
color: `inherit`,
|
|
137
|
+
borderLeftColor: `inherit`,
|
|
138
|
+
opacity: 0.8,
|
|
139
|
+
'&.translation': {
|
|
140
|
+
fontSize: `1em`,
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
waves: {
|
|
144
|
+
default: {
|
|
145
|
+
Wave: {
|
|
146
|
+
width: ['100%', variables.sizes[SizeVariableNames.CONTENT] * 2 + variables.sizes[SizeVariableNames.CENTRAL_GAP]],
|
|
147
|
+
// marginTop: "40px",
|
|
148
|
+
marginLeft: [0, -(variables.sizes[SizeVariableNames.CONTENT] + variables.sizes[SizeVariableNames.CENTRAL_GAP])],
|
|
149
|
+
marginBottom: '28px',
|
|
150
|
+
position: 'relative',
|
|
151
|
+
display: ['block', 'flex'],
|
|
152
|
+
},
|
|
153
|
+
ScrollerContainer: {
|
|
154
|
+
paddingTop: ['80px', 0],
|
|
155
|
+
width: ['auto', SizeVariableNames.CONTENT],
|
|
156
|
+
marginLeft: [0, SizeVariableNames.CENTRAL_GAP],
|
|
157
|
+
},
|
|
158
|
+
ScrollerStep: {
|
|
159
|
+
position: 'relative',
|
|
160
|
+
padding: 0,
|
|
161
|
+
minHeight: '400px',
|
|
162
|
+
display: 'flex',
|
|
163
|
+
alignItems: 'center',
|
|
164
|
+
borderLeft: 0,
|
|
165
|
+
},
|
|
166
|
+
ScrollerProgress: {
|
|
167
|
+
backgroundColor: ColorVariableNames.MUTED,
|
|
168
|
+
borderRadius: '3px',
|
|
169
|
+
position: 'absolute',
|
|
170
|
+
left: '-24px',
|
|
171
|
+
},
|
|
172
|
+
StickerContainer: {
|
|
173
|
+
width: ['100vw', SizeVariableNames.CONTENT],
|
|
174
|
+
marginLeft: ['calc(50% - 50vw)', 0],
|
|
175
|
+
position: ['sticky', 'static'],
|
|
176
|
+
top: [0, 'auto'],
|
|
177
|
+
zIndex: [1, 'auto'],
|
|
178
|
+
height: ['50vh', 'auto'],
|
|
179
|
+
paddingRight: [0, SizeVariableNames.INNER_MARGIN],
|
|
180
|
+
backgroundColor: ColorVariableNames.DARK_BACKGROUND,
|
|
181
|
+
color: ColorVariableNames.LIGHT_TEXT,
|
|
182
|
+
},
|
|
183
|
+
Sticker: {
|
|
184
|
+
position: ['static', 'sticky'],
|
|
185
|
+
width: '100%',
|
|
186
|
+
height: ['100%', '80vh'],
|
|
187
|
+
maxHeight: ['100%', '80vh'],
|
|
188
|
+
top: ['auto', '2rem'],
|
|
189
|
+
marginLeft: [0, variables.sizes.innerMargin],
|
|
190
|
+
},
|
|
191
|
+
StickerStep: {
|
|
192
|
+
position: 'absolute',
|
|
193
|
+
height: '100%',
|
|
194
|
+
width: '100%',
|
|
195
|
+
display: 'flex',
|
|
196
|
+
justifyContent: 'center',
|
|
197
|
+
},
|
|
198
|
+
// this is used to select the active scroller step
|
|
199
|
+
// 0.5 selects the step that is at half the screen height
|
|
200
|
+
// 0.7 the step that is at 70% the screen height
|
|
201
|
+
focus: [0.7, 0.5],
|
|
202
|
+
},
|
|
203
|
+
},
|
|
204
|
+
CodeSurfer: {
|
|
205
|
+
pre: {
|
|
206
|
+
color: ColorVariableNames.LIGHT_TEXT,
|
|
207
|
+
backgroundColor: ColorVariableNames.DARK_BACKGROUND,
|
|
208
|
+
},
|
|
209
|
+
code: {
|
|
210
|
+
color: ColorVariableNames.LIGHT_TEXT,
|
|
211
|
+
backgroundColor: ColorVariableNames.DARK_BACKGROUND,
|
|
212
|
+
},
|
|
213
|
+
tokens: {
|
|
214
|
+
'comment cdata doctype': {
|
|
215
|
+
fontStyle: 'italic',
|
|
216
|
+
},
|
|
217
|
+
'builtin changed keyword punctuation operator tag deleted string attr-value char number inserted': {
|
|
218
|
+
color: ColorVariableNames.LIGHT_BLUE,
|
|
219
|
+
},
|
|
220
|
+
},
|
|
221
|
+
},
|
|
222
|
+
},
|
|
223
|
+
},
|
|
224
|
+
]);
|
|
225
|
+
theme.breakpoints = ['1000px'];
|
|
226
|
+
theme.prism = {
|
|
227
|
+
'.builtin, .changed, .keyword, .punctuation, .operator, .tag, .deleted, .string, .attr-value, .char, .number, .inserted': {
|
|
228
|
+
color: '#0f8f5e',
|
|
229
|
+
},
|
|
230
|
+
'.comment, .cdata, .doctype': {
|
|
231
|
+
fontStyle: 'italic',
|
|
232
|
+
},
|
|
233
|
+
};
|
|
234
|
+
export default theme;
|