@enhanced-dom/slides 0.0.7 → 0.1.1
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/components/icon.component.d.ts +3 -3
- package/components/scroll-top/scroll-top.component.d.ts +3 -3
- package/components/scroll-top/scroll-top.component.js +6 -7
- package/components/scroll-top/scroll-top.style.pcss +1 -0
- package/components/scroll-top/scroll-top.style.pcss.d.ts +4 -4
- package/components/shell/header.component.d.ts +2 -1
- package/components/shell/header.component.js +2 -5
- package/components/shell/shell.component.d.ts +7 -8
- package/components/shell/shell.component.js +10 -13
- package/components/toc/heading2.component.d.ts +1 -1
- package/components/toc/heading2.component.js +3 -3
- package/components/toc/heading2.style.pcss.d.ts +4 -0
- package/components/toc/toc.component.d.ts +2 -1
- package/components/toc/toc.component.js +2 -2
- package/package.json +19 -19
- package/components/toc/toc.style.pcss.d.ts +0 -4
- /package/components/toc/{toc.style.pcss → heading2.style.pcss} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
import { IconWebComponent, IconWebComponentAttributes } from '@enhanced-dom/icon';
|
|
1
|
+
import { type DetailedHTMLProps, HTMLAttributes } from 'react';
|
|
2
|
+
import { IconWebComponent, type IconWebComponentAttributes } from '@enhanced-dom/icon';
|
|
3
3
|
import { IconDefinition } from '@fortawesome/fontawesome-common-types';
|
|
4
|
-
declare type IconComponentProps = IconWebComponentAttributes<IconDefinition> &
|
|
4
|
+
declare type IconComponentProps = IconWebComponentAttributes<IconDefinition> & DetailedHTMLProps<HTMLAttributes<IconWebComponent>, IconWebComponent>;
|
|
5
5
|
export declare const Icon: import("react").ComponentType<IconComponentProps> & {
|
|
6
6
|
renderer: import("@enhanced-dom/webcomponent").IRenderingEngine;
|
|
7
7
|
} & Record<string, AnalyserNode>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
2
|
export declare const ScrollTop: ({ children }: {
|
|
3
|
-
children?:
|
|
4
|
-
}) => import("
|
|
3
|
+
children?: ReactNode;
|
|
4
|
+
}) => import("react").JSX.Element;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "theme-ui/jsx-runtime";
|
|
2
|
-
import
|
|
2
|
+
import { useCallback, useState } 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';
|
|
@@ -22,16 +22,15 @@ const scrollOnKey = (e) => {
|
|
|
22
22
|
scrollToTop();
|
|
23
23
|
};
|
|
24
24
|
export const ScrollTop = ({ children }) => {
|
|
25
|
-
const [isFlipped, setFlipped] =
|
|
26
|
-
const showButton =
|
|
25
|
+
const [isFlipped, setFlipped] = useState(false);
|
|
26
|
+
const showButton = useCallback(() => {
|
|
27
27
|
if (getBodyScroll()) {
|
|
28
28
|
setFlipped(true);
|
|
29
29
|
}
|
|
30
30
|
}, [setFlipped]);
|
|
31
|
-
const showFront =
|
|
31
|
+
const showFront = useCallback(() => {
|
|
32
32
|
setFlipped(false);
|
|
33
33
|
}, [setFlipped]);
|
|
34
|
-
const buttonContents = children ? (_jsxs(ReactCardFlip,
|
|
35
|
-
|
|
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));
|
|
34
|
+
const buttonContents = children ? (_jsxs(ReactCardFlip, { isFlipped: isFlipped, flipDirection: "horizontal", children: [_jsx("div", { className: styles.brandingFront, children: children }), _jsx("div", { className: styles.brandingBack, children: _jsx(Icon, { className: styles.scrollIcon, config: { ...faArrowAltCircleUp, namespace: 'fa5' } }) })] })) : (_jsx("div", { className: styles.brandingBack, children: _jsx(Icon, { className: styles.scrollIcon, config: { ...faArrowAltCircleUp, namespace: 'fa5' } }) }));
|
|
35
|
+
return (_jsx("div", { className: styles.branding, tabIndex: 0, role: "button", onClick: scrollToTop, onFocus: showButton, onBlur: showFront, onMouseEnter: showButton, onMouseLeave: showFront, onKeyDown: scrollOnKey, children: buttonContents }));
|
|
37
36
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const branding: string
|
|
2
|
-
export const brandingBack: string
|
|
3
|
-
export const brandingFront: string
|
|
4
|
-
export const scrollIcon: string
|
|
1
|
+
export const branding: string;
|
|
2
|
+
export const brandingBack: string;
|
|
3
|
+
export const brandingFront: string;
|
|
4
|
+
export const scrollIcon: string;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
export declare const ShellHeader: ({ title, author, profileLink, date, variant, }: {
|
|
2
3
|
title: string;
|
|
3
4
|
author: string;
|
|
4
5
|
profileLink?: string;
|
|
5
6
|
date: string;
|
|
6
7
|
variant?: string;
|
|
7
|
-
}) => import("
|
|
8
|
+
}) => import("react").JSX.Element;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "theme-ui/jsx-runtime";
|
|
2
|
-
import { Themed } from 'theme-ui';
|
|
2
|
+
import { Themed } from '@theme-ui/mdx';
|
|
3
3
|
export const ShellHeader = ({ title, author, profileLink, date, variant = 'default', }) => {
|
|
4
|
-
return (_jsxs("header", { children: [_jsx(Themed.h1, { children: title },
|
|
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));
|
|
4
|
+
return (_jsxs("header", { children: [_jsx(Themed.h1, { children: title }), _jsxs(Themed.p, { sx: { variant: `styles.shell.${variant}.Author` }, children: [profileLink ? (_jsx(Themed.a, { href: "/", sx: { textDecoration: 'none', color: 'inherit', border: 'none' }, children: author })) : (author), _jsx("br", {}), _jsx("span", { sx: { fontSize: 1 }, children: date })] })] }));
|
|
8
5
|
};
|
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import React from 'react';
|
|
1
|
+
import { type Theme } from 'theme-ui';
|
|
2
|
+
import { type ComponentProps, type FC, type ReactNode } from 'react';
|
|
4
3
|
import { MDXProvider } from '@mdx-js/react';
|
|
5
4
|
import { ShellHeader } from './header.component';
|
|
6
5
|
declare const BrandingSlot: ({ children }: {
|
|
7
|
-
children?:
|
|
8
|
-
}) => import("
|
|
9
|
-
declare const ContentsSlot:
|
|
10
|
-
export declare const Shell:
|
|
6
|
+
children?: ReactNode;
|
|
7
|
+
}) => import("react").JSX.Element;
|
|
8
|
+
declare const ContentsSlot: FC<ComponentProps<typeof ShellHeader>>;
|
|
9
|
+
export declare const Shell: FC<{
|
|
11
10
|
theme?: Theme;
|
|
12
11
|
variant?: string;
|
|
13
12
|
}> & {
|
|
14
13
|
Branding: typeof BrandingSlot;
|
|
15
14
|
Contents: typeof ContentsSlot;
|
|
16
|
-
mdxComponents:
|
|
15
|
+
mdxComponents: ComponentProps<typeof MDXProvider>['components'];
|
|
17
16
|
};
|
|
18
17
|
export {};
|
|
@@ -1,34 +1,31 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "theme-ui/jsx-runtime";
|
|
2
|
-
|
|
3
|
-
import { Themed
|
|
2
|
+
import { ThemeUIProvider } from 'theme-ui';
|
|
3
|
+
import { Themed } from '@theme-ui/mdx';
|
|
4
4
|
import { Global } from '@emotion/react';
|
|
5
|
-
import
|
|
5
|
+
import { Children as ReactChildren } from 'react';
|
|
6
6
|
import { MDXProvider } from '@mdx-js/react';
|
|
7
7
|
import defaultTheme from '../../theme';
|
|
8
8
|
import { ShellHeader } from './header.component';
|
|
9
9
|
import { ScrollTop } from '../scroll-top';
|
|
10
10
|
import { Heading2 } from '../toc';
|
|
11
11
|
const BrandingSlot = ({ children }) => {
|
|
12
|
-
return _jsx(_Fragment, { children: children }
|
|
12
|
+
return _jsx(_Fragment, { children: children });
|
|
13
13
|
};
|
|
14
14
|
const ContentsSlot = ({ children, ...rest }) => {
|
|
15
|
-
return (_jsxs(_Fragment, { children: [_jsx(ShellHeader,
|
|
15
|
+
return (_jsxs(_Fragment, { children: [_jsx(ShellHeader, { ...rest }), children || null] }));
|
|
16
16
|
};
|
|
17
|
-
const getBranding = (children) =>
|
|
18
|
-
const getContents = (children) =>
|
|
17
|
+
const getBranding = (children) => ReactChildren.toArray(children).find((item) => (item === null || item === void 0 ? void 0 : item.type) === BrandingSlot);
|
|
18
|
+
const getContents = (children) => ReactChildren.toArray(children).find((item) => (item === null || item === void 0 ? void 0 : item.type) === ContentsSlot);
|
|
19
19
|
export const Shell = ({ children, theme, variant = 'default' }) => {
|
|
20
20
|
var _a, _b, _c, _d, _e;
|
|
21
21
|
const branding = getBranding(children);
|
|
22
22
|
const contents = getContents(children);
|
|
23
|
-
return (_jsx(
|
|
23
|
+
return (_jsx(ThemeUIProvider, { theme: theme, children: _jsxs(Themed.root, { sx: {
|
|
24
24
|
variant: `styles.shell.${variant}.Root`,
|
|
25
|
-
}
|
|
25
|
+
}, children: [_jsx(Global, { styles: {
|
|
26
26
|
...((_b = (_a = theme.styles.global) === null || _a === void 0 ? void 0 : _a[variant]) !== null && _b !== void 0 ? _b : {}),
|
|
27
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
|
-
} },
|
|
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));
|
|
28
|
+
} }), _jsx("aside", {}), _jsxs("main", { children: [_jsx(MDXProvider, { components: Shell.mdxComponents, disableParentContext: true, children: contents }), branding ? _jsx(ScrollTop, { children: branding.props.children ? branding : null }) : null] })] }) }));
|
|
32
29
|
};
|
|
33
30
|
Shell.defaultProps = {
|
|
34
31
|
theme: defaultTheme,
|
|
@@ -3,7 +3,7 @@ import { useCallback, useMemo, useState } from 'react';
|
|
|
3
3
|
import classnames from 'classnames';
|
|
4
4
|
import { faLink } from '@fortawesome/free-solid-svg-icons';
|
|
5
5
|
import { faClipboard } from '@fortawesome/free-regular-svg-icons';
|
|
6
|
-
import * as styles from './
|
|
6
|
+
import * as styles from './heading2.style.pcss';
|
|
7
7
|
import { Icon } from '../icon.component';
|
|
8
8
|
export const Heading2 = ({ children, id, className, ...forwarded }) => {
|
|
9
9
|
const anchorRef = id !== null && id !== void 0 ? id : children.toLowerCase().replace(/\s/, '-');
|
|
@@ -30,7 +30,7 @@ export const Heading2 = ({ children, id, className, ...forwarded }) => {
|
|
|
30
30
|
const handleCopyReset = useCallback(() => {
|
|
31
31
|
setCopied(false);
|
|
32
32
|
}, [setCopied]);
|
|
33
|
-
return (_jsx("h2",
|
|
33
|
+
return (_jsx("h2", { className: classnames(styles.heading, className), ...forwarded, tabIndex: 0, onKeyDown: handleKeyboardCopy, onBlur: handleCopyReset,
|
|
34
34
|
// eslint-disable-next-line jsx-a11y/no-noninteractive-element-to-interactive-role
|
|
35
|
-
role: "link"
|
|
35
|
+
role: "link", children: _jsxs("a", { 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' })] }) }));
|
|
36
36
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
interface TocItemProps {
|
|
2
3
|
heading: string;
|
|
3
4
|
to?: string;
|
|
@@ -5,5 +6,5 @@ interface TocItemProps {
|
|
|
5
6
|
}
|
|
6
7
|
export declare const Toc: ({ headings }: {
|
|
7
8
|
headings: TocItemProps[];
|
|
8
|
-
}) =>
|
|
9
|
+
}) => React.JSX.Element;
|
|
9
10
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "theme-ui/jsx-runtime";
|
|
2
2
|
const TocItem = ({ heading, to, explanation }) => {
|
|
3
3
|
const anchor = to !== null && to !== void 0 ? to : heading;
|
|
4
|
-
return (_jsxs("li", { children: [_jsx("a",
|
|
4
|
+
return (_jsxs("li", { children: [_jsx("a", { href: `#${anchor.toLowerCase().replace(/\s/, '-')}`, children: _jsx("b", { children: heading }) }), explanation ? ': ' : '', explanation] }));
|
|
5
5
|
};
|
|
6
|
-
export const Toc = ({ headings }) => (_jsx("ul", { children: headings.map((h, idx) => (_jsx(TocItem,
|
|
6
|
+
export const Toc = ({ headings }) => (_jsx("ul", { children: headings.map((h, idx) => (_jsx(TocItem, { ...h }, idx))) }));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@enhanced-dom/slides",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Basic building blocks for html slides",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"repository": "https://github.com/enhanced-dom/slides.git",
|
|
@@ -8,29 +8,29 @@
|
|
|
8
8
|
"author": "CD9B4A105290E17E0948E021DF4105107C88693C59C0B891CCC08366C51AEA990902A6A156AC87D88A2FC41422A5E1C3C4071F251F19441C4516000EC25F87DF",
|
|
9
9
|
"main": "index.js",
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@emotion/react": "^11.
|
|
12
|
-
"@enhanced-dom/fontawesome": "
|
|
13
|
-
"@enhanced-dom/gatsby-waves": "
|
|
14
|
-
"@enhanced-dom/icon": "
|
|
15
|
-
"@enhanced-dom/react": "
|
|
16
|
-
"@fontsource/montserrat": "^
|
|
17
|
-
"@fontsource/noto-serif": "^5.0.
|
|
18
|
-
"@mdx-js/react": "^
|
|
19
|
-
"@theme-ui/typography": "^0.
|
|
20
|
-
"deepmerge": "^4.
|
|
11
|
+
"@emotion/react": "^11.11.3",
|
|
12
|
+
"@enhanced-dom/fontawesome": "~0.2.0",
|
|
13
|
+
"@enhanced-dom/gatsby-waves": "~0.1.0",
|
|
14
|
+
"@enhanced-dom/icon": "~0.1.1",
|
|
15
|
+
"@enhanced-dom/react": "~0.1.0",
|
|
16
|
+
"@fontsource/montserrat": "^5.0.17",
|
|
17
|
+
"@fontsource/noto-serif": "^5.0.19",
|
|
18
|
+
"@mdx-js/react": "^3.0.1",
|
|
19
|
+
"@theme-ui/typography": "^0.16.2",
|
|
20
|
+
"deepmerge": "^4.3.1",
|
|
21
21
|
"lodash.pick": "^4.4.0",
|
|
22
|
-
"react-card-flip": "^1.
|
|
22
|
+
"react-card-flip": "^1.2.2",
|
|
23
23
|
"typography-theme-wordpress-2016": "^0.16.19"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@enhanced-dom/lint": "
|
|
27
|
-
"@enhanced-dom/webpack": "
|
|
28
|
-
"@types/lodash.pick": "^4.4.
|
|
29
|
-
"@types/react": "^17.0.
|
|
30
|
-
"@types/react-dom": "^17.0.
|
|
26
|
+
"@enhanced-dom/lint": "~0.1.4",
|
|
27
|
+
"@enhanced-dom/webpack": "~0.2.0",
|
|
28
|
+
"@types/lodash.pick": "^4.4.9",
|
|
29
|
+
"@types/react": "^17.0.75",
|
|
30
|
+
"@types/react-dom": "^17.0.25"
|
|
31
31
|
},
|
|
32
32
|
"engines": {
|
|
33
|
-
"node": ">=
|
|
34
|
-
"npm": ">=
|
|
33
|
+
"node": ">=18",
|
|
34
|
+
"npm": ">=10"
|
|
35
35
|
}
|
|
36
36
|
}
|
|
File without changes
|