@gpichot/spectacle-deck 1.2.0 → 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.
- package/.turbo/turbo-build.log +4 -0
- package/.turbo/turbo-dev.log +4 -0
- package/{index.cjs → dist/index.cjs} +5 -4
- package/{index.mjs → dist/index.mjs} +5 -4
- package/package.json +21 -16
- package/publish.sh +7 -0
- package/scripts/bundle.ts +84 -0
- package/src/SlideWrapper.tsx +25 -0
- package/src/colors.ts +42 -0
- package/src/components/CodeStepper/CodeStepper.tsx +228 -0
- package/src/components/CodeStepper/code-directives.test.ts +58 -0
- package/src/components/CodeStepper/code-directives.ts +129 -0
- package/src/components/DocumentationItem.tsx +85 -0
- package/src/components/FilePane.tsx +18 -0
- package/src/components/HorizontalList.tsx +141 -0
- package/src/components/IconBox.tsx +31 -0
- package/src/components/Image.tsx +39 -0
- package/src/components/ItemsColumn.tsx +60 -0
- package/src/components/QRCode.tsx +55 -0
- package/src/components/Timeline.styled.tsx +24 -0
- package/src/components/Timeline.tsx +159 -0
- package/src/components/map.tsx +128 -0
- package/src/components/styled.tsx +73 -0
- package/src/context.tsx +33 -0
- package/src/front.png +0 -0
- package/src/index.tsx +127 -0
- package/src/layouts/BaseLayout.tsx +52 -0
- package/src/layouts/CenteredLayout.tsx +40 -0
- package/src/layouts/Default3Layout.tsx +159 -0
- package/src/layouts/MainSectionLayout.tsx +31 -0
- package/src/layouts/QuoteLayout.tsx +107 -0
- package/src/layouts/SectionLayout.tsx +14 -0
- package/src/layouts/SideCodeLayout.tsx +44 -0
- package/src/layouts/SideImageLayout.tsx +82 -0
- package/src/layouts/SideLayout.tsx +31 -0
- package/src/layouts/columns.tsx +56 -0
- package/src/layouts/index.tsx +19 -0
- package/src/layouts/styled.ts +7 -0
- package/src/layouts/utils.ts +66 -0
- package/src/node.d.ts +5 -0
- package/src/style.d.ts +10 -0
- package/src/template.tsx +25 -0
- package/src/theme.ts +28 -0
- package/tsconfig.json +29 -0
- /package/{SlideWrapper.d.ts → dist/SlideWrapper.d.ts} +0 -0
- /package/{colors.d.ts → dist/colors.d.ts} +0 -0
- /package/{components → dist/components}/CodeStepper/CodeStepper.d.ts +0 -0
- /package/{components → dist/components}/CodeStepper/code-directives.d.ts +0 -0
- /package/{components → dist/components}/DocumentationItem.d.ts +0 -0
- /package/{components → dist/components}/FilePane.d.ts +0 -0
- /package/{components → dist/components}/HorizontalList.d.ts +0 -0
- /package/{components → dist/components}/IconBox.d.ts +0 -0
- /package/{components → dist/components}/Image.d.ts +0 -0
- /package/{components → dist/components}/ItemsColumn.d.ts +0 -0
- /package/{components → dist/components}/QRCode.d.ts +0 -0
- /package/{components → dist/components}/Timeline.d.ts +0 -0
- /package/{components → dist/components}/Timeline.styled.d.ts +0 -0
- /package/{components → dist/components}/map.d.ts +0 -0
- /package/{components → dist/components}/styled.d.ts +0 -0
- /package/{context.d.ts → dist/context.d.ts} +0 -0
- /package/{index.d.ts → dist/index.d.ts} +0 -0
- /package/{layouts → dist/layouts}/BaseLayout.d.ts +0 -0
- /package/{layouts → dist/layouts}/CenteredLayout.d.ts +0 -0
- /package/{layouts → dist/layouts}/Default3Layout.d.ts +0 -0
- /package/{layouts → dist/layouts}/MainSectionLayout.d.ts +0 -0
- /package/{layouts → dist/layouts}/QuoteLayout.d.ts +0 -0
- /package/{layouts → dist/layouts}/SectionLayout.d.ts +0 -0
- /package/{layouts → dist/layouts}/SideCodeLayout.d.ts +0 -0
- /package/{layouts → dist/layouts}/SideImageLayout.d.ts +0 -0
- /package/{layouts → dist/layouts}/SideLayout.d.ts +0 -0
- /package/{layouts → dist/layouts}/columns.d.ts +0 -0
- /package/{layouts → dist/layouts}/index.d.ts +0 -0
- /package/{layouts → dist/layouts}/styled.d.ts +0 -0
- /package/{layouts → dist/layouts}/utils.d.ts +0 -0
- /package/{template.d.ts → dist/template.d.ts} +0 -0
- /package/{theme.d.ts → dist/theme.d.ts} +0 -0
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { mdxComponentMap } from "spectacle";
|
|
3
|
+
import {
|
|
4
|
+
CustomHeading,
|
|
5
|
+
CustomQuote,
|
|
6
|
+
HeadingThree,
|
|
7
|
+
HeadingTwo,
|
|
8
|
+
InlineCode,
|
|
9
|
+
Image,
|
|
10
|
+
} from "./styled";
|
|
11
|
+
|
|
12
|
+
import CodeStepper from "./CodeStepper/CodeStepper";
|
|
13
|
+
import { QRCode } from "./QRCode";
|
|
14
|
+
|
|
15
|
+
const componentsMap = {
|
|
16
|
+
...mdxComponentMap,
|
|
17
|
+
inlineCode: (props: React.ComponentPropsWithoutRef<"code">) => (
|
|
18
|
+
<InlineCode
|
|
19
|
+
{...props}
|
|
20
|
+
style={{
|
|
21
|
+
fontWeight: 500,
|
|
22
|
+
display: "inline-block",
|
|
23
|
+
}}
|
|
24
|
+
/>
|
|
25
|
+
),
|
|
26
|
+
table: (props: React.ComponentPropsWithoutRef<"table">) => (
|
|
27
|
+
<table
|
|
28
|
+
{...props}
|
|
29
|
+
style={{
|
|
30
|
+
borderCollapse: "collapse",
|
|
31
|
+
width: "100%",
|
|
32
|
+
textAlign: "center",
|
|
33
|
+
}}
|
|
34
|
+
/>
|
|
35
|
+
),
|
|
36
|
+
tr: (props: React.ComponentPropsWithoutRef<"tr">) => (
|
|
37
|
+
<tr
|
|
38
|
+
{...props}
|
|
39
|
+
style={{
|
|
40
|
+
textAlign: "center",
|
|
41
|
+
color: "white",
|
|
42
|
+
fontFamily: 'Bitter,"Helvetica Neue",Helvetica,Arial,sans-serif',
|
|
43
|
+
fontSize: 24,
|
|
44
|
+
}}
|
|
45
|
+
/>
|
|
46
|
+
),
|
|
47
|
+
td: (props: React.ComponentPropsWithoutRef<"td">) => (
|
|
48
|
+
<td
|
|
49
|
+
{...props}
|
|
50
|
+
style={{
|
|
51
|
+
textAlign: "center",
|
|
52
|
+
padding: "0.3rem 0",
|
|
53
|
+
color: "white",
|
|
54
|
+
fontFamily: 'Bitter,"Helvetica Neue",Helvetica,Arial,sans-serif',
|
|
55
|
+
fontSize: 24,
|
|
56
|
+
}}
|
|
57
|
+
/>
|
|
58
|
+
),
|
|
59
|
+
h1: (props: React.ComponentProps<"h1">) => (
|
|
60
|
+
<CustomHeading
|
|
61
|
+
fontSize="h1"
|
|
62
|
+
color="white"
|
|
63
|
+
style={{
|
|
64
|
+
fontWeight: 500,
|
|
65
|
+
fontFamily: 'Bitter,"Helvetica Neue",Helvetica,Arial,sans-serif',
|
|
66
|
+
fontSize: 67,
|
|
67
|
+
flex: "0 1 65vw",
|
|
68
|
+
maxWidth: "65%",
|
|
69
|
+
textAlign: "left",
|
|
70
|
+
}}
|
|
71
|
+
>
|
|
72
|
+
{props.children}
|
|
73
|
+
</CustomHeading>
|
|
74
|
+
),
|
|
75
|
+
h2: (props: React.ComponentProps<"h2">) => (
|
|
76
|
+
<HeadingTwo>{props.children}</HeadingTwo>
|
|
77
|
+
),
|
|
78
|
+
h3: (props: React.ComponentPropsWithoutRef<"h3">) => (
|
|
79
|
+
<HeadingThree {...props} />
|
|
80
|
+
),
|
|
81
|
+
img: (props: React.ComponentProps<typeof Image>) => <Image {...props} />,
|
|
82
|
+
pre: CodeStepper,
|
|
83
|
+
li: (props: React.ComponentProps<"li">) => (
|
|
84
|
+
<li {...props} style={{ margin: "24px 0" }} />
|
|
85
|
+
),
|
|
86
|
+
Side: (props: React.ComponentProps<"div">) => <div {...props} />,
|
|
87
|
+
p: (props: React.ComponentProps<"p">) => {
|
|
88
|
+
const Text = mdxComponentMap.p!;
|
|
89
|
+
return (
|
|
90
|
+
<Text
|
|
91
|
+
style={{ margin: "8px 0", padding: "8px 0", lineHeight: "2rem" }}
|
|
92
|
+
{...props}
|
|
93
|
+
/>
|
|
94
|
+
);
|
|
95
|
+
},
|
|
96
|
+
blockquote: (props: React.ComponentProps<"blockquote">) => (
|
|
97
|
+
<CustomQuote {...props} />
|
|
98
|
+
),
|
|
99
|
+
a: ({ children, ...props }: React.ComponentProps<"a">) => {
|
|
100
|
+
const domain = new URL(props.href || "").hostname;
|
|
101
|
+
return (
|
|
102
|
+
<a
|
|
103
|
+
{...props}
|
|
104
|
+
style={{ color: "var(--color-secondary)", textDecoration: "none" }}
|
|
105
|
+
>
|
|
106
|
+
{children}{" "}
|
|
107
|
+
<small
|
|
108
|
+
style={{
|
|
109
|
+
color: "#ffffff44",
|
|
110
|
+
}}
|
|
111
|
+
>
|
|
112
|
+
({domain})
|
|
113
|
+
</small>
|
|
114
|
+
</a>
|
|
115
|
+
);
|
|
116
|
+
},
|
|
117
|
+
directive: (props: React.ComponentProps<"div">) => {
|
|
118
|
+
// @ts-expect-error
|
|
119
|
+
if (props._name === "qrcode") {
|
|
120
|
+
// @ts-expect-error
|
|
121
|
+
const url = React.Children.toArray(props.children)[0].props.href;
|
|
122
|
+
return <QRCode url={url} />;
|
|
123
|
+
}
|
|
124
|
+
return <div {...props} />;
|
|
125
|
+
},
|
|
126
|
+
} as const;
|
|
127
|
+
|
|
128
|
+
export default componentsMap;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import {
|
|
3
|
+
Link as SpectacleLink,
|
|
4
|
+
Image as SpectacleImage,
|
|
5
|
+
Heading,
|
|
6
|
+
FlexBox,
|
|
7
|
+
} from "spectacle";
|
|
8
|
+
import styled from "styled-components";
|
|
9
|
+
|
|
10
|
+
export const Link = (props: { href: string; children: React.ReactNode }) => (
|
|
11
|
+
<SpectacleLink href={props.href} target="_blank" rel="noopener noreferrer">
|
|
12
|
+
{props.children} [{props.href}]
|
|
13
|
+
</SpectacleLink>
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
const StyledImage = styled(SpectacleImage)`
|
|
17
|
+
object-fit: contain;
|
|
18
|
+
max-height: 30vh;
|
|
19
|
+
max-width: 70vw;
|
|
20
|
+
`;
|
|
21
|
+
|
|
22
|
+
export const Image = (props: React.ComponentProps<typeof SpectacleImage>) => (
|
|
23
|
+
<FlexBox margin="0 0" padding="0 0">
|
|
24
|
+
<StyledImage {...props} />
|
|
25
|
+
</FlexBox>
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
export const CustomHeading = styled(Heading)`
|
|
29
|
+
strong {
|
|
30
|
+
color: var(--color-secondary);
|
|
31
|
+
font-weight: 500;
|
|
32
|
+
}
|
|
33
|
+
`;
|
|
34
|
+
|
|
35
|
+
export const CustomQuote = styled.blockquote`
|
|
36
|
+
margin: 1rem 0;
|
|
37
|
+
padding-left: 1.5rem;
|
|
38
|
+
padding-top: 0;
|
|
39
|
+
padding-bottom: 0;
|
|
40
|
+
opacity: 0.8;
|
|
41
|
+
|
|
42
|
+
> * {
|
|
43
|
+
padding: 0 !important;
|
|
44
|
+
}
|
|
45
|
+
`;
|
|
46
|
+
|
|
47
|
+
export const InlineCode = styled.code`
|
|
48
|
+
filter: brightness(1.05);
|
|
49
|
+
zoom: 1.1;
|
|
50
|
+
&:before,
|
|
51
|
+
&:after {
|
|
52
|
+
content: "\`";
|
|
53
|
+
font-size: 0.8em;
|
|
54
|
+
}
|
|
55
|
+
`;
|
|
56
|
+
|
|
57
|
+
export const HeadingTwo = styled.h2`
|
|
58
|
+
font-family: Bitter, \"Helvetica Neue\", Helvetica, Arial, sans-serif;
|
|
59
|
+
font-size: 55px;
|
|
60
|
+
font-weight: 400;
|
|
61
|
+
`;
|
|
62
|
+
|
|
63
|
+
export const HeadingThree = styled.h3`
|
|
64
|
+
font-family: Bitter, \"Helvetica Neue\", Helvetica, Arial, sans-serif;
|
|
65
|
+
font-size: 40px;
|
|
66
|
+
font-weight: 400;
|
|
67
|
+
margin-top: 0;
|
|
68
|
+
|
|
69
|
+
strong {
|
|
70
|
+
color: var(--color-secondary);
|
|
71
|
+
font-weight: 500;
|
|
72
|
+
}
|
|
73
|
+
`;
|
package/src/context.tsx
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
export type LayoutComponent = React.ComponentType<any>;
|
|
4
|
+
|
|
5
|
+
export interface IPestacleContext {
|
|
6
|
+
layouts: Record<string, LayoutComponent>;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const PestacleContext = React.createContext<
|
|
10
|
+
IPestacleContext | undefined
|
|
11
|
+
>(undefined);
|
|
12
|
+
|
|
13
|
+
export function usePestacle() {
|
|
14
|
+
const context = React.useContext(PestacleContext);
|
|
15
|
+
if (!context) {
|
|
16
|
+
throw new Error("usePestacle must be used within a PestacleProvider");
|
|
17
|
+
}
|
|
18
|
+
return context;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function PestacleProvider({
|
|
22
|
+
children,
|
|
23
|
+
layouts,
|
|
24
|
+
}: {
|
|
25
|
+
children: React.ReactNode;
|
|
26
|
+
layouts: Record<string, LayoutComponent>;
|
|
27
|
+
}) {
|
|
28
|
+
return (
|
|
29
|
+
<PestacleContext.Provider value={{ layouts }}>
|
|
30
|
+
{children}
|
|
31
|
+
</PestacleContext.Provider>
|
|
32
|
+
);
|
|
33
|
+
}
|
package/src/front.png
ADDED
|
Binary file
|
package/src/index.tsx
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { MDXProvider } from "@mdx-js/react";
|
|
3
|
+
import { Deck as SpectacleDeck, Slide } from "spectacle";
|
|
4
|
+
|
|
5
|
+
import Layouts from "./layouts";
|
|
6
|
+
import { default as baseTheme } from "./theme";
|
|
7
|
+
import { template } from "./template";
|
|
8
|
+
import customComponents from "./components/map";
|
|
9
|
+
import { createGlobalStyle } from "styled-components";
|
|
10
|
+
import { SlideWrapper } from "./SlideWrapper";
|
|
11
|
+
import { LayoutComponent, PestacleProvider } from "./context";
|
|
12
|
+
import { createCssVariables } from "./colors";
|
|
13
|
+
|
|
14
|
+
export * from "spectacle";
|
|
15
|
+
|
|
16
|
+
export { default as FilePane } from "./components/FilePane";
|
|
17
|
+
export { ItemsColumn } from "./components/ItemsColumn";
|
|
18
|
+
export { Doc, DocItem } from "./components/DocumentationItem";
|
|
19
|
+
export { Image } from "./components/Image";
|
|
20
|
+
export {
|
|
21
|
+
default as HorizontalList,
|
|
22
|
+
HorizontalListItem,
|
|
23
|
+
} from "./components/HorizontalList";
|
|
24
|
+
export { default as Timeline, TimelineItem } from "./components/Timeline";
|
|
25
|
+
export { IconBox } from "./components/IconBox";
|
|
26
|
+
|
|
27
|
+
export type SlideType = {
|
|
28
|
+
metadata: Record<string, unknown> & { layout?: string };
|
|
29
|
+
slideComponent: React.ElementType<unknown>;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export type DeckType = {
|
|
33
|
+
metadata: Record<string, unknown>;
|
|
34
|
+
slides: SlideType[];
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export function PassThrough({ children }: { children: React.ReactNode }) {
|
|
38
|
+
return <>{children}</>;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export const layouts = Layouts;
|
|
42
|
+
|
|
43
|
+
interface ThemeOptions {
|
|
44
|
+
themeTokens: {
|
|
45
|
+
colors: Record<string, string>;
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const componentsMap = {
|
|
50
|
+
...customComponents,
|
|
51
|
+
wrapper: SlideWrapper,
|
|
52
|
+
};
|
|
53
|
+
export function Deck({
|
|
54
|
+
deck,
|
|
55
|
+
theme,
|
|
56
|
+
layouts = Layouts,
|
|
57
|
+
}: {
|
|
58
|
+
deck: DeckType;
|
|
59
|
+
theme: ThemeOptions;
|
|
60
|
+
layouts?: Record<string, LayoutComponent>;
|
|
61
|
+
}) {
|
|
62
|
+
React.useEffect(() => {
|
|
63
|
+
document.title = (deck.metadata.title as string) || "Untitled";
|
|
64
|
+
}, [deck.metadata.title]);
|
|
65
|
+
|
|
66
|
+
const GlobalStyle = React.useMemo(() => {
|
|
67
|
+
const cssVariables = createCssVariables(theme.themeTokens.colors);
|
|
68
|
+
return createGlobalStyle`
|
|
69
|
+
:root {
|
|
70
|
+
${cssVariables}
|
|
71
|
+
--font-family: ${baseTheme.fonts.text}
|
|
72
|
+
}
|
|
73
|
+
`;
|
|
74
|
+
}, [theme]);
|
|
75
|
+
|
|
76
|
+
return (
|
|
77
|
+
<React.StrictMode>
|
|
78
|
+
<PestacleProvider layouts={layouts}>
|
|
79
|
+
<MDXProvider components={componentsMap}>
|
|
80
|
+
<GlobalStyle />
|
|
81
|
+
<SpectacleDeck
|
|
82
|
+
theme={{ ...baseTheme, ...theme.themeTokens }}
|
|
83
|
+
template={template}
|
|
84
|
+
>
|
|
85
|
+
{deck.slides.map((slide, i) => {
|
|
86
|
+
const Component = slide.slideComponent;
|
|
87
|
+
return (
|
|
88
|
+
<Slide key={i}>
|
|
89
|
+
<Component />
|
|
90
|
+
</Slide>
|
|
91
|
+
);
|
|
92
|
+
})}
|
|
93
|
+
</SpectacleDeck>
|
|
94
|
+
</MDXProvider>
|
|
95
|
+
</PestacleProvider>
|
|
96
|
+
</React.StrictMode>
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export function Danger({ children }: { children: React.ReactNode }) {
|
|
101
|
+
return <div style={{ color: "red" }}>{children}</div>;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export function Information({ children }: { children: React.ReactNode }) {
|
|
105
|
+
return <div style={{ color: "orange" }}>{children}</div>;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export function Success({ children }: { children: React.ReactNode }) {
|
|
109
|
+
return <div style={{ color: "green" }}>{children}</div>;
|
|
110
|
+
}
|
|
111
|
+
export function Warning({ children }: { children: React.ReactNode }) {
|
|
112
|
+
return <div style={{ color: "yellow" }}>{children}</div>;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export function Side({ children }: { children: React.ReactNode }) {
|
|
116
|
+
return <div>{children}</div>;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
Side.mdxType = "Side";
|
|
120
|
+
|
|
121
|
+
export function Documentation({ children }: { children: React.ReactNode }) {
|
|
122
|
+
return <div>{children}</div>;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export function Box({ children }: { children: React.ReactNode }) {
|
|
126
|
+
return <div>{children}</div>;
|
|
127
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import styled from "styled-components";
|
|
3
|
+
|
|
4
|
+
const DefaultLayoutHeading = styled.div`
|
|
5
|
+
background-color: #ffffff11;
|
|
6
|
+
padding: 2rem 5rem;
|
|
7
|
+
margin-bottom: 1rem;
|
|
8
|
+
|
|
9
|
+
h2 {
|
|
10
|
+
margin: 0;
|
|
11
|
+
}
|
|
12
|
+
`;
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
export const BaseLayout = ({
|
|
16
|
+
children,
|
|
17
|
+
title,
|
|
18
|
+
...otherProps
|
|
19
|
+
}: {
|
|
20
|
+
children: React.ReactNode;
|
|
21
|
+
title?: React.ReactNode;
|
|
22
|
+
} & Omit<React.ComponentPropsWithoutRef<"div">, "title">) => {
|
|
23
|
+
return (
|
|
24
|
+
<div
|
|
25
|
+
{...otherProps}
|
|
26
|
+
style={{
|
|
27
|
+
position: "absolute",
|
|
28
|
+
top: 0,
|
|
29
|
+
right: 0,
|
|
30
|
+
bottom: 0,
|
|
31
|
+
left: 0,
|
|
32
|
+
display: "flex",
|
|
33
|
+
flexDirection: "column",
|
|
34
|
+
marginBottom: "5rem",
|
|
35
|
+
}}
|
|
36
|
+
>
|
|
37
|
+
{title && <DefaultLayoutHeading>{title}</DefaultLayoutHeading>}
|
|
38
|
+
<div
|
|
39
|
+
style={{
|
|
40
|
+
display: "flex",
|
|
41
|
+
flexDirection: "column",
|
|
42
|
+
justifyContent: "center",
|
|
43
|
+
height: "100%",
|
|
44
|
+
padding: "0 4rem",
|
|
45
|
+
flex: 1,
|
|
46
|
+
}}
|
|
47
|
+
>
|
|
48
|
+
{children}
|
|
49
|
+
</div>
|
|
50
|
+
</div>
|
|
51
|
+
);
|
|
52
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import styled from "styled-components";
|
|
3
|
+
import { Margins, getHeading } from "./utils";
|
|
4
|
+
|
|
5
|
+
const CenteredLayoutContent = styled.div`
|
|
6
|
+
h2,
|
|
7
|
+
h3 {
|
|
8
|
+
}
|
|
9
|
+
`;
|
|
10
|
+
export const CenteredLayout = (
|
|
11
|
+
props: React.ComponentPropsWithoutRef<"div">
|
|
12
|
+
) => {
|
|
13
|
+
const [heading, rest] = getHeading(props.children);
|
|
14
|
+
return (
|
|
15
|
+
<div
|
|
16
|
+
{...props}
|
|
17
|
+
style={{
|
|
18
|
+
height: "100%",
|
|
19
|
+
display: "flex",
|
|
20
|
+
flexFlow: "column",
|
|
21
|
+
alignItems: "center",
|
|
22
|
+
justifyContent: "center",
|
|
23
|
+
margin: `0 ${Margins.horizontal}`,
|
|
24
|
+
}}
|
|
25
|
+
>
|
|
26
|
+
{rest}
|
|
27
|
+
<CenteredLayoutContent
|
|
28
|
+
style={{
|
|
29
|
+
position: "absolute",
|
|
30
|
+
opacity: 0.8,
|
|
31
|
+
marginBottom: "2rem",
|
|
32
|
+
marginTop: "2rem",
|
|
33
|
+
bottom: 0,
|
|
34
|
+
}}
|
|
35
|
+
>
|
|
36
|
+
{heading}
|
|
37
|
+
</CenteredLayoutContent>
|
|
38
|
+
</div>
|
|
39
|
+
);
|
|
40
|
+
};
|