@enhanced-dom/slides 0.0.6 → 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 (32) hide show
  1. package/components/icon.component.d.ts +8 -0
  2. package/components/{shell/scroll-top/icon.component.js → icon.component.js} +1 -2
  3. package/components/index.d.ts +1 -1
  4. package/components/index.js +1 -1
  5. package/components/scroll-top/scroll-top.component.d.ts +4 -0
  6. package/components/{shell/scroll-top → scroll-top}/scroll-top.component.js +4 -4
  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 +3 -1
  10. package/components/shell/header.component.js +5 -16
  11. package/components/shell/shell.component.d.ts +5 -2
  12. package/components/shell/shell.component.js +17 -21
  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.component.js → toc/toc.component.js} +1 -3
  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 -1
  22. package/index.js +1 -1
  23. package/package.json +10 -8
  24. package/theme.d.ts +27 -26
  25. package/theme.js +148 -141
  26. package/components/shell/scroll-top/icon.component.d.ts +0 -13
  27. package/components/shell/scroll-top/scroll-top.component.d.ts +0 -2
  28. package/components/shell/scroll-top/scroll-top.style.pcss +0 -25
  29. package/components/shell/scroll-top/scroll-top.style.pcss.d.ts +0 -2
  30. package/components/toc.component.d.ts +0 -14
  31. /package/components/{shell/scroll-top → scroll-top}/index.d.ts +0 -0
  32. /package/components/{shell/scroll-top → scroll-top}/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,2 +1,2 @@
1
- export * from './toc.component';
1
+ export * from './toc';
2
2
  export * from './shell';
@@ -1,2 +1,2 @@
1
- export * from './toc.component';
1
+ export * from './toc';
2
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;
@@ -3,7 +3,7 @@ import React from 'react';
3
3
  import ReactCardFlip from 'react-card-flip';
4
4
  import { faArrowAltCircleUp } from '@fortawesome/free-regular-svg-icons';
5
5
  import * as styles from './scroll-top.style.pcss';
6
- import { Icon } from './icon.component';
6
+ import { Icon } from '../icon.component';
7
7
  const getBodyScroll = () => {
8
8
  return document.body.scrollTop !== 0 || document.documentElement.scrollTop !== 0;
9
9
  };
@@ -31,7 +31,7 @@ export const ScrollTop = ({ children }) => {
31
31
  const showFront = React.useCallback(() => {
32
32
  setFlipped(false);
33
33
  }, [setFlipped]);
34
- const buttonContents = children ? (_jsxs(ReactCardFlip, Object.assign({ isFlipped: isFlipped, flipDirection: "horizontal" }, { children: [_jsx("div", { children: children }, void 0),
35
- _jsx("div", Object.assign({ className: styles.brandingBack }, { children: _jsx(Icon, { config: { ...faArrowAltCircleUp, namespace: 'fa5' } }, void 0) }), void 0)] }), void 0)) : (_jsx("div", Object.assign({ className: styles.brandingBack }, { children: _jsx(Icon, { 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, onKeyPress: scrollOnKey }, { children: buttonContents }), void 0));
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
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
@@ -1,5 +1,7 @@
1
- export declare const ShellHeader: ({ title, author, date }: {
1
+ export declare const ShellHeader: ({ title, author, profileLink, date, variant, }: {
2
2
  title: string;
3
3
  author: string;
4
+ profileLink?: string;
4
5
  date: string;
6
+ variant?: string;
5
7
  }) => import("theme-ui/jsx-runtime").JSX.Element;
@@ -1,19 +1,8 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "theme-ui/jsx-runtime";
2
2
  import { Themed } from 'theme-ui';
3
- import { SizeVariableNames, ColorVariableNames } from '../../theme';
4
- export const ShellHeader = ({ title, author, date }) => {
5
- return (_jsxs("div", Object.assign({ sx: { position: 'relative' } }, { children: [_jsx("div", Object.assign({ sx: {
6
- position: ['static', 'absolute'],
7
- width: '100%',
8
- height: ['auto', '100%'],
9
- right: ['auto', SizeVariableNames.FULL_CONTENT_WIDTH],
10
- color: ['text', ColorVariableNames.LIGHT_TEXT],
11
- } }, { children: _jsx("div", Object.assign({ sx: {
12
- float: ['none', 'right'],
13
- display: ['block', 'inline-block'],
14
- textAlign: ['left', 'right'],
15
- } }, { children: _jsx(Themed.h1, Object.assign({ sx: { paddingBottom: '80px' } }, { children: title }), void 0) }), void 0) }), void 0),
16
- _jsx("div", { children: _jsxs(Themed.p, Object.assign({ sx: { paddingTop: 1 } }, { children: [_jsx(Themed.a, Object.assign({ href: "/", sx: { textDecoration: 'none', color: 'inherit', border: 'none' } }, { children: author }), void 0),
17
- _jsx("br", {}, void 0),
18
- _jsx("span", Object.assign({ sx: { fontSize: 1 } }, { children: date }), void 0)] }), void 0) }, void 0)] }), void 0));
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));
19
8
  };
@@ -1,15 +1,18 @@
1
1
  /** @jsxFrag React.Fragment */
2
2
  import { Theme } from 'theme-ui';
3
3
  import React from 'react';
4
+ import { MDXProvider } from '@mdx-js/react';
4
5
  import { ShellHeader } from './header.component';
5
6
  declare const BrandingSlot: ({ children }: {
6
- children: any;
7
- }) => any;
7
+ children?: React.ReactNode;
8
+ }) => import("theme-ui/jsx-runtime").JSX.Element;
8
9
  declare const ContentsSlot: React.FC<React.ComponentProps<typeof ShellHeader>>;
9
10
  export declare const Shell: React.FC<{
10
11
  theme?: Theme;
12
+ variant?: string;
11
13
  }> & {
12
14
  Branding: typeof BrandingSlot;
13
15
  Contents: typeof ContentsSlot;
16
+ mdxComponents: React.ComponentProps<typeof MDXProvider>['components'];
14
17
  };
15
18
  export {};
@@ -1,44 +1,40 @@
1
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "theme-ui/jsx-runtime";
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "theme-ui/jsx-runtime";
2
2
  /** @jsxFrag React.Fragment */
3
3
  import { Themed, ThemeProvider } from 'theme-ui';
4
4
  import { Global } from '@emotion/react';
5
5
  import React from 'react';
6
- import defaultTheme, { ColorVariableNames, SizeVariableNames } from '../../theme';
6
+ import { MDXProvider } from '@mdx-js/react';
7
+ import defaultTheme from '../../theme';
7
8
  import { ShellHeader } from './header.component';
8
- import { ScrollTop } from './scroll-top';
9
+ import { ScrollTop } from '../scroll-top';
10
+ import { Heading2 } from '../toc';
9
11
  const BrandingSlot = ({ children }) => {
10
- return children || null;
12
+ return _jsx(_Fragment, { children: children }, void 0);
11
13
  };
12
14
  const ContentsSlot = ({ children, ...rest }) => {
13
15
  return (_jsxs(_Fragment, { children: [_jsx(ShellHeader, Object.assign({}, rest), void 0), children || null] }, void 0));
14
16
  };
15
17
  const getBranding = (children) => React.Children.toArray(children).find((item) => { var _a; return ((_a = item) === null || _a === void 0 ? void 0 : _a.type) === BrandingSlot; });
16
18
  const getContents = (children) => React.Children.toArray(children).find((item) => { var _a; return ((_a = item) === null || _a === void 0 ? void 0 : _a.type) === ContentsSlot; });
17
- export const Shell = ({ children, theme, }) => {
19
+ export const Shell = ({ children, theme, variant = 'default' }) => {
20
+ var _a, _b, _c, _d, _e;
18
21
  const branding = getBranding(children);
19
22
  const contents = getContents(children);
20
23
  return (_jsx(ThemeProvider, Object.assign({ theme: theme }, { children: _jsxs(Themed.root, Object.assign({ sx: {
21
- display: 'flex',
22
- width: '100vw',
24
+ variant: `styles.shell.${variant}.Root`,
23
25
  } }, { children: [_jsx(Global, { styles: {
24
- body: { margin: 0, overflowX: 'hidden' },
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 : {}) },
25
28
  } }, void 0),
26
- _jsx("aside", { sx: {
27
- bg: ColorVariableNames.DARK_BACKGROUND,
28
- color: ColorVariableNames.LIGHT_TEXT,
29
- width: [0, '40vw'],
30
- minHeight: '100vh',
31
- } }, void 0),
32
- _jsx("div", Object.assign({ sx: { bg: ColorVariableNames.BACKGROUND, color: ColorVariableNames.TEXT, width: ['100vw', '60vw'] } }, { children: _jsxs("main", Object.assign({ sx: {
33
- py: [5, SizeVariableNames.TOP_MARGIN],
34
- pl: [0, SizeVariableNames.INNER_MARGIN],
35
- width: [SizeVariableNames.CONTENT, SizeVariableNames.CONTENT],
36
- maxWidth: ['80%', 'none'],
37
- mx: ['auto', 0],
38
- } }, { children: [contents, branding ? _jsx(ScrollTop, { children: branding }, void 0) : null] }), void 0) }), void 0)] }), void 0) }), 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));
39
32
  };
40
33
  Shell.defaultProps = {
41
34
  theme: defaultTheme,
42
35
  };
36
+ Shell.mdxComponents = {
37
+ h2: Heading2,
38
+ };
43
39
  Shell.Branding = BrandingSlot;
44
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 {};
@@ -1,8 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "theme-ui/jsx-runtime";
2
- const Heading = ({ heading }) => (_jsxs("h2", { children: [heading, _jsx("a", Object.assign({ href: `#${heading.toLowerCase().replace(/\s/, '-')}`, style: { display: 'none' }, id: heading.toLowerCase().replace(/\s/, '-') }, { children: '' }), void 0)] }, void 0));
3
2
  const TocItem = ({ heading, to, explanation }) => {
4
3
  const anchor = to !== null && to !== void 0 ? to : heading;
5
- return (_jsxs("li", { children: [_jsx("a", Object.assign({ href: `#${anchor.toLowerCase().replace(/\s/, '-')}` }, { children: _jsx("em", { children: heading }, void 0) }), void 0), explanation ? ': ' : '', explanation] }, void 0));
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));
6
5
  };
7
6
  export const Toc = ({ headings }) => (_jsx("ul", { children: headings.map((h, idx) => (_jsx(TocItem, Object.assign({}, h), idx))) }, void 0));
8
- Toc.Heading = Heading;
@@ -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,2 +1,2 @@
1
1
  export * from './components';
2
- export { default as defaultTheme } from './theme';
2
+ export { default as defaultTheme, ColorVariableNames, SizeVariableNames, FontVariableNames, variables as defaultThemeVariables, } from './theme';
package/index.js CHANGED
@@ -1,2 +1,2 @@
1
1
  export * from './components';
2
- 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.6",
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",
@@ -9,11 +9,13 @@
9
9
  "main": "index.js",
10
10
  "dependencies": {
11
11
  "@emotion/react": "^11.9.0",
12
- "@enhanced-dom/fontawesome": "^0.0.3",
13
- "@enhanced-dom/gatsby-waves": "^0.0.1",
14
- "@enhanced-dom/icon": "^0.0.4",
15
- "@enhanced-dom/react": "^0.0.6",
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
16
  "@fontsource/montserrat": "^4.5.10",
17
+ "@fontsource/noto-serif": "^5.0.15",
18
+ "@mdx-js/react": "^2.3.0",
17
19
  "@theme-ui/typography": "^0.14.5",
18
20
  "deepmerge": "^4.2.2",
19
21
  "lodash.pick": "^4.4.0",
@@ -21,14 +23,14 @@
21
23
  "typography-theme-wordpress-2016": "^0.16.19"
22
24
  },
23
25
  "devDependencies": {
24
- "@enhanced-dom/lint": "^0.0.7",
25
- "@enhanced-dom/webpack": "^0.0.7",
26
+ "@enhanced-dom/lint": "^0.0.9",
27
+ "@enhanced-dom/webpack": "^0.0.11",
26
28
  "@types/lodash.pick": "^4.4.6",
27
29
  "@types/react": "^17.0.8",
28
30
  "@types/react-dom": "^17.0.5"
29
31
  },
30
32
  "engines": {
31
33
  "node": ">=14.17.0",
32
- "npm": ">=8.0.0"
34
+ "npm": ">=9.0.0"
33
35
  }
34
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,202 +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
- import { blogTheme } from '@enhanced-dom/gatsby-waves';
8
8
  const typographyTheme = toTheme(typography);
9
9
  export var ColorVariableNames;
10
10
  (function (ColorVariableNames) {
11
- ColorVariableNames["BACKGROUND"] = "background";
12
- ColorVariableNames["TEXT"] = "text";
13
- ColorVariableNames["DARK_BACKGROUND"] = "darkBackground";
14
- 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";
15
15
  ColorVariableNames["HIGHLIGHT"] = "highlight";
16
- ColorVariableNames["MUTED"] = "muted";
17
- ColorVariableNames["LIGHTER_BLUE"] = "lighterBlue";
18
- ColorVariableNames["LIGHT_BLUE"] = "lightBlue";
19
- ColorVariableNames["HEADING"] = "heading";
16
+ ColorVariableNames["CODE_KEYWORDS"] = "code-keywords";
20
17
  })(ColorVariableNames || (ColorVariableNames = {}));
21
18
  export var SizeVariableNames;
22
19
  (function (SizeVariableNames) {
23
- SizeVariableNames["CONTENT"] = "content";
24
- SizeVariableNames["INNER_MARGIN"] = "innerMargin";
25
- SizeVariableNames["CENTRAL_GAP"] = "centralGap";
20
+ SizeVariableNames["CONTENT_WIDTH"] = "content";
21
+ SizeVariableNames["SECTION_SLEEVE"] = "sectionSleeve";
26
22
  SizeVariableNames["TOP_MARGIN"] = "topMargin";
27
- SizeVariableNames["FULL_CONTENT"] = "fullContent";
28
- 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";
29
27
  })(SizeVariableNames || (SizeVariableNames = {}));
30
28
  export var FontVariableNames;
31
29
  (function (FontVariableNames) {
32
30
  FontVariableNames["BODY"] = "body";
31
+ FontVariableNames["HEADING"] = "heading";
33
32
  FontVariableNames["MONOSPACE"] = "monospace";
34
33
  })(FontVariableNames || (FontVariableNames = {}));
35
34
  export const variables = {
36
35
  colors: {
37
- [ColorVariableNames.BACKGROUND]: '#f1f5f8',
38
- [ColorVariableNames.TEXT]: '#3D4851',
36
+ [ColorVariableNames.LIGHT_BACKGROUND]: '#f1f5f8',
37
+ [ColorVariableNames.DARK_TEXT]: '#3D4851',
39
38
  [ColorVariableNames.DARK_BACKGROUND]: '#3D4851',
40
39
  [ColorVariableNames.LIGHT_TEXT]: 'white',
41
- [ColorVariableNames.MUTED]: '#3D4851',
42
- [ColorVariableNames.LIGHTER_BLUE]: '#ebfcf6',
43
- [ColorVariableNames.HEADING]: '#e2001a',
44
- [ColorVariableNames.LIGHT_BLUE]: '#aaf6d9',
40
+ [ColorVariableNames.HIGHLIGHT]: '#e2001a',
41
+ [ColorVariableNames.CODE_KEYWORDS]: '#aaf6d9',
45
42
  },
46
43
  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,
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',
52
51
  },
53
52
  fonts: {
54
53
  [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`,
54
+ [FontVariableNames.HEADING]: 'Noto Serif, serif',
55
+ [FontVariableNames.MONOSPACE]: 'Consolas, Menlo, Monaco, source-code-pro, Courier New, monospace',
56
56
  },
57
57
  };
58
58
  const theme = merge.all([
59
- blogTheme,
60
59
  typographyTheme,
61
60
  {
62
61
  colors: variables.colors,
62
+ breakpoints: ['1000px'],
63
63
  space: {
64
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
- ]),
65
+ ...variables.sizes,
71
66
  },
72
- 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
+ ]),
73
73
  fonts: variables.fonts,
74
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`,
75
+ global: {
76
+ body: {
77
+ fontFamily: FontVariableNames.BODY,
88
78
  },
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`,
79
+ img: {
80
+ objectFit: 'contain',
81
+ margin: 0,
82
+ maxWidth: '100%',
83
+ maxHeight: '100%',
141
84
  },
142
85
  },
143
86
  waves: {
144
87
  default: {
145
88
  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',
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,
150
95
  position: 'relative',
151
96
  display: ['block', 'flex'],
152
97
  },
153
98
  ScrollerContainer: {
154
- paddingTop: ['80px', 0],
155
- width: ['auto', SizeVariableNames.CONTENT],
156
- 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],
157
105
  },
158
106
  ScrollerStep: {
159
107
  position: 'relative',
160
108
  padding: 0,
161
- minHeight: '400px',
109
+ minHeight: SizeVariableNames.STEP_HEIGHT,
162
110
  display: 'flex',
163
111
  alignItems: 'center',
164
112
  borderLeft: 0,
165
113
  },
166
114
  ScrollerProgress: {
167
- backgroundColor: ColorVariableNames.MUTED,
115
+ backgroundColor: ColorVariableNames.DARK_TEXT,
168
116
  borderRadius: '3px',
169
117
  position: 'absolute',
170
118
  left: '-24px',
171
119
  },
172
120
  StickerContainer: {
173
- width: ['100vw', SizeVariableNames.CONTENT],
174
- marginLeft: ['calc(50% - 50vw)', 0],
175
- position: ['sticky', 'static'],
176
- top: [0, 'auto'],
121
+ minWidth: ['100vw', SizeVariableNames.ASIDE_WIDTH],
122
+ maxWidth: ['100vw', SizeVariableNames.ASIDE_WIDTH],
123
+ position: 'sticky',
124
+ top: ['0', '10vh'],
177
125
  zIndex: [1, 'auto'],
178
- height: ['50vh', 'auto'],
179
- 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',
180
132
  backgroundColor: ColorVariableNames.DARK_BACKGROUND,
181
133
  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],
134
+ paddingRight: SizeVariableNames.SECTION_SLEEVE,
135
+ paddingLeft: SizeVariableNames.SECTION_SLEEVE,
136
+ a: {
137
+ border: 'none',
138
+ },
190
139
  },
191
140
  StickerStep: {
192
- position: 'absolute',
141
+ position: 'relative',
193
142
  height: '100%',
194
143
  width: '100%',
195
144
  display: 'flex',
196
145
  justifyContent: 'center',
197
146
  },
198
147
  // this is used to select the active scroller step
148
+ // 0.8 the step that is at 80% the screen height
199
149
  // 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],
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
+ },
202
221
  },
203
222
  },
204
223
  CodeSurfer: {
@@ -206,29 +225,17 @@ const theme = merge.all([
206
225
  color: ColorVariableNames.LIGHT_TEXT,
207
226
  backgroundColor: ColorVariableNames.DARK_BACKGROUND,
208
227
  },
209
- code: {
210
- color: ColorVariableNames.LIGHT_TEXT,
211
- backgroundColor: ColorVariableNames.DARK_BACKGROUND,
212
- },
213
228
  tokens: {
229
+ 'builtin changed keyword punctuation operator tag deleted string attr-value char number inserted': {
230
+ color: ColorVariableNames.CODE_KEYWORDS,
231
+ },
214
232
  'comment cdata doctype': {
215
233
  fontStyle: 'italic',
216
234
  },
217
- 'builtin changed keyword punctuation operator tag deleted string attr-value char number inserted': {
218
- color: ColorVariableNames.LIGHT_BLUE,
219
- },
220
235
  },
221
236
  },
222
237
  },
223
238
  },
224
239
  ]);
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
- };
240
+ theme.mergeWith = (otherTheme) => merge.all([theme, otherTheme]);
234
241
  export default theme;
@@ -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,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,14 +0,0 @@
1
- interface TocItemProps {
2
- heading: string;
3
- to?: string;
4
- explanation?: string;
5
- }
6
- export declare const Toc: {
7
- ({ headings }: {
8
- headings: TocItemProps[];
9
- }): import("theme-ui/jsx-runtime").JSX.Element;
10
- Heading: ({ heading }: {
11
- heading: string;
12
- }) => import("theme-ui/jsx-runtime").JSX.Element;
13
- };
14
- export {};