@gpichot/spectacle-deck 1.0.9 → 1.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 → dist/components}/Timeline.d.ts +2 -0
- package/dist/components/Timeline.styled.d.ts +7 -0
- package/dist/components/styled.d.ts +12 -0
- package/{index.cjs → dist/index.cjs} +233 -144
- package/{index.mjs → dist/index.mjs} +232 -143
- package/dist/layouts/QuoteLayout.d.ts +6 -0
- package/dist/layouts/SectionLayout.d.ts +2 -0
- package/dist/layouts/index.d.ts +25 -0
- package/dist/layouts/styled.d.ts +2 -0
- package/dist/package.json +30 -0
- package/package.json +23 -19
- package/scripts/bundle.ts +84 -0
- package/src/components/CodeStepper/CodeStepper.tsx +223 -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 +140 -0
- package/src/components/IconBox.tsx +31 -0
- package/src/components/Image.tsx +34 -0
- package/src/components/ItemsColumn.tsx +56 -0
- package/src/components/Timeline.styled.tsx +24 -0
- package/src/components/Timeline.tsx +159 -0
- package/src/components/map.tsx +115 -0
- package/src/components/styled.tsx +73 -0
- package/src/front.png +0 -0
- package/src/index.tsx +109 -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 +99 -0
- package/src/layouts/SectionLayout.tsx +14 -0
- package/src/layouts/SideCodeLayout.tsx +44 -0
- package/src/layouts/SideImageLayout.tsx +72 -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 +65 -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 +24 -0
- package/test.js +106 -0
- package/tsconfig.json +29 -0
- package/components/Timeline.styled.d.ts +0 -1361
- package/components/styled.d.ts +0 -1097
- package/layouts/SectionLayout.d.ts +0 -274
- package/layouts/index.d.ts +0 -295
- package/layouts/styled.d.ts +0 -283
- /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}/map.d.ts +0 -0
- /package/{index.d.ts → dist/index.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}/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}/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,56 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import styled from "styled-components";
|
|
3
|
+
|
|
4
|
+
const DivWithHeading = styled.div`
|
|
5
|
+
h2 {
|
|
6
|
+
margin-top: 0;
|
|
7
|
+
}
|
|
8
|
+
h2 strong {
|
|
9
|
+
color: #f49676;
|
|
10
|
+
font-weight: 400;
|
|
11
|
+
}
|
|
12
|
+
`;
|
|
13
|
+
|
|
14
|
+
const ColumnsContainer = styled(DivWithHeading)`
|
|
15
|
+
display: flex;
|
|
16
|
+
flex-direction: row;
|
|
17
|
+
position: absolute;
|
|
18
|
+
left: 0;
|
|
19
|
+
right: 0;
|
|
20
|
+
top: 0;
|
|
21
|
+
bottom: 0;
|
|
22
|
+
alignitems: center;
|
|
23
|
+
`;
|
|
24
|
+
|
|
25
|
+
export function ColumnsLayout({
|
|
26
|
+
children,
|
|
27
|
+
reverse,
|
|
28
|
+
}: {
|
|
29
|
+
children: React.ReactNode;
|
|
30
|
+
reverse?: boolean;
|
|
31
|
+
}) {
|
|
32
|
+
const childrenArray = React.Children.toArray(children);
|
|
33
|
+
return (
|
|
34
|
+
<ColumnsContainer
|
|
35
|
+
style={{
|
|
36
|
+
flexDirection: reverse ? "row-reverse" : "row",
|
|
37
|
+
}}
|
|
38
|
+
>
|
|
39
|
+
{childrenArray.map((child, i) => (
|
|
40
|
+
<div
|
|
41
|
+
key={i}
|
|
42
|
+
style={{
|
|
43
|
+
flex: 1,
|
|
44
|
+
height: "100%",
|
|
45
|
+
display: "flex",
|
|
46
|
+
flexFlow: "column",
|
|
47
|
+
justifyContent: "center",
|
|
48
|
+
boxSizing: "border-box",
|
|
49
|
+
}}
|
|
50
|
+
>
|
|
51
|
+
{child}
|
|
52
|
+
</div>
|
|
53
|
+
))}
|
|
54
|
+
</ColumnsContainer>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { CenteredLayout } from "./CenteredLayout";
|
|
2
|
+
import { Default3Layout } from "./Default3Layout";
|
|
3
|
+
import { MainSectionLayout } from "./MainSectionLayout";
|
|
4
|
+
import { QuoteLayout } from "./QuoteLayout";
|
|
5
|
+
import { SectionLayout } from "./SectionLayout";
|
|
6
|
+
import { SidedCodeLayout } from "./SideCodeLayout";
|
|
7
|
+
import { SidedImageLayout } from "./SideImageLayout";
|
|
8
|
+
import { SideLayout } from "./SideLayout";
|
|
9
|
+
|
|
10
|
+
export default {
|
|
11
|
+
mainSection: MainSectionLayout,
|
|
12
|
+
centered: CenteredLayout,
|
|
13
|
+
default3: Default3Layout,
|
|
14
|
+
quote: QuoteLayout,
|
|
15
|
+
sidedCode: SidedCodeLayout,
|
|
16
|
+
sidedImage: SidedImageLayout,
|
|
17
|
+
side: SideLayout,
|
|
18
|
+
section: SectionLayout,
|
|
19
|
+
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
export const Margins = {
|
|
4
|
+
vertical: "4rem",
|
|
5
|
+
horizontal: "7rem",
|
|
6
|
+
horizontalInternal: "2rem",
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export function getHeading(children: React.ReactNode) {
|
|
10
|
+
const allChild = React.Children.toArray(children);
|
|
11
|
+
if (allChild.length === 0) return [null, allChild];
|
|
12
|
+
const [candidate, ...rest] = allChild;
|
|
13
|
+
if (!React.isValidElement(candidate)) return [null, allChild];
|
|
14
|
+
if (["h2", "h3"].includes(candidate.props.originalType)) {
|
|
15
|
+
return [candidate, rest];
|
|
16
|
+
}
|
|
17
|
+
return [null, allChild];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function getCode(children: React.ReactNode) {
|
|
21
|
+
const allChild = React.Children.toArray(children);
|
|
22
|
+
|
|
23
|
+
if (allChild.length === 0) return [null, allChild];
|
|
24
|
+
|
|
25
|
+
const index = allChild.findIndex((child) => {
|
|
26
|
+
if (!React.isValidElement(child)) return false;
|
|
27
|
+
return child.props.originalType === "pre";
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
if (index === -1) return [null, allChild];
|
|
31
|
+
|
|
32
|
+
const candidate = allChild[index];
|
|
33
|
+
const rest = allChild.filter((_, i) => i !== index);
|
|
34
|
+
return [candidate, rest];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function getMatchingMdxType(children: React.ReactNode, mdxType: string) {
|
|
38
|
+
const allChild = React.Children.toArray(children);
|
|
39
|
+
|
|
40
|
+
const matchFn = (child: React.ReactNode) => {
|
|
41
|
+
if (!React.isValidElement(child)) return false;
|
|
42
|
+
if (typeof child.type !== "function") return false;
|
|
43
|
+
if ("mdxType" in child.type === false) return false;
|
|
44
|
+
|
|
45
|
+
return child.type.mdxType === mdxType;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const matches = allChild.filter(matchFn);
|
|
49
|
+
|
|
50
|
+
const rest = allChild.filter((child) => !matchFn(child));
|
|
51
|
+
|
|
52
|
+
return [matches, rest];
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function getCodeChildren(children: React.ReactNode) {
|
|
56
|
+
const [code, rest] = getCode(children);
|
|
57
|
+
if (code) return [code, rest];
|
|
58
|
+
|
|
59
|
+
const [codeStepper, rest2] = getMatchingMdxType(children, "CodeStepper");
|
|
60
|
+
if (codeStepper.length > 0) return [codeStepper, rest2];
|
|
61
|
+
|
|
62
|
+
const [codes, rest3] = getMatchingMdxType(children, "FilePane");
|
|
63
|
+
|
|
64
|
+
return [codes, rest3];
|
|
65
|
+
}
|
package/src/node.d.ts
ADDED
package/src/style.d.ts
ADDED
package/src/template.tsx
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
import { Box, FullScreen } from "spectacle";
|
|
4
|
+
|
|
5
|
+
export const template = ({ slideNumber, numberOfSlides }) => {
|
|
6
|
+
const percentage = (slideNumber / numberOfSlides) * 100;
|
|
7
|
+
return (
|
|
8
|
+
<div style={{ position: "absolute", bottom: 0, left: 0, right: 0 }}>
|
|
9
|
+
<Box padding="0 0 0.5em 0.7em">
|
|
10
|
+
<FullScreen />
|
|
11
|
+
</Box>
|
|
12
|
+
|
|
13
|
+
<div style={{ width: "100%", height: "4px", background: "#ffffff11" }}>
|
|
14
|
+
<div
|
|
15
|
+
style={{
|
|
16
|
+
width: `${percentage}%`,
|
|
17
|
+
height: "2px",
|
|
18
|
+
background: "#ffffff77",
|
|
19
|
+
transition: "width 0.3s ease",
|
|
20
|
+
}}
|
|
21
|
+
/>
|
|
22
|
+
</div>
|
|
23
|
+
</div>
|
|
24
|
+
);
|
|
25
|
+
};
|
package/src/theme.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import "@fontsource/bitter/300.css";
|
|
2
|
+
import "@fontsource/bitter/400.css";
|
|
3
|
+
import "@fontsource/bitter/500.css";
|
|
4
|
+
import "@fontsource/bitter/700.css";
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
colors: {
|
|
8
|
+
primary: "white",
|
|
9
|
+
secondary: "#F49676",
|
|
10
|
+
tertiary: "#042F3B",
|
|
11
|
+
},
|
|
12
|
+
fonts: {
|
|
13
|
+
header: 'Bitter, "Helvetica Neue", Helvetica, Arial, sans-serif',
|
|
14
|
+
text: 'Bitter, "Helvetica Neue", Helvetica, Arial, sans-serif',
|
|
15
|
+
},
|
|
16
|
+
fontSizes: {
|
|
17
|
+
h1: "48px",
|
|
18
|
+
h2: "32px",
|
|
19
|
+
h3: "24px",
|
|
20
|
+
text: "24px",
|
|
21
|
+
monospace: "16px",
|
|
22
|
+
},
|
|
23
|
+
space: [8, 16, 24],
|
|
24
|
+
};
|
package/test.js
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { Timeline, TimelineItem } from "@gpichot/spectacle-deck";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import {Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs} from "react/jsx-runtime";import {useMDXComponents as _provideComponents} from "@mdx-js/react"
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
metadata: {"author":"Gabriel"},
|
|
9
|
+
slides: [{
|
|
10
|
+
metadata: {"layout":"mainSection"},
|
|
11
|
+
slideComponent: (baseProps) => {
|
|
12
|
+
const props = {...baseProps, frontmatter: {"layout":"mainSection"} };
|
|
13
|
+
const _components = {
|
|
14
|
+
h1: "h1",
|
|
15
|
+
strong: "strong",
|
|
16
|
+
..._provideComponents(),
|
|
17
|
+
...props.components
|
|
18
|
+
};
|
|
19
|
+
const {wrapper: MDXLayout} = _components;
|
|
20
|
+
return _jsxs(_components.h1, {
|
|
21
|
+
children: ["Hello, ", _jsx(_components.strong, {
|
|
22
|
+
children: "world!"
|
|
23
|
+
})]
|
|
24
|
+
})});
|
|
25
|
+
}
|
|
26
|
+
},{
|
|
27
|
+
metadata: {"layout":"centered"},
|
|
28
|
+
slideComponent: (baseProps) => {
|
|
29
|
+
const props = {...baseProps, frontmatter: {"layout":"centered"} };
|
|
30
|
+
const _components = {
|
|
31
|
+
h3: "h3",
|
|
32
|
+
p: "p",
|
|
33
|
+
strong: "strong",
|
|
34
|
+
..._provideComponents(),
|
|
35
|
+
...props.components
|
|
36
|
+
};
|
|
37
|
+
const {wrapper: MDXLayout} = _components;
|
|
38
|
+
return _jsx(MDXLayout, {...props,
|
|
39
|
+
children: [_jsx(_components.h3, {
|
|
40
|
+
children: _jsx(_components.strong, {
|
|
41
|
+
children: "History"
|
|
42
|
+
})
|
|
43
|
+
}), "\n", _jsxs(Timeline, {
|
|
44
|
+
children: [_jsx(TimelineItem, {
|
|
45
|
+
title: "2011",
|
|
46
|
+
children: _jsx(_components.p, {
|
|
47
|
+
children: "Created by Jordan Walke, a software engineer at Facebook."
|
|
48
|
+
})
|
|
49
|
+
}), _jsx(TimelineItem, {
|
|
50
|
+
title: "May 2013",
|
|
51
|
+
children: _jsxs(_components.p, {
|
|
52
|
+
children: ["⚛️ ", _jsx(_components.strong, {
|
|
53
|
+
children: "React"
|
|
54
|
+
}), " is open sourced."]
|
|
55
|
+
})
|
|
56
|
+
}), _jsx(TimelineItem, {
|
|
57
|
+
title: "March 2015",
|
|
58
|
+
children: _jsx(_components.p, {
|
|
59
|
+
children: "📱 React Native"
|
|
60
|
+
})
|
|
61
|
+
}), _jsx(TimelineItem, {
|
|
62
|
+
title: "Feb 2019",
|
|
63
|
+
children: _jsxs(_components.p, {
|
|
64
|
+
children: [_jsx(_components.strong, {
|
|
65
|
+
children: "v16.8:"
|
|
66
|
+
}), " React Hooks 🤘"]
|
|
67
|
+
})
|
|
68
|
+
}), _jsx(TimelineItem, {
|
|
69
|
+
title: "Oct 2020",
|
|
70
|
+
children: _jsxs(_components.p, {
|
|
71
|
+
children: [_jsx(_components.strong, {
|
|
72
|
+
children: "v17"
|
|
73
|
+
}), ": 🤷♂️"]
|
|
74
|
+
})
|
|
75
|
+
}), _jsx(TimelineItem, {
|
|
76
|
+
title: "March 2022",
|
|
77
|
+
children: _jsxs(_components.p, {
|
|
78
|
+
children: [_jsx(_components.strong, {
|
|
79
|
+
children: "v18:"
|
|
80
|
+
}), " Concurrent React"]
|
|
81
|
+
})
|
|
82
|
+
})]
|
|
83
|
+
})]
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
},{
|
|
87
|
+
metadata: null,
|
|
88
|
+
slideComponent: (baseProps) => {
|
|
89
|
+
const props = {...baseProps, frontmatter: null };
|
|
90
|
+
const _components = {
|
|
91
|
+
code: "code",
|
|
92
|
+
pre: "pre",
|
|
93
|
+
..._provideComponents(),
|
|
94
|
+
...props.components
|
|
95
|
+
};
|
|
96
|
+
const {wrapper: MDXLayout} = _components;
|
|
97
|
+
return _jsx(MDXLayout, {...props, children: _jsx(_components.pre, {
|
|
98
|
+
children: _jsx(_components.code, {
|
|
99
|
+
className: "language-jsx",
|
|
100
|
+
children: "export default () => <div>Hello, world!</div>;\n"
|
|
101
|
+
})
|
|
102
|
+
})});
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
]
|
|
106
|
+
};
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
/* Target node 14 */
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"lib": ["ES2020"],
|
|
6
|
+
"target": "ES2020",
|
|
7
|
+
"skipLibCheck": true,
|
|
8
|
+
|
|
9
|
+
/* Transpile with esbuild */
|
|
10
|
+
"moduleResolution": "bundler",
|
|
11
|
+
"allowSyntheticDefaultImports": true,
|
|
12
|
+
|
|
13
|
+
/* Linting */
|
|
14
|
+
"strict": true,
|
|
15
|
+
"noUnusedLocals": true,
|
|
16
|
+
"noFallthroughCasesInSwitch": true,
|
|
17
|
+
"useUnknownInCatchVariables": true,
|
|
18
|
+
|
|
19
|
+
// Options
|
|
20
|
+
"outDir": "dist",
|
|
21
|
+
"baseUrl": "./src",
|
|
22
|
+
"esModuleInterop": true,
|
|
23
|
+
"declaration": true,
|
|
24
|
+
"jsx": "react",
|
|
25
|
+
"types": ["./src/node.d.ts"]
|
|
26
|
+
},
|
|
27
|
+
"include": ["src/**/*"],
|
|
28
|
+
"files": ["src/style.d.ts"]
|
|
29
|
+
}
|