@enhanced-dom/slides 0.0.5 → 0.0.7

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.
Files changed (45) hide show
  1. package/components/icon.component.d.ts +8 -0
  2. package/{shell/scroll-top → components}/icon.component.js +1 -2
  3. package/components/index.d.ts +2 -3
  4. package/components/index.js +2 -3
  5. package/components/scroll-top/scroll-top.component.d.ts +4 -0
  6. package/components/scroll-top/scroll-top.component.js +37 -0
  7. package/components/scroll-top/scroll-top.style.pcss +51 -0
  8. package/components/scroll-top/scroll-top.style.pcss.d.ts +4 -0
  9. package/components/shell/header.component.d.ts +7 -0
  10. package/components/shell/header.component.js +8 -0
  11. package/{shell → components/shell}/shell.component.d.ts +5 -3
  12. package/components/shell/shell.component.js +40 -0
  13. package/components/toc/heading2.component.d.ts +5 -0
  14. package/components/toc/heading2.component.js +36 -0
  15. package/components/toc/index.d.ts +2 -0
  16. package/components/toc/index.js +2 -0
  17. package/components/toc/toc.component.d.ts +9 -0
  18. package/components/toc/toc.component.js +6 -0
  19. package/components/toc/toc.style.pcss +70 -0
  20. package/components/toc/toc.style.pcss.d.ts +4 -0
  21. package/index.d.ts +1 -2
  22. package/index.js +1 -2
  23. package/package.json +14 -25
  24. package/theme.d.ts +27 -26
  25. package/theme.js +148 -142
  26. package/components/component-wave.component.d.ts +0 -8
  27. package/components/component-wave.component.js +0 -28
  28. package/components/image-wave.component.d.ts +0 -5
  29. package/components/image-wave.component.js +0 -27
  30. package/components/toc.component.d.ts +0 -15
  31. package/components/toc.component.js +0 -14
  32. package/components/wave.component.d.ts +0 -10
  33. package/components/wave.component.js +0 -37
  34. package/shell/header.component.d.ts +0 -7
  35. package/shell/header.component.js +0 -24
  36. package/shell/scroll-top/icon.component.d.ts +0 -13
  37. package/shell/scroll-top/scroll-top.component.d.ts +0 -2
  38. package/shell/scroll-top/scroll-top.component.js +0 -39
  39. package/shell/scroll-top/scroll-top.style.pcss +0 -25
  40. package/shell/scroll-top/scroll-top.style.pcss.d.ts +0 -2
  41. package/shell/shell.component.js +0 -51
  42. /package/{shell → components}/scroll-top/index.d.ts +0 -0
  43. /package/{shell → components}/scroll-top/index.js +0 -0
  44. /package/{shell → components/shell}/index.d.ts +0 -0
  45. /package/{shell → components/shell}/index.js +0 -0
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+ import { IconWebComponent, IconWebComponentAttributes } from '@enhanced-dom/icon';
3
+ import { IconDefinition } from '@fortawesome/fontawesome-common-types';
4
+ declare type IconComponentProps = IconWebComponentAttributes<IconDefinition> & React.DetailedHTMLProps<React.HTMLAttributes<IconWebComponent>, IconWebComponent>;
5
+ export declare const Icon: import("react").ComponentType<IconComponentProps> & {
6
+ renderer: import("@enhanced-dom/webcomponent").IRenderingEngine;
7
+ } & Record<string, AnalyserNode>;
8
+ export {};
@@ -1,8 +1,7 @@
1
- import { withReactAdapter } from '@enhanced-dom/react';
2
1
  import { IconWebComponent } from '@enhanced-dom/icon';
3
2
  import { FontawesomeIconRenderer } from '@enhanced-dom/fontawesome';
3
+ import { withReactAdapter } from '@enhanced-dom/react';
4
4
  IconWebComponent.addIconInterpreter('fa5', new FontawesomeIconRenderer());
5
- IconWebComponent.register();
6
5
  export const Icon = withReactAdapter({
7
6
  type: IconWebComponent,
8
7
  });
@@ -1,3 +1,2 @@
1
- export * from './toc.component';
2
- export * from './component-wave.component';
3
- export * from './image-wave.component';
1
+ export * from './toc';
2
+ export * from './shell';
@@ -1,3 +1,2 @@
1
- export * from './toc.component';
2
- export * from './component-wave.component';
3
- export * from './image-wave.component';
1
+ export * from './toc';
2
+ export * from './shell';
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ export declare const ScrollTop: ({ children }: {
3
+ children?: React.ReactNode;
4
+ }) => import("theme-ui/jsx-runtime").JSX.Element;
@@ -0,0 +1,37 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "theme-ui/jsx-runtime";
2
+ import React from 'react';
3
+ import ReactCardFlip from 'react-card-flip';
4
+ import { faArrowAltCircleUp } from '@fortawesome/free-regular-svg-icons';
5
+ import * as styles from './scroll-top.style.pcss';
6
+ import { Icon } from '../icon.component';
7
+ const getBodyScroll = () => {
8
+ return document.body.scrollTop !== 0 || document.documentElement.scrollTop !== 0;
9
+ };
10
+ const scrollToTop = () => {
11
+ if (getBodyScroll()) {
12
+ window.scrollBy(0, -50);
13
+ requestAnimationFrame(scrollToTop);
14
+ }
15
+ };
16
+ const scrollOnKey = (e) => {
17
+ if (e.altKey || e.shiftKey || e.ctrlKey || e.key !== 'Enter') {
18
+ return;
19
+ }
20
+ e.stopPropagation();
21
+ e.preventDefault();
22
+ scrollToTop();
23
+ };
24
+ export const ScrollTop = ({ children }) => {
25
+ const [isFlipped, setFlipped] = React.useState(false);
26
+ const showButton = React.useCallback(() => {
27
+ if (getBodyScroll()) {
28
+ setFlipped(true);
29
+ }
30
+ }, [setFlipped]);
31
+ const showFront = React.useCallback(() => {
32
+ setFlipped(false);
33
+ }, [setFlipped]);
34
+ const buttonContents = children ? (_jsxs(ReactCardFlip, Object.assign({ isFlipped: isFlipped, flipDirection: "horizontal" }, { children: [_jsx("div", Object.assign({ className: styles.brandingFront }, { children: children }), void 0),
35
+ _jsx("div", Object.assign({ className: styles.brandingBack }, { children: _jsx(Icon, { className: styles.scrollIcon, config: { ...faArrowAltCircleUp, namespace: 'fa5' } }, void 0) }), void 0)] }), void 0)) : (_jsx("div", Object.assign({ className: styles.brandingBack }, { children: _jsx(Icon, { className: styles.scrollIcon, config: { ...faArrowAltCircleUp, namespace: 'fa5' } }, void 0) }), void 0));
36
+ return (_jsx("div", Object.assign({ className: styles.branding, tabIndex: 0, role: "button", onClick: scrollToTop, onFocus: showButton, onBlur: showFront, onMouseEnter: showButton, onMouseLeave: showFront, onKeyDown: scrollOnKey }, { children: buttonContents }), void 0));
37
+ };
@@ -0,0 +1,51 @@
1
+ .branding {
2
+ width: 3rem;
3
+ height: 3rem;
4
+ position: fixed;
5
+ bottom: 1.5rem;
6
+ right: 1.5rem;
7
+ z-index: 1;
8
+ border-radius: 50%;
9
+ color: var(--theme-ui-colors-highlight, inherit);
10
+
11
+ &:focus,
12
+ &:active {
13
+ /* stylelint-disable-next-line unit-allowed-list */
14
+ box-shadow: inset 0 0 1px 1px var(--theme-ui-colors-dark-text, inherit);
15
+ outline: none;
16
+ }
17
+
18
+ > div {
19
+ height: 100%;
20
+ width: 100%;
21
+ display: flex;
22
+ align-items: center;
23
+ justify-content: space-around;
24
+ }
25
+
26
+ &-back {
27
+ height: 100%;
28
+ width: 100%;
29
+ background-color: transparent;
30
+ font-size: 2rem;
31
+ color: var(--theme-uicolors-highlight, inherit);
32
+ cursor: pointer;
33
+ display: flex;
34
+ justify-content: space-around;
35
+ align-items: center;
36
+ padding: 0.5rem;
37
+ }
38
+
39
+ &-front {
40
+ height: 100%;
41
+ width: 100%;
42
+ display: flex;
43
+ justify-content: space-around;
44
+ padding: 0.5rem;
45
+ }
46
+ }
47
+
48
+ .scroll-icon {
49
+ display: flex;
50
+ align-items: center;
51
+ }
@@ -0,0 +1,4 @@
1
+ export const branding: string
2
+ export const brandingBack: string
3
+ export const brandingFront: string
4
+ export const scrollIcon: string
@@ -0,0 +1,7 @@
1
+ export declare const ShellHeader: ({ title, author, profileLink, date, variant, }: {
2
+ title: string;
3
+ author: string;
4
+ profileLink?: string;
5
+ date: string;
6
+ variant?: string;
7
+ }) => import("theme-ui/jsx-runtime").JSX.Element;
@@ -0,0 +1,8 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "theme-ui/jsx-runtime";
2
+ import { Themed } from 'theme-ui';
3
+ export const ShellHeader = ({ title, author, profileLink, date, variant = 'default', }) => {
4
+ return (_jsxs("header", { children: [_jsx(Themed.h1, { children: title }, void 0),
5
+ _jsxs(Themed.p, Object.assign({ sx: { variant: `styles.shell.${variant}.Author` } }, { children: [profileLink ? (_jsx(Themed.a, Object.assign({ href: "/", sx: { textDecoration: 'none', color: 'inherit', border: 'none' } }, { children: author }), void 0)) : (author),
6
+ _jsx("br", {}, void 0),
7
+ _jsx("span", Object.assign({ sx: { fontSize: 1 } }, { children: date }), void 0)] }), void 0)] }, void 0));
8
+ };
@@ -1,16 +1,18 @@
1
- /** @jsx jsx */
2
1
  /** @jsxFrag React.Fragment */
3
2
  import { Theme } from 'theme-ui';
4
3
  import React from 'react';
4
+ import { MDXProvider } from '@mdx-js/react';
5
5
  import { ShellHeader } from './header.component';
6
6
  declare const BrandingSlot: ({ children }: {
7
- children: any;
8
- }) => any;
7
+ children?: React.ReactNode;
8
+ }) => import("theme-ui/jsx-runtime").JSX.Element;
9
9
  declare const ContentsSlot: React.FC<React.ComponentProps<typeof ShellHeader>>;
10
10
  export declare const Shell: React.FC<{
11
11
  theme?: Theme;
12
+ variant?: string;
12
13
  }> & {
13
14
  Branding: typeof BrandingSlot;
14
15
  Contents: typeof ContentsSlot;
16
+ mdxComponents: React.ComponentProps<typeof MDXProvider>['components'];
15
17
  };
16
18
  export {};
@@ -0,0 +1,40 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "theme-ui/jsx-runtime";
2
+ /** @jsxFrag React.Fragment */
3
+ import { Themed, ThemeProvider } from 'theme-ui';
4
+ import { Global } from '@emotion/react';
5
+ import React from 'react';
6
+ import { MDXProvider } from '@mdx-js/react';
7
+ import defaultTheme from '../../theme';
8
+ import { ShellHeader } from './header.component';
9
+ import { ScrollTop } from '../scroll-top';
10
+ import { Heading2 } from '../toc';
11
+ const BrandingSlot = ({ children }) => {
12
+ return _jsx(_Fragment, { children: children }, void 0);
13
+ };
14
+ const ContentsSlot = ({ children, ...rest }) => {
15
+ return (_jsxs(_Fragment, { children: [_jsx(ShellHeader, Object.assign({}, rest), void 0), children || null] }, void 0));
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, variant = 'default' }) => {
20
+ var _a, _b, _c, _d, _e;
21
+ const branding = getBranding(children);
22
+ const contents = getContents(children);
23
+ return (_jsx(ThemeProvider, Object.assign({ theme: theme }, { children: _jsxs(Themed.root, Object.assign({ sx: {
24
+ variant: `styles.shell.${variant}.Root`,
25
+ } }, { children: [_jsx(Global, { styles: {
26
+ ...((_b = (_a = theme.styles.global) === null || _a === void 0 ? void 0 : _a[variant]) !== null && _b !== void 0 ? _b : {}),
27
+ body: { margin: 0, overflowX: 'hidden', ...((_e = (_d = (_c = theme.styles.global) === null || _c === void 0 ? void 0 : _c[variant]) === null || _d === void 0 ? void 0 : _d.body) !== null && _e !== void 0 ? _e : {}) },
28
+ } }, void 0),
29
+ _jsx("aside", {}, void 0),
30
+ _jsxs("main", { children: [_jsx(MDXProvider, Object.assign({ components: Shell.mdxComponents, disableParentContext: true }, { children: contents }), void 0),
31
+ branding ? _jsx(ScrollTop, { children: branding.props.children ? branding : null }, void 0) : null] }, void 0)] }), void 0) }), void 0));
32
+ };
33
+ Shell.defaultProps = {
34
+ theme: defaultTheme,
35
+ };
36
+ Shell.mdxComponents = {
37
+ h2: Heading2,
38
+ };
39
+ Shell.Branding = BrandingSlot;
40
+ Shell.Contents = ContentsSlot;
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ export declare const Heading2: ({ children, id, className, ...forwarded }: React.BaseHTMLAttributes<HTMLElement> & {
3
+ children: string;
4
+ variant: string;
5
+ }) => import("theme-ui/jsx-runtime").JSX.Element;
@@ -0,0 +1,36 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "theme-ui/jsx-runtime";
2
+ import { useCallback, useMemo, useState } from 'react';
3
+ import classnames from 'classnames';
4
+ import { faLink } from '@fortawesome/free-solid-svg-icons';
5
+ import { faClipboard } from '@fortawesome/free-regular-svg-icons';
6
+ import * as styles from './toc.style.pcss';
7
+ import { Icon } from '../icon.component';
8
+ export const Heading2 = ({ children, id, className, ...forwarded }) => {
9
+ const anchorRef = id !== null && id !== void 0 ? id : children.toLowerCase().replace(/\s/, '-');
10
+ const url = useMemo(() => {
11
+ const modifiedUrl = new URL(window.location.href);
12
+ modifiedUrl.hash = anchorRef;
13
+ return modifiedUrl;
14
+ }, [anchorRef]);
15
+ const [copied, setCopied] = useState(false);
16
+ const handleCopyLink = useCallback(() => {
17
+ navigator.clipboard.writeText(url.toString());
18
+ setCopied(true);
19
+ }, [url, setCopied]);
20
+ const handleKeyboardCopy = useCallback((e) => {
21
+ const hasModifier = e.altKey || e.ctrlKey || e.metaKey || e.shiftKey;
22
+ const isActionKey = e.key == ' ' || e.key == 'Enter';
23
+ if (!hasModifier && isActionKey) {
24
+ e.stopPropagation();
25
+ e.preventDefault();
26
+ handleCopyLink();
27
+ }
28
+ }, [handleCopyLink]);
29
+ const iconConfig = useMemo(() => ({ ...(copied ? faClipboard : faLink), namespace: 'fa5' }), [copied]);
30
+ const handleCopyReset = useCallback(() => {
31
+ setCopied(false);
32
+ }, [setCopied]);
33
+ return (_jsx("h2", Object.assign({ className: classnames(styles.heading, className) }, forwarded, { tabIndex: 0, onKeyDown: handleKeyboardCopy, onBlur: handleCopyReset,
34
+ // eslint-disable-next-line jsx-a11y/no-noninteractive-element-to-interactive-role
35
+ role: "link" }, { children: _jsxs("a", Object.assign({ id: anchorRef, className: styles.anchor, href: url.toString() }, { children: [children, _jsx(Icon, { onClick: copied ? undefined : handleCopyLink, config: iconConfig, className: classnames(styles.icon, { [styles.copied]: copied }), title: copied ? 'Copied to clipboard!' : 'Copy link' }, void 0)] }), void 0) }), void 0));
36
+ };
@@ -0,0 +1,2 @@
1
+ export * from './toc.component';
2
+ export * from './heading2.component';
@@ -0,0 +1,2 @@
1
+ export * from './toc.component';
2
+ export * from './heading2.component';
@@ -0,0 +1,9 @@
1
+ interface TocItemProps {
2
+ heading: string;
3
+ to?: string;
4
+ explanation?: string;
5
+ }
6
+ export declare const Toc: ({ headings }: {
7
+ headings: TocItemProps[];
8
+ }) => import("theme-ui/jsx-runtime").JSX.Element;
9
+ export {};
@@ -0,0 +1,6 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "theme-ui/jsx-runtime";
2
+ const TocItem = ({ heading, to, explanation }) => {
3
+ const anchor = to !== null && to !== void 0 ? to : heading;
4
+ return (_jsxs("li", { children: [_jsx("a", Object.assign({ href: `#${anchor.toLowerCase().replace(/\s/, '-')}` }, { children: _jsx("b", { children: heading }, void 0) }), void 0), explanation ? ': ' : '', explanation] }, void 0));
5
+ };
6
+ export const Toc = ({ headings }) => (_jsx("ul", { children: headings.map((h, idx) => (_jsx(TocItem, Object.assign({}, h), idx))) }, void 0));
@@ -0,0 +1,70 @@
1
+ .heading {
2
+ display: flex;
3
+ justify-content: flex-start;
4
+
5
+ .anchor {
6
+ cursor: default;
7
+ display: flex;
8
+ flex-wrap: nowrap;
9
+ align-items: center;
10
+ gap: 0.5rem;
11
+ border: none;
12
+ outline: none;
13
+
14
+ .icon {
15
+ visibility: hidden;
16
+ font-size: 1rem;
17
+
18
+ &:hover {
19
+ color: var(--theme-ui-colors-highlight, inherit);
20
+
21
+ &.copied {
22
+ color: inherit;
23
+ }
24
+ }
25
+ }
26
+
27
+ &:hover,
28
+ &:focus,
29
+ &:active,
30
+ &:focus-within,
31
+ &:focus-visible {
32
+ outline: none;
33
+ color: inherit;
34
+ /* stylelint-disable-next-line unit-allowed-list */
35
+ box-shadow: 0 1px 0 0;
36
+
37
+ .icon {
38
+ visibility: visible;
39
+ cursor: pointer;
40
+
41
+ &.copied {
42
+ cursor: inherit;
43
+ }
44
+ }
45
+ }
46
+ }
47
+
48
+ &:hover,
49
+ &:focus,
50
+ &:active,
51
+ &:focus-within,
52
+ &:focus-visible {
53
+ outline: none;
54
+
55
+ .anchor {
56
+ color: inherit;
57
+ /* stylelint-disable-next-line unit-allowed-list */
58
+ box-shadow: 0 1px 0 0;
59
+
60
+ .icon {
61
+ visibility: visible;
62
+ cursor: pointer;
63
+
64
+ &.copied {
65
+ cursor: inherit;
66
+ }
67
+ }
68
+ }
69
+ }
70
+ }
@@ -0,0 +1,4 @@
1
+ export const heading: string
2
+ export const icon: string
3
+ export const copied: string
4
+ export const anchor: string
package/index.d.ts CHANGED
@@ -1,3 +1,2 @@
1
- export * from './shell';
2
1
  export * from './components';
3
- export { default as defaultTheme } from './theme';
2
+ export { default as defaultTheme, ColorVariableNames, SizeVariableNames, FontVariableNames, variables as defaultThemeVariables, } from './theme';
package/index.js CHANGED
@@ -1,3 +1,2 @@
1
- export * from './shell';
2
1
  export * from './components';
3
- export { default as defaultTheme } from './theme';
2
+ export { default as defaultTheme, ColorVariableNames, SizeVariableNames, FontVariableNames, variables as defaultThemeVariables, } from './theme';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@enhanced-dom/slides",
3
- "version": "0.0.5",
3
+ "version": "0.0.7",
4
4
  "description": "Basic building blocks for html slides",
5
5
  "keywords": [],
6
6
  "repository": "https://github.com/enhanced-dom/slides.git",
@@ -8,40 +8,29 @@
8
8
  "author": "CD9B4A105290E17E0948E021DF4105107C88693C59C0B891CCC08366C51AEA990902A6A156AC87D88A2FC41422A5E1C3C4071F251F19441C4516000EC25F87DF",
9
9
  "main": "index.js",
10
10
  "dependencies": {
11
- "@emotion/react": "^11.4.0",
12
- "@enhanced-dom/fontawesome": "^0.0.2",
13
- "@enhanced-dom/icon": "^0.0.4",
14
- "@enhanced-dom/react": "^0.0.6",
15
- "@fontsource/montserrat": "^4.4.5",
16
- "@fortawesome/free-regular-svg-icons": "^5.15.3",
17
- "@fortawesome/free-solid-svg-icons": "^5.15.3",
18
- "@theme-ui/typography": "^0.10.0",
11
+ "@emotion/react": "^11.9.0",
12
+ "@enhanced-dom/fontawesome": "^0.0.5",
13
+ "@enhanced-dom/gatsby-waves": "^0.0.2",
14
+ "@enhanced-dom/icon": "^0.0.9",
15
+ "@enhanced-dom/react": "^0.0.17",
16
+ "@fontsource/montserrat": "^4.5.10",
17
+ "@fontsource/noto-serif": "^5.0.15",
18
+ "@mdx-js/react": "^2.3.0",
19
+ "@theme-ui/typography": "^0.14.5",
19
20
  "deepmerge": "^4.2.2",
20
- "gatsby-theme-blog": "^3.0.0",
21
- "gatsby-theme-waves": "^0.1.6",
22
21
  "lodash.pick": "^4.4.0",
23
22
  "react-card-flip": "^1.1.1",
24
- "theme-ui": "^0.9.1",
25
23
  "typography-theme-wordpress-2016": "^0.16.19"
26
24
  },
27
25
  "devDependencies": {
28
- "@enhanced-dom/lint": "^0.0.7",
29
- "@enhanced-dom/webpack": "^0.0.6",
26
+ "@enhanced-dom/lint": "^0.0.9",
27
+ "@enhanced-dom/webpack": "^0.0.11",
30
28
  "@types/lodash.pick": "^4.4.6",
31
29
  "@types/react": "^17.0.8",
32
- "@types/react-dom": "^17.0.5",
33
- "copyfiles": "2.4.1",
34
- "rimraf": "3.0.2",
35
- "typescript": "4.2.2"
36
- },
37
- "overrides": {
38
- "react": "^17.0.2",
39
- "react-dom": "^17.0.2",
40
- "theme-ui": "^0.9.1",
41
- "gatsby": "^3.0.0"
30
+ "@types/react-dom": "^17.0.5"
42
31
  },
43
32
  "engines": {
44
33
  "node": ">=14.17.0",
45
- "npm": ">=8.0.0"
34
+ "npm": ">=9.0.0"
46
35
  }
47
36
  }
package/theme.d.ts CHANGED
@@ -1,47 +1,48 @@
1
1
  import '@fontsource/montserrat';
2
+ import '@fontsource/noto-serif';
2
3
  export declare enum ColorVariableNames {
3
- BACKGROUND = "background",
4
- TEXT = "text",
5
- DARK_BACKGROUND = "darkBackground",
6
- LIGHT_TEXT = "lightText",
4
+ LIGHT_BACKGROUND = "light-background",
5
+ DARK_TEXT = "dark-text",
6
+ DARK_BACKGROUND = "dark-background",
7
+ LIGHT_TEXT = "light-text",
7
8
  HIGHLIGHT = "highlight",
8
- MUTED = "muted",
9
- LIGHTER_BLUE = "lighterBlue",
10
- LIGHT_BLUE = "lightBlue",
11
- HEADING = "heading"
9
+ CODE_KEYWORDS = "code-keywords"
12
10
  }
13
11
  export declare enum SizeVariableNames {
14
- CONTENT = "content",
15
- INNER_MARGIN = "innerMargin",
16
- CENTRAL_GAP = "centralGap",
12
+ CONTENT_WIDTH = "content",
13
+ SECTION_SLEEVE = "sectionSleeve",
17
14
  TOP_MARGIN = "topMargin",
18
- FULL_CONTENT = "fullContent",
19
- FULL_CONTENT_WIDTH = "fullContentWidth"
15
+ SECTION_GAP = "sectionGap",
16
+ PARAGRAPH_GAP = "paragraphGap",
17
+ STEP_HEIGHT = "stepHeight",
18
+ ASIDE_WIDTH = "asideWidth"
20
19
  }
21
20
  export declare enum FontVariableNames {
22
21
  BODY = "body",
22
+ HEADING = "heading",
23
23
  MONOSPACE = "monospace"
24
24
  }
25
25
  export declare const variables: {
26
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;
27
+ "light-background": string;
28
+ "dark-text": string;
29
+ "dark-background": string;
30
+ "light-text": string;
31
+ highlight: string;
32
+ "code-keywords": string;
35
33
  };
36
34
  sizes: {
37
- content: number;
38
- innerMargin: number;
39
- topMargin: number;
40
- centralGap: number;
41
- fullContentWidth: number;
35
+ content: string;
36
+ sectionSleeve: string;
37
+ topMargin: string;
38
+ sectionGap: string;
39
+ paragraphGap: string;
40
+ stepHeight: string;
41
+ asideWidth: string;
42
42
  };
43
43
  fonts: {
44
44
  body: string;
45
+ heading: string;
45
46
  monospace: string;
46
47
  };
47
48
  };
package/theme.js CHANGED
@@ -3,203 +3,221 @@ import { toTheme } from '@theme-ui/typography';
3
3
  import typography from 'typography-theme-wordpress-2016';
4
4
  import merge from 'deepmerge';
5
5
  import '@fontsource/montserrat';
6
+ import '@fontsource/noto-serif';
6
7
  import pick from 'lodash.pick';
7
- // @ts-nocheck
8
- import blogTheme from 'gatsby-theme-blog/src/gatsby-plugin-theme-ui/components';
9
8
  const typographyTheme = toTheme(typography);
10
9
  export var ColorVariableNames;
11
10
  (function (ColorVariableNames) {
12
- ColorVariableNames["BACKGROUND"] = "background";
13
- ColorVariableNames["TEXT"] = "text";
14
- ColorVariableNames["DARK_BACKGROUND"] = "darkBackground";
15
- ColorVariableNames["LIGHT_TEXT"] = "lightText";
11
+ ColorVariableNames["LIGHT_BACKGROUND"] = "light-background";
12
+ ColorVariableNames["DARK_TEXT"] = "dark-text";
13
+ ColorVariableNames["DARK_BACKGROUND"] = "dark-background";
14
+ ColorVariableNames["LIGHT_TEXT"] = "light-text";
16
15
  ColorVariableNames["HIGHLIGHT"] = "highlight";
17
- ColorVariableNames["MUTED"] = "muted";
18
- ColorVariableNames["LIGHTER_BLUE"] = "lighterBlue";
19
- ColorVariableNames["LIGHT_BLUE"] = "lightBlue";
20
- ColorVariableNames["HEADING"] = "heading";
16
+ ColorVariableNames["CODE_KEYWORDS"] = "code-keywords";
21
17
  })(ColorVariableNames || (ColorVariableNames = {}));
22
18
  export var SizeVariableNames;
23
19
  (function (SizeVariableNames) {
24
- SizeVariableNames["CONTENT"] = "content";
25
- SizeVariableNames["INNER_MARGIN"] = "innerMargin";
26
- SizeVariableNames["CENTRAL_GAP"] = "centralGap";
20
+ SizeVariableNames["CONTENT_WIDTH"] = "content";
21
+ SizeVariableNames["SECTION_SLEEVE"] = "sectionSleeve";
27
22
  SizeVariableNames["TOP_MARGIN"] = "topMargin";
28
- SizeVariableNames["FULL_CONTENT"] = "fullContent";
29
- SizeVariableNames["FULL_CONTENT_WIDTH"] = "fullContentWidth";
23
+ SizeVariableNames["SECTION_GAP"] = "sectionGap";
24
+ SizeVariableNames["PARAGRAPH_GAP"] = "paragraphGap";
25
+ SizeVariableNames["STEP_HEIGHT"] = "stepHeight";
26
+ SizeVariableNames["ASIDE_WIDTH"] = "asideWidth";
30
27
  })(SizeVariableNames || (SizeVariableNames = {}));
31
28
  export var FontVariableNames;
32
29
  (function (FontVariableNames) {
33
30
  FontVariableNames["BODY"] = "body";
31
+ FontVariableNames["HEADING"] = "heading";
34
32
  FontVariableNames["MONOSPACE"] = "monospace";
35
33
  })(FontVariableNames || (FontVariableNames = {}));
36
34
  export const variables = {
37
35
  colors: {
38
- [ColorVariableNames.BACKGROUND]: '#f1f5f8',
39
- [ColorVariableNames.TEXT]: '#3D4851',
36
+ [ColorVariableNames.LIGHT_BACKGROUND]: '#f1f5f8',
37
+ [ColorVariableNames.DARK_TEXT]: '#3D4851',
40
38
  [ColorVariableNames.DARK_BACKGROUND]: '#3D4851',
41
39
  [ColorVariableNames.LIGHT_TEXT]: 'white',
42
- [ColorVariableNames.MUTED]: '#3D4851',
43
- [ColorVariableNames.LIGHTER_BLUE]: '#ebfcf6',
44
- [ColorVariableNames.HEADING]: '#e2001a',
45
- [ColorVariableNames.LIGHT_BLUE]: '#aaf6d9',
40
+ [ColorVariableNames.HIGHLIGHT]: '#e2001a',
41
+ [ColorVariableNames.CODE_KEYWORDS]: '#aaf6d9',
46
42
  },
47
43
  sizes: {
48
- [SizeVariableNames.CONTENT]: 420,
49
- [SizeVariableNames.INNER_MARGIN]: 85,
50
- [SizeVariableNames.TOP_MARGIN]: 256,
51
- [SizeVariableNames.CENTRAL_GAP]: 85 * 2,
52
- [SizeVariableNames.FULL_CONTENT_WIDTH]: 85 * 2 + 420,
44
+ [SizeVariableNames.CONTENT_WIDTH]: '420px',
45
+ [SizeVariableNames.SECTION_SLEEVE]: '85px',
46
+ [SizeVariableNames.TOP_MARGIN]: '256px',
47
+ [SizeVariableNames.SECTION_GAP]: '28px',
48
+ [SizeVariableNames.PARAGRAPH_GAP]: '20px',
49
+ [SizeVariableNames.STEP_HEIGHT]: '400px',
50
+ [SizeVariableNames.ASIDE_WIDTH]: '40vw',
53
51
  },
54
52
  fonts: {
55
53
  [FontVariableNames.BODY]: 'Montserrat, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, sans-serif',
56
- [FontVariableNames.MONOSPACE]: `Consolas, Menlo, Monaco, source-code-pro, Courier New, monospace`,
54
+ [FontVariableNames.HEADING]: 'Noto Serif, serif',
55
+ [FontVariableNames.MONOSPACE]: 'Consolas, Menlo, Monaco, source-code-pro, Courier New, monospace',
57
56
  },
58
57
  };
59
58
  const theme = merge.all([
60
- blogTheme,
61
59
  typographyTheme,
62
60
  {
63
61
  colors: variables.colors,
62
+ breakpoints: ['1000px'],
64
63
  space: {
65
64
  ...typographyTheme.space,
66
- ...pick(variables.sizes, [
67
- SizeVariableNames.INNER_MARGIN,
68
- SizeVariableNames.TOP_MARGIN,
69
- SizeVariableNames.FULL_CONTENT_WIDTH,
70
- SizeVariableNames.CENTRAL_GAP,
71
- ]),
65
+ ...variables.sizes,
72
66
  },
73
- sizes: pick(variables.sizes, [SizeVariableNames.CONTENT]),
67
+ sizes: pick(variables.sizes, [
68
+ SizeVariableNames.CONTENT_WIDTH,
69
+ SizeVariableNames.ASIDE_WIDTH,
70
+ SizeVariableNames.SECTION_SLEEVE,
71
+ SizeVariableNames.TOP_MARGIN,
72
+ ]),
74
73
  fonts: variables.fonts,
75
74
  styles: {
76
- root: {
77
- fontFamily: FontVariableNames.BODY,
78
- },
79
- a: {
80
- color: 'inherit',
81
- textDecoration: 'none',
82
- borderBottom: '1px solid',
83
- borderColor: ColorVariableNames.MUTED,
84
- },
85
- li: {
86
- marginBottom: '4px',
87
- code: {
88
- fontSize: `inherit`,
75
+ global: {
76
+ body: {
77
+ fontFamily: FontVariableNames.BODY,
89
78
  },
90
- },
91
- pre: {
92
- variant: `prism`,
93
- fontFamily: FontVariableNames.MONOSPACE,
94
- tabSize: 2,
95
- hyphens: `none`,
96
- overflow: `auto`,
97
- borderRadius: 10,
98
- p: 0,
99
- pl: 2,
100
- color: ColorVariableNames.TEXT,
101
- backgroundColor: ColorVariableNames.BACKGROUND,
102
- marginBottom: '28px',
103
- whiteSpace: 'pre-wrap',
104
- },
105
- code: {
106
- fontFamily: FontVariableNames.MONOSPACE,
107
- fontSize: `inherit`,
108
- },
109
- h1: {
110
- fontStyle: 'italic',
111
- color: ColorVariableNames.HEADING,
112
- },
113
- h2: {
114
- marginTop: '60px',
115
- fontStyle: 'italic',
116
- },
117
- h3: {
118
- marginTop: '4px',
119
- },
120
- inlineCode: {
121
- borderRadius: `0.3em`,
122
- paddingTop: `0.15em`,
123
- paddingBottom: `0.05em`,
124
- paddingX: `0.2em`,
125
- },
126
- hr: {
127
- borderColor: ColorVariableNames.MUTED,
128
- },
129
- p: {
130
- marginBottom: '20px',
131
- marginTop: '20px',
132
- code: {
133
- fontSize: `inherit`,
134
- },
135
- },
136
- blockquote: {
137
- color: `inherit`,
138
- borderLeftColor: `inherit`,
139
- opacity: 0.8,
140
- '&.translation': {
141
- fontSize: `1em`,
79
+ img: {
80
+ objectFit: 'contain',
81
+ margin: 0,
82
+ maxWidth: '100%',
83
+ maxHeight: '100%',
142
84
  },
143
85
  },
144
86
  waves: {
145
87
  default: {
146
88
  Wave: {
147
- width: ['100%', variables.sizes[SizeVariableNames.CONTENT] * 2 + variables.sizes[SizeVariableNames.CENTRAL_GAP]],
148
- // marginTop: "40px",
149
- marginLeft: [0, -(variables.sizes[SizeVariableNames.CONTENT] + variables.sizes[SizeVariableNames.CENTRAL_GAP])],
150
- marginBottom: '28px',
89
+ width: '100vw',
90
+ marginLeft: [
91
+ 0,
92
+ `calc(-${variables.sizes[SizeVariableNames.ASIDE_WIDTH]} - ${variables.sizes[SizeVariableNames.SECTION_SLEEVE]})`,
93
+ ],
94
+ marginBottom: SizeVariableNames.SECTION_GAP,
151
95
  position: 'relative',
152
96
  display: ['block', 'flex'],
153
97
  },
154
98
  ScrollerContainer: {
155
- paddingTop: ['80px', 0],
156
- width: ['auto', SizeVariableNames.CONTENT],
157
- marginLeft: [0, SizeVariableNames.CENTRAL_GAP],
99
+ paddingTop: [SizeVariableNames.SECTION_SLEEVE, 0],
100
+ paddingRight: SizeVariableNames.SECTION_SLEEVE,
101
+ paddingBottom: [SizeVariableNames.SECTION_SLEEVE, 0],
102
+ paddingLeft: [SizeVariableNames.SECTION_SLEEVE, 0],
103
+ width: '100%',
104
+ marginLeft: [0, SizeVariableNames.SECTION_SLEEVE],
158
105
  },
159
106
  ScrollerStep: {
160
107
  position: 'relative',
161
108
  padding: 0,
162
- minHeight: '400px',
109
+ minHeight: SizeVariableNames.STEP_HEIGHT,
163
110
  display: 'flex',
164
111
  alignItems: 'center',
165
112
  borderLeft: 0,
166
113
  },
167
114
  ScrollerProgress: {
168
- backgroundColor: ColorVariableNames.MUTED,
115
+ backgroundColor: ColorVariableNames.DARK_TEXT,
169
116
  borderRadius: '3px',
170
117
  position: 'absolute',
171
118
  left: '-24px',
172
119
  },
173
120
  StickerContainer: {
174
- width: ['100vw', SizeVariableNames.CONTENT],
175
- marginLeft: ['calc(50% - 50vw)', 0],
176
- position: ['sticky', 'static'],
177
- top: [0, 'auto'],
121
+ minWidth: ['100vw', SizeVariableNames.ASIDE_WIDTH],
122
+ maxWidth: ['100vw', SizeVariableNames.ASIDE_WIDTH],
123
+ position: 'sticky',
124
+ top: ['0', '10vh'],
178
125
  zIndex: [1, 'auto'],
179
- height: ['50vh', 'auto'],
180
- paddingRight: [0, SizeVariableNames.INNER_MARGIN],
126
+ height: ['30vh', 'auto'],
127
+ maxHeight: ['50vh', '80vh'],
128
+ display: 'flex',
129
+ flexDirection: ['row', 'column'],
130
+ justifyContent: 'space-around',
131
+ alignItems: 'center',
181
132
  backgroundColor: ColorVariableNames.DARK_BACKGROUND,
182
133
  color: ColorVariableNames.LIGHT_TEXT,
183
- },
184
- Sticker: {
185
- position: ['static', 'sticky'],
186
- width: '100%',
187
- height: ['100%', '80vh'],
188
- maxHeight: ['100%', '80vh'],
189
- top: ['auto', '2rem'],
190
- marginLeft: [0, variables.sizes.innerMargin],
134
+ paddingRight: SizeVariableNames.SECTION_SLEEVE,
135
+ paddingLeft: SizeVariableNames.SECTION_SLEEVE,
136
+ a: {
137
+ border: 'none',
138
+ },
191
139
  },
192
140
  StickerStep: {
193
- position: 'absolute',
141
+ position: 'relative',
194
142
  height: '100%',
195
143
  width: '100%',
196
144
  display: 'flex',
197
145
  justifyContent: 'center',
198
146
  },
199
147
  // this is used to select the active scroller step
148
+ // 0.8 the step that is at 80% the screen height
200
149
  // 0.5 selects the step that is at half the screen height
201
- // 0.7 the step that is at 70% the screen height
202
- focus: [0.7, 0.5],
150
+ focus: [0.8, 0.5],
151
+ },
152
+ },
153
+ shell: {
154
+ default: {
155
+ Root: {
156
+ display: 'flex',
157
+ width: '100vw',
158
+ h1: {
159
+ marginLeft: [SizeVariableNames.SECTION_SLEEVE, 0],
160
+ color: ColorVariableNames.HIGHLIGHT,
161
+ },
162
+ h2: {
163
+ marginLeft: [SizeVariableNames.SECTION_SLEEVE, 0],
164
+ marginTop: '60px',
165
+ },
166
+ h3: {
167
+ marginLeft: [SizeVariableNames.SECTION_SLEEVE, 0],
168
+ marginTop: '4px',
169
+ },
170
+ hr: {
171
+ borderColor: ColorVariableNames.DARK_TEXT,
172
+ },
173
+ a: {
174
+ color: 'inherit',
175
+ textDecoration: 'none',
176
+ borderBottom: '1px solid',
177
+ borderColor: ColorVariableNames.DARK_TEXT,
178
+ '&:visited': {
179
+ color: 'inherit',
180
+ },
181
+ '&:hover': {
182
+ color: ColorVariableNames.HIGHLIGHT,
183
+ },
184
+ },
185
+ aside: {
186
+ bg: ColorVariableNames.DARK_BACKGROUND,
187
+ color: ColorVariableNames.LIGHT_TEXT,
188
+ minWidth: [0, SizeVariableNames.ASIDE_WIDTH],
189
+ maxWidth: ['100vw', SizeVariableNames.ASIDE_WIDTH],
190
+ minHeight: '100vh',
191
+ },
192
+ main: {
193
+ py: [5, SizeVariableNames.TOP_MARGIN],
194
+ pl: [0, SizeVariableNames.SECTION_SLEEVE],
195
+ bg: ColorVariableNames.LIGHT_BACKGROUND,
196
+ color: ColorVariableNames.DARK_TEXT,
197
+ width: ['100vw', '100%'],
198
+ mx: ['auto', 0],
199
+ },
200
+ header: {
201
+ position: 'relative',
202
+ paddingX: [SizeVariableNames.SECTION_SLEEVE, 0],
203
+ display: 'flex',
204
+ flexDirection: ['row-reverse', 'column'],
205
+ alignItems: ['center', 'flex-start'],
206
+ justifyContent: ['space-between', 'start'],
207
+ },
208
+ },
209
+ Author: {
210
+ display: 'flex',
211
+ flexDirection: 'column',
212
+ paddingTop: [1, undefined],
213
+ },
214
+ Title: {
215
+ position: ['relative', 'static'],
216
+ width: '100%',
217
+ height: ['auto', '100%'],
218
+ right: ['auto', `calc(100vw - ${variables.sizes[SizeVariableNames.CONTENT_WIDTH]}})`],
219
+ color: ['text', ColorVariableNames.LIGHT_TEXT],
220
+ },
203
221
  },
204
222
  },
205
223
  CodeSurfer: {
@@ -207,29 +225,17 @@ const theme = merge.all([
207
225
  color: ColorVariableNames.LIGHT_TEXT,
208
226
  backgroundColor: ColorVariableNames.DARK_BACKGROUND,
209
227
  },
210
- code: {
211
- color: ColorVariableNames.LIGHT_TEXT,
212
- backgroundColor: ColorVariableNames.DARK_BACKGROUND,
213
- },
214
228
  tokens: {
229
+ 'builtin changed keyword punctuation operator tag deleted string attr-value char number inserted': {
230
+ color: ColorVariableNames.CODE_KEYWORDS,
231
+ },
215
232
  'comment cdata doctype': {
216
233
  fontStyle: 'italic',
217
234
  },
218
- 'builtin changed keyword punctuation operator tag deleted string attr-value char number inserted': {
219
- color: ColorVariableNames.LIGHT_BLUE,
220
- },
221
235
  },
222
236
  },
223
237
  },
224
238
  },
225
239
  ]);
226
- theme.breakpoints = ['1000px'];
227
- theme.prism = {
228
- '.builtin, .changed, .keyword, .punctuation, .operator, .tag, .deleted, .string, .attr-value, .char, .number, .inserted': {
229
- color: '#0f8f5e',
230
- },
231
- '.comment, .cdata, .doctype': {
232
- fontStyle: 'italic',
233
- },
234
- };
240
+ theme.mergeWith = (otherTheme) => merge.all([theme, otherTheme]);
235
241
  export default theme;
@@ -1,8 +0,0 @@
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
- }
@@ -1,28 +0,0 @@
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;
@@ -1,5 +0,0 @@
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
- }
@@ -1,27 +0,0 @@
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
- }
@@ -1,15 +0,0 @@
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 {};
@@ -1,14 +0,0 @@
1
- import React from 'react';
2
- const Heading = ({ heading }) => (React.createElement("h2", null,
3
- heading,
4
- React.createElement("a", { href: `#${heading.toLowerCase().replace(/\s/, '-')}`, 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;
@@ -1,10 +0,0 @@
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
- }
@@ -1,37 +0,0 @@
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
- }
@@ -1,7 +0,0 @@
1
- /** @jsx jsx */
2
- import { jsx } from 'theme-ui';
3
- export declare const ShellHeader: ({ title, author, date }: {
4
- title: string;
5
- author: string;
6
- date: string;
7
- }) => jsx.JSX.Element;
@@ -1,24 +0,0 @@
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
- };
@@ -1,13 +0,0 @@
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
- export declare const Icon: import("react").ComponentType<IconAttributes> & {
11
- renderer: import("@enhanced-dom/icon").MultiIconRenderer;
12
- } & Record<string, AnalyserNode>;
13
- export {};
@@ -1,2 +0,0 @@
1
- import React from 'react';
2
- export declare const ScrollTop: React.FunctionComponent;
@@ -1,39 +0,0 @@
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.pcss';
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
- const scrollOnKey = (e) => {
16
- if (e.altKey || e.shiftKey || e.ctrlKey || e.key !== 'Enter') {
17
- return;
18
- }
19
- e.stopPropagation();
20
- e.preventDefault();
21
- scrollToTop();
22
- };
23
- export const ScrollTop = ({ children }) => {
24
- const [isFlipped, setFlipped] = React.useState(false);
25
- const showButton = React.useCallback(() => {
26
- if (getBodyScroll()) {
27
- setFlipped(true);
28
- }
29
- }, [setFlipped]);
30
- const showFront = React.useCallback(() => {
31
- setFlipped(false);
32
- }, [setFlipped]);
33
- const buttonContents = children ? (React.createElement(ReactCardFlip, { isFlipped: isFlipped, flipDirection: "horizontal" },
34
- React.createElement("div", null, children),
35
- React.createElement("div", { className: styles.brandingBack },
36
- React.createElement(Icon, { config: { ...faArrowAltCircleUp, namespace: 'fa5' } })))) : (React.createElement("div", { className: styles.brandingBack },
37
- React.createElement(Icon, { config: { ...faArrowAltCircleUp, namespace: 'fa5' } })));
38
- return (React.createElement("div", { className: styles.branding, tabIndex: 0, role: "button", onClick: scrollToTop, onFocus: showButton, onBlur: showFront, onMouseEnter: showButton, onMouseLeave: showFront, onKeyPress: scrollOnKey }, buttonContents));
39
- };
@@ -1,25 +0,0 @@
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
- }
@@ -1,2 +0,0 @@
1
- export const branding: string;
2
- export const brandingBack: string;
@@ -1,51 +0,0 @@
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;
File without changes
File without changes
File without changes
File without changes