@gpichot/spectacle-deck 1.1.7 → 1.2.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.
Files changed (80) hide show
  1. package/.turbo/turbo-build.log +4 -0
  2. package/.turbo/turbo-dev.log +4 -0
  3. package/dist/SlideWrapper.d.ts +7 -0
  4. package/dist/colors.d.ts +14 -0
  5. package/dist/components/QRCode.d.ts +6 -0
  6. package/dist/components/Timeline.styled.d.ts +7 -0
  7. package/{components → dist/components}/map.d.ts +2 -0
  8. package/dist/components/styled.d.ts +12 -0
  9. package/dist/context.d.ts +11 -0
  10. package/{index.cjs → dist/index.cjs} +321 -200
  11. package/{index.d.ts → dist/index.d.ts} +30 -7
  12. package/{index.mjs → dist/index.mjs} +312 -191
  13. package/{layouts → dist/layouts}/BaseLayout.d.ts +1 -1
  14. package/dist/layouts/SectionLayout.d.ts +2 -0
  15. package/{layouts → dist/layouts}/index.d.ts +1 -1
  16. package/dist/layouts/styled.d.ts +2 -0
  17. package/package.json +29 -23
  18. package/publish.sh +7 -0
  19. package/scripts/bundle.ts +84 -0
  20. package/src/SlideWrapper.tsx +25 -0
  21. package/src/colors.ts +42 -0
  22. package/src/components/CodeStepper/CodeStepper.tsx +228 -0
  23. package/src/components/CodeStepper/code-directives.test.ts +58 -0
  24. package/src/components/CodeStepper/code-directives.ts +129 -0
  25. package/src/components/DocumentationItem.tsx +85 -0
  26. package/src/components/FilePane.tsx +18 -0
  27. package/src/components/HorizontalList.tsx +141 -0
  28. package/src/components/IconBox.tsx +31 -0
  29. package/src/components/Image.tsx +39 -0
  30. package/src/components/ItemsColumn.tsx +60 -0
  31. package/src/components/QRCode.tsx +55 -0
  32. package/src/components/Timeline.styled.tsx +24 -0
  33. package/src/components/Timeline.tsx +159 -0
  34. package/src/components/map.tsx +128 -0
  35. package/src/components/styled.tsx +73 -0
  36. package/src/context.tsx +33 -0
  37. package/src/front.png +0 -0
  38. package/src/index.tsx +127 -0
  39. package/src/layouts/BaseLayout.tsx +52 -0
  40. package/src/layouts/CenteredLayout.tsx +40 -0
  41. package/src/layouts/Default3Layout.tsx +159 -0
  42. package/src/layouts/MainSectionLayout.tsx +31 -0
  43. package/src/layouts/QuoteLayout.tsx +107 -0
  44. package/src/layouts/SectionLayout.tsx +14 -0
  45. package/src/layouts/SideCodeLayout.tsx +44 -0
  46. package/src/layouts/SideImageLayout.tsx +82 -0
  47. package/src/layouts/SideLayout.tsx +31 -0
  48. package/src/layouts/columns.tsx +56 -0
  49. package/src/layouts/index.tsx +19 -0
  50. package/src/layouts/styled.ts +7 -0
  51. package/src/layouts/utils.ts +66 -0
  52. package/src/node.d.ts +5 -0
  53. package/src/style.d.ts +10 -0
  54. package/src/template.tsx +25 -0
  55. package/src/theme.ts +28 -0
  56. package/tsconfig.json +29 -0
  57. package/components/Timeline.styled.d.ts +0 -7
  58. package/components/styled.d.ts +0 -12
  59. package/layouts/SectionLayout.d.ts +0 -2
  60. package/layouts/styled.d.ts +0 -2
  61. /package/{components → dist/components}/CodeStepper/CodeStepper.d.ts +0 -0
  62. /package/{components → dist/components}/CodeStepper/code-directives.d.ts +0 -0
  63. /package/{components → dist/components}/DocumentationItem.d.ts +0 -0
  64. /package/{components → dist/components}/FilePane.d.ts +0 -0
  65. /package/{components → dist/components}/HorizontalList.d.ts +0 -0
  66. /package/{components → dist/components}/IconBox.d.ts +0 -0
  67. /package/{components → dist/components}/Image.d.ts +0 -0
  68. /package/{components → dist/components}/ItemsColumn.d.ts +0 -0
  69. /package/{components → dist/components}/Timeline.d.ts +0 -0
  70. /package/{layouts → dist/layouts}/CenteredLayout.d.ts +0 -0
  71. /package/{layouts → dist/layouts}/Default3Layout.d.ts +0 -0
  72. /package/{layouts → dist/layouts}/MainSectionLayout.d.ts +0 -0
  73. /package/{layouts → dist/layouts}/QuoteLayout.d.ts +0 -0
  74. /package/{layouts → dist/layouts}/SideCodeLayout.d.ts +0 -0
  75. /package/{layouts → dist/layouts}/SideImageLayout.d.ts +0 -0
  76. /package/{layouts → dist/layouts}/SideLayout.d.ts +0 -0
  77. /package/{layouts → dist/layouts}/columns.d.ts +0 -0
  78. /package/{layouts → dist/layouts}/utils.d.ts +0 -0
  79. /package/{template.d.ts → dist/template.d.ts} +0 -0
  80. /package/{theme.d.ts → dist/theme.d.ts} +0 -0
@@ -0,0 +1,85 @@
1
+ import React from "react";
2
+
3
+ import styled from "styled-components";
4
+
5
+ const DocWrapper = styled.div`
6
+ position: absolute;
7
+ bottom: 0;
8
+ right: 0;
9
+ z-index: 10000;
10
+
11
+ .docContent {
12
+ display: none;
13
+ }
14
+
15
+ &:hover .docContent {
16
+ display: flex;
17
+ }
18
+ `;
19
+
20
+ const DocContainer = styled.div`
21
+ margin: 2rem 1rem;
22
+ background-color: #333;
23
+ border: 1px solid #333;
24
+ padding: 0.5rem 1rem;
25
+ border-radius: 1.5rem;
26
+ `;
27
+
28
+ const DocLink = styled.a`
29
+ text-decoration: none;
30
+ font-weight: normal;
31
+ font-family: var(--font-family);
32
+ color: var(--color-secondary);
33
+ `;
34
+
35
+ const DocLinkItem = styled(DocLink)`
36
+ width: fit-content;
37
+ display: inline-block;
38
+ background-color: #333;
39
+ border: 1px solid #333;
40
+ padding: 0.5rem 1rem;
41
+ border-radius: 1.5rem;
42
+ margin: 0.25rem 0;
43
+ `;
44
+
45
+ const DocContent = styled.div`
46
+ display: flex;
47
+ flex-flow: column-reverse nowrap;
48
+ position: absolute;
49
+ right: 1rem;
50
+ bottom: 4.5rem;
51
+ text-align: right;
52
+ border-radius: 0.5rem;
53
+ align-items: flex-end;
54
+ `;
55
+
56
+ export function Doc({
57
+ label,
58
+ link,
59
+ children,
60
+ }: {
61
+ label: string;
62
+ link: string;
63
+ children: React.ReactNode;
64
+ }) {
65
+ return (
66
+ <DocWrapper>
67
+ <DocContainer>
68
+ {children && <DocContent>{children}</DocContent>}
69
+ <div>
70
+ <DocLink target="_blank" rel="noopener noreferrer" href={link}>
71
+ {label}
72
+ </DocLink>
73
+ </div>
74
+ </DocContainer>
75
+ </DocWrapper>
76
+ );
77
+ }
78
+
79
+ export function DocItem({ label, link }: { label: string; link: string }) {
80
+ return (
81
+ <DocLinkItem target="_blank" rel="noopener noreferrer" href={link}>
82
+ {label}
83
+ </DocLinkItem>
84
+ );
85
+ }
@@ -0,0 +1,18 @@
1
+ import React from "react";
2
+
3
+ export default function FilePane({
4
+ name,
5
+ children,
6
+ priority,
7
+ ...divProps
8
+ }: React.ComponentProps<"div"> & { name: string; priority?: number }) {
9
+ return React.isValidElement(children)
10
+ ? React.cloneElement(children, {
11
+ // @ts-expect-error cloning
12
+ priority,
13
+ name,
14
+ })
15
+ : children;
16
+ }
17
+
18
+ FilePane.mdxType = "FilePane";
@@ -0,0 +1,141 @@
1
+ import { usePestacle } from "context";
2
+ import React from "react";
3
+ import { animated, useSpring } from "react-spring";
4
+ import { Stepper } from "spectacle";
5
+ import styled from "styled-components";
6
+
7
+ const Container = styled.div`
8
+ display: grid;
9
+ grid-gap: 2rem;
10
+ `;
11
+
12
+ export default function HorizontalList({
13
+ children,
14
+ columns = 3,
15
+ }: {
16
+ columns?: number;
17
+ children: React.ReactNode;
18
+ }) {
19
+ const items = React.Children.toArray(children);
20
+ return (
21
+ <Stepper values={items}>
22
+ {(_, step) => (
23
+ <Container
24
+ style={{
25
+ gridTemplateColumns: `repeat(${columns}, 1fr)`,
26
+ }}
27
+ >
28
+ {items.map((item, k) => {
29
+ if (!React.isValidElement(item)) {
30
+ return item;
31
+ }
32
+ return React.cloneElement(item, {
33
+ // @ts-expect-error cloning
34
+ position: k + 1,
35
+ isVisible: k <= step,
36
+ isLast: k === step,
37
+ });
38
+ })}
39
+ </Container>
40
+ )}
41
+ </Stepper>
42
+ );
43
+ }
44
+
45
+ function Pill({ position }: { position: number }) {
46
+ return (
47
+ <div
48
+ style={{ width: 48, transform: "translate(-25%, -25%)", opacity: 0.9 }}
49
+ >
50
+ <svg
51
+ width="48"
52
+ height="48"
53
+ viewBox="0 0 18 20"
54
+ fill="none"
55
+ xmlns="http://www.w3.org/2000/svg"
56
+ >
57
+ <path
58
+ d="M8.64717 20L0 15.0094V5.00134L8.64717 0L17.289 5.00134V15.0094L8.64717 20ZM1.48222 14.141L8.64717 18.2846L15.8068 14.141V5.85902L8.64717 1.71536L1.48222 5.85902V14.141Z"
59
+ fill="#ffffff"
60
+ ></path>
61
+ <text
62
+ x="9"
63
+ y="11"
64
+ text-anchor="middle"
65
+ dominant-baseline="middle"
66
+ fill="#f49676"
67
+ style={{ fontSize: "50%" }}
68
+ >
69
+ {position}
70
+ </text>
71
+ <path
72
+ d="M 8.758 16.01 L 3.549 13.004 L 3.549 6.975 L 8.758 3.963 L 13.964 6.975 L 13.964 13.004 L 8.758 16.01 Z"
73
+ fill="transparent"
74
+ ></path>
75
+ </svg>
76
+ </div>
77
+ );
78
+ }
79
+
80
+ const Item = styled(animated.div)`
81
+ display: flex;
82
+ flex-direction: column;
83
+ font-family: Bitter, "Helvetica Neue", Helvetica, Arial, sans-serif;
84
+ `;
85
+ const ItemHead = styled.div`
86
+ display: flex;
87
+ flex-direction: row;
88
+ font-size: 1.3rem;
89
+ margin-bottom: 0.4rem;
90
+
91
+ p {
92
+ margin: 0;
93
+ }
94
+ `;
95
+ const ItemContent = styled.div`
96
+ > * {
97
+ font-size: 1rem;
98
+ padding: 4px !important;
99
+ line-height: 1.5rem !important;
100
+ margin-top: 0;
101
+ }
102
+ `;
103
+
104
+ function getItemOpacity({
105
+ isLast,
106
+ isVisible,
107
+ }: {
108
+ isLast?: boolean;
109
+ isVisible?: boolean;
110
+ }) {
111
+ if (isLast) return 1;
112
+ if (isVisible) return 0.7;
113
+ return 0;
114
+ }
115
+ export function HorizontalListItem({
116
+ title,
117
+ children,
118
+ position,
119
+ isVisible,
120
+ isLast,
121
+ }: {
122
+ title: string;
123
+ position: number;
124
+ isVisible?: boolean;
125
+ isLast?: boolean;
126
+ children: React.ReactNode;
127
+ }) {
128
+ const opacityStyles = useSpring({
129
+ opacity: getItemOpacity({ isVisible, isLast }),
130
+ });
131
+ return (
132
+ <Item style={opacityStyles}>
133
+ <ItemHead>
134
+ <Pill position={position} />
135
+ <p>{title}</p>
136
+ </ItemHead>
137
+
138
+ <ItemContent>{children}</ItemContent>
139
+ </Item>
140
+ );
141
+ }
@@ -0,0 +1,31 @@
1
+ import React from "react";
2
+ import styled from "styled-components";
3
+
4
+ const IconBoxContent = styled.div`
5
+ * {
6
+ margin: 0.2rem !important;
7
+ padding: 0 !important;
8
+ }
9
+ `;
10
+
11
+ export function IconBox({
12
+ children,
13
+ icon,
14
+ }: {
15
+ children: React.ReactNode;
16
+ icon: React.ReactNode;
17
+ }) {
18
+ return (
19
+ <div
20
+ style={{
21
+ display: "flex",
22
+ flexDirection: "column",
23
+ alignItems: "center",
24
+ padding: "1rem 0",
25
+ }}
26
+ >
27
+ <div style={{ fontSize: 60 }}>{icon}</div>
28
+ <IconBoxContent>{children}</IconBoxContent>
29
+ </div>
30
+ );
31
+ }
@@ -0,0 +1,39 @@
1
+ import React from "react";
2
+ import { SVGObject } from "../layouts/styled";
3
+
4
+ export interface ImageProps extends React.ComponentProps<"img"> { }
5
+
6
+ export function Image(props: ImageProps) {
7
+ const { src, height, width,
8
+ style, ...otherProps
9
+ } = props;
10
+ if (!src?.endsWith(".svg")) {
11
+ return (
12
+ <img
13
+ src={src}
14
+ {...otherProps}
15
+ style={{
16
+ width,
17
+ height: height || "100%",
18
+ objectFit: "cover",
19
+ objectPosition: "center",
20
+ ...style
21
+ }}
22
+ />
23
+ );
24
+ }
25
+ return (
26
+ <SVGObject
27
+ type="image/svg+xml"
28
+ data={src}
29
+ style={{
30
+ height: height || "100%",
31
+ minWidth: "30vw",
32
+ width: width || "100%",
33
+ ...style
34
+ }}
35
+ />
36
+ );
37
+ }
38
+
39
+ Image.mdxType = "Image";
@@ -0,0 +1,60 @@
1
+ import React from "react";
2
+ import { Stepper } from "spectacle";
3
+ import styled from "styled-components";
4
+ import { useSpring, animated } from "react-spring";
5
+
6
+ export function ItemsColumn(divProps: React.ComponentProps<"div">) {
7
+ const { style, children, ...props } = divProps;
8
+ const childrenArray = React.Children.toArray(children);
9
+ return (
10
+ <Stepper values={childrenArray}>
11
+ {(value, step) => (
12
+ <div
13
+ style={{
14
+ display: "flex",
15
+ flexDirection: "column",
16
+ justifyItems: 'center',
17
+ alignItems: "stretch",
18
+ height: "100%",
19
+ rowGap: '2rem',
20
+ ...style,
21
+ }}
22
+ {...props}
23
+ >
24
+ {childrenArray.map((child, index) => {
25
+ const isVisible = index <= step;
26
+ if (!React.isValidElement(child)) {
27
+ return child;
28
+ }
29
+ return (
30
+ <ItemColumnWrapper key={index} isVisible={isVisible}>
31
+ {child}
32
+ </ItemColumnWrapper>
33
+ );
34
+ })}
35
+ </div>
36
+ )}
37
+ </Stepper>
38
+ );
39
+ }
40
+
41
+ const ItemColumnWrapperStyled = styled(animated.div)`
42
+ display: flex;
43
+ justify-content: center;
44
+ * {
45
+ text-align: center !important;
46
+ }
47
+ `;
48
+
49
+ function ItemColumnWrapper({
50
+ children,
51
+ isVisible,
52
+ ...props
53
+ }: React.ComponentPropsWithRef<"div"> & { isVisible: boolean }) {
54
+ const styles = useSpring({ opacity: isVisible ? 1 : 0 });
55
+ return (
56
+ <ItemColumnWrapperStyled style={styles} {...props}>
57
+ {children}
58
+ </ItemColumnWrapperStyled>
59
+ );
60
+ }
@@ -0,0 +1,55 @@
1
+ import QrCreator from "qr-creator";
2
+ import React, { useContext } from "react";
3
+ import { DeckContext } from "spectacle";
4
+
5
+ export interface QRCodeProps {
6
+ url: string;
7
+ size?: "xs" | "sm" | "md" | "lg";
8
+ }
9
+
10
+ const MapSize = {
11
+ xs: 64,
12
+ sm: 128,
13
+ md: 256,
14
+ lg: 512,
15
+ };
16
+
17
+ export function QRCode({ url, size = "md" }: QRCodeProps) {
18
+ const id = React.useId().replace(/:/g, "___");
19
+ const deck = useContext(DeckContext);
20
+ const width = MapSize[size];
21
+ const backgroundColor = deck.theme?.colors?.primary || "#ffffff";
22
+
23
+ React.useEffect(() => {
24
+ const element = document.querySelector(`#${id}`);
25
+
26
+ if (!element) return console.error("QRCode element not mounted");
27
+
28
+ QrCreator.render(
29
+ {
30
+ text: url,
31
+ radius: 0.5,
32
+ ecLevel: "H", // L, M, Q, H
33
+ fill: deck.theme?.colors?.secondary || "#000000",
34
+ background: backgroundColor,
35
+ size: width,
36
+ },
37
+ element as HTMLElement,
38
+ );
39
+
40
+ return () => {
41
+ element.replaceChildren();
42
+ };
43
+ }, [url]);
44
+
45
+ return (
46
+ <div
47
+ id={id}
48
+ style={{
49
+ padding: "1rem 1rem 0.6rem 1rem",
50
+ borderRadius: "1rem",
51
+ backgroundColor,
52
+ }}
53
+ />
54
+ );
55
+ }
@@ -0,0 +1,24 @@
1
+ import styled from "styled-components";
2
+
3
+ export const TimelineItemContent = styled.div`
4
+ display: flex;
5
+ padding: 0.7rem 0 1rem 12px;
6
+ `;
7
+ export const TimelineItemContentPhantom = styled(TimelineItemContent)`
8
+ opacity: 0;
9
+ `;
10
+
11
+ export const TimelineItemBody = styled.div`
12
+ &,
13
+ & > * {
14
+ font-size: 1.3rem !important;
15
+ color: #ffffff !important;
16
+ }
17
+ `;
18
+
19
+ export const TimelineItemTitle = styled.div`
20
+ font-family: Bitter, "Helvetica Neue", Helvetica, Arial, sans-serif;
21
+ font-size: 1rem;
22
+ font-weight: bold;
23
+ color: #ffffffbb;
24
+ `;
@@ -0,0 +1,159 @@
1
+ import React from "react";
2
+ import { animated, useSpring } from "react-spring";
3
+ import { Stepper } from "spectacle";
4
+
5
+ import {
6
+ TimelineItemBody,
7
+ TimelineItemContent,
8
+ TimelineItemContentPhantom,
9
+ TimelineItemTitle,
10
+ } from "./Timeline.styled";
11
+ import styled from "styled-components";
12
+
13
+ const TimelineItemStyled = styled(animated.div)<{
14
+ isOdd?: boolean;
15
+ isEven?: boolean;
16
+ }>`
17
+ flex: 1;
18
+ flex-flow: column nowrap;
19
+ display: inline-flex;
20
+
21
+ &:nth-child(odd) {
22
+ &,
23
+ ${TimelineItemContent} {
24
+ flex-direction: column;
25
+ }
26
+ }
27
+ &:nth-child(even) {
28
+ &,
29
+ ${TimelineItemContent} {
30
+ flex-direction: column-reverse;
31
+ }
32
+ }
33
+ `;
34
+
35
+ const TimelineItemGuide = styled(animated.div)`
36
+ width: 100%;
37
+ padding-top: 2px;
38
+ display: flex;
39
+ flex-flow: row;
40
+ align-items: center;
41
+
42
+ svg {
43
+ height: 28px;
44
+ width: 28px;
45
+ path {
46
+ fill: #ffffff;
47
+ }
48
+ margin-right: 4px;
49
+ }
50
+ `;
51
+
52
+ const TimelineItemGuideLine = styled(animated.div)`
53
+ border-top: 4px solid #ffffff;
54
+ margin-right: 4px;
55
+ `;
56
+
57
+ const style = {
58
+ display: "flex",
59
+ position: "relative",
60
+ flexFlow: "row nowrap",
61
+ alignItems: "center",
62
+ };
63
+
64
+ export default function Timeline(props: React.ComponentPropsWithoutRef<"div">) {
65
+ const children = React.Children.toArray(props.children);
66
+ return (
67
+ <Stepper
68
+ {...props}
69
+ values={children}
70
+ activeStyle={style}
71
+ inactiveStyle={style}
72
+ >
73
+ {(value, step) => {
74
+ return children.map((child, index) => {
75
+ if (!React.isValidElement(child)) {
76
+ return child;
77
+ }
78
+ return React.cloneElement(child, {
79
+ // @ts-expect-error cloning
80
+ isPhantom: step < index,
81
+ isLast: step === index,
82
+ });
83
+ });
84
+ }}
85
+ </Stepper>
86
+ );
87
+ }
88
+
89
+ function getItemOpacity({
90
+ isLast,
91
+ isPhantom,
92
+ }: {
93
+ isLast?: boolean;
94
+ isPhantom?: boolean;
95
+ }) {
96
+ if (isPhantom) return 0;
97
+ if (isLast) return 1;
98
+ return 0.5;
99
+ }
100
+
101
+ export function TimelineItem(
102
+ props: React.ComponentPropsWithoutRef<"div"> & {
103
+ isPhantom?: boolean;
104
+ isLast?: boolean;
105
+ isOdd?: boolean;
106
+ isEven?: boolean;
107
+ }
108
+ ) {
109
+ const { children, title, isPhantom, isLast, ...rest } = props;
110
+ const guideLineProps = useSpring({
111
+ width: isPhantom || isLast ? "0%" : "100%",
112
+ });
113
+ const appearStyles = useSpring({
114
+ opacity: getItemOpacity({ isPhantom, isLast }),
115
+ });
116
+ const colorStyles = useSpring({ opacity: isPhantom || isLast ? 1 : 0.15 });
117
+ return (
118
+ <TimelineItemStyled
119
+ {...rest}
120
+ style={{
121
+ ...appearStyles,
122
+ }}
123
+ >
124
+ <TimelineItemContentPhantom>
125
+ <TimelineItemTitle>{title}</TimelineItemTitle>
126
+ <TimelineItemBody>{children}</TimelineItemBody>
127
+ </TimelineItemContentPhantom>
128
+ <TimelineItemGuide style={colorStyles}>
129
+ <Hexagon />
130
+ <TimelineItemGuideLine style={guideLineProps} />
131
+ </TimelineItemGuide>
132
+ <TimelineItemContent>
133
+ <TimelineItemTitle>{title}</TimelineItemTitle>
134
+ <TimelineItemBody>{children}</TimelineItemBody>
135
+ </TimelineItemContent>
136
+ </TimelineItemStyled>
137
+ );
138
+ }
139
+
140
+ function Hexagon() {
141
+ return (
142
+ <svg
143
+ width="18"
144
+ height="20"
145
+ viewBox="0 0 18 20"
146
+ fill="none"
147
+ xmlns="http://www.w3.org/2000/svg"
148
+ >
149
+ <path
150
+ d="M8.64717 20L0 15.0094V5.00134L8.64717 0L17.289 5.00134V15.0094L8.64717 20ZM1.48222 14.141L8.64717 18.2846L15.8068 14.141V5.85902L8.64717 1.71536L1.48222 5.85902V14.141Z"
151
+ fill="#F49676"
152
+ ></path>
153
+ <path
154
+ d="M 8.758 16.01 L 3.549 13.004 L 3.549 6.975 L 8.758 3.963 L 13.964 6.975 L 13.964 13.004 L 8.758 16.01 Z"
155
+ fill="#F49676"
156
+ ></path>
157
+ </svg>
158
+ );
159
+ }