@gpichot/spectacle-deck 1.1.0 → 1.1.2

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 (70) hide show
  1. package/{dist/components → components}/Timeline.d.ts +2 -0
  2. package/components/Timeline.styled.d.ts +7 -0
  3. package/components/styled.d.ts +12 -0
  4. package/layouts/SectionLayout.d.ts +2 -0
  5. package/layouts/index.d.ts +25 -0
  6. package/layouts/styled.d.ts +2 -0
  7. package/package.json +19 -23
  8. package/dist/components/Timeline.styled.d.ts +0 -1361
  9. package/dist/components/styled.d.ts +0 -1097
  10. package/dist/layouts/SectionLayout.d.ts +0 -274
  11. package/dist/layouts/index.d.ts +0 -297
  12. package/dist/layouts/styled.d.ts +0 -283
  13. package/dist/package.json +0 -30
  14. package/scripts/bundle.ts +0 -84
  15. package/src/components/CodeStepper/CodeStepper.tsx +0 -223
  16. package/src/components/CodeStepper/code-directives.test.ts +0 -58
  17. package/src/components/CodeStepper/code-directives.ts +0 -129
  18. package/src/components/DocumentationItem.tsx +0 -85
  19. package/src/components/FilePane.tsx +0 -18
  20. package/src/components/HorizontalList.tsx +0 -140
  21. package/src/components/IconBox.tsx +0 -31
  22. package/src/components/Image.tsx +0 -34
  23. package/src/components/ItemsColumn.tsx +0 -56
  24. package/src/components/Timeline.styled.tsx +0 -24
  25. package/src/components/Timeline.tsx +0 -157
  26. package/src/components/map.tsx +0 -115
  27. package/src/components/styled.tsx +0 -73
  28. package/src/front.png +0 -0
  29. package/src/index.tsx +0 -109
  30. package/src/layouts/CenteredLayout.tsx +0 -40
  31. package/src/layouts/Default3Layout.tsx +0 -159
  32. package/src/layouts/MainSectionLayout.tsx +0 -31
  33. package/src/layouts/QuoteLayout.tsx +0 -99
  34. package/src/layouts/SectionLayout.tsx +0 -14
  35. package/src/layouts/SideCodeLayout.tsx +0 -44
  36. package/src/layouts/SideImageLayout.tsx +0 -72
  37. package/src/layouts/SideLayout.tsx +0 -31
  38. package/src/layouts/columns.tsx +0 -56
  39. package/src/layouts/index.tsx +0 -19
  40. package/src/layouts/styled.ts +0 -7
  41. package/src/layouts/utils.ts +0 -65
  42. package/src/node.d.ts +0 -5
  43. package/src/style.d.ts +0 -10
  44. package/src/template.tsx +0 -25
  45. package/src/theme.ts +0 -24
  46. package/test.js +0 -106
  47. package/tsconfig.json +0 -29
  48. /package/{dist/components → components}/CodeStepper/CodeStepper.d.ts +0 -0
  49. /package/{dist/components → components}/CodeStepper/code-directives.d.ts +0 -0
  50. /package/{dist/components → components}/DocumentationItem.d.ts +0 -0
  51. /package/{dist/components → components}/FilePane.d.ts +0 -0
  52. /package/{dist/components → components}/HorizontalList.d.ts +0 -0
  53. /package/{dist/components → components}/IconBox.d.ts +0 -0
  54. /package/{dist/components → components}/Image.d.ts +0 -0
  55. /package/{dist/components → components}/ItemsColumn.d.ts +0 -0
  56. /package/{dist/components → components}/map.d.ts +0 -0
  57. /package/{dist/index.cjs → index.cjs} +0 -0
  58. /package/{dist/index.d.ts → index.d.ts} +0 -0
  59. /package/{dist/index.mjs → index.mjs} +0 -0
  60. /package/{dist/layouts → layouts}/CenteredLayout.d.ts +0 -0
  61. /package/{dist/layouts → layouts}/Default3Layout.d.ts +0 -0
  62. /package/{dist/layouts → layouts}/MainSectionLayout.d.ts +0 -0
  63. /package/{dist/layouts → layouts}/QuoteLayout.d.ts +0 -0
  64. /package/{dist/layouts → layouts}/SideCodeLayout.d.ts +0 -0
  65. /package/{dist/layouts → layouts}/SideImageLayout.d.ts +0 -0
  66. /package/{dist/layouts → layouts}/SideLayout.d.ts +0 -0
  67. /package/{dist/layouts → layouts}/columns.d.ts +0 -0
  68. /package/{dist/layouts → layouts}/utils.d.ts +0 -0
  69. /package/{dist/template.d.ts → template.d.ts} +0 -0
  70. /package/{dist/theme.d.ts → theme.d.ts} +0 -0
@@ -1,129 +0,0 @@
1
- /**
2
- * The Code Stepper component is a component that allows you to step through
3
- * the code using familiar directives.
4
- *
5
- * @example "@step showLines(1-3)" will show lines 1-3
6
- * @example "@step highlight(1-3)" will highlight lines 1-3
7
- *
8
- */
9
-
10
- function range(start: number, end: number) {
11
- return Array.from({ length: end - start + 1 }, (_, i) => i + start);
12
- }
13
-
14
- /**
15
- * Function parse ranges list
16
- */
17
- function parseRangeList(str: string): number[] {
18
- return str.split(',').reduce((acc, line) => {
19
- if (!line.includes('-')) return [...acc, parseInt(line, 10)];
20
-
21
- const [start, end] = line.split('-').map(Number);
22
- return [...acc, ...range(start, end)];
23
- }, [] as number[]);
24
- }
25
-
26
- /**
27
- * Parse showLines fn
28
- *
29
- * "showLines(1-3)" => [1, 2, 3]
30
- * "showLines(1,3)" => [1,3]
31
- * "showLines(1-2,4-5)" => [1,2,4,5]
32
- */
33
- function parseShowLines(directive: string): { showLines: number[] } | null {
34
- const match = directive.match(/showLines\((.*)\)/);
35
- if (!match) return null;
36
-
37
- const lines = parseRangeList(match[1]);
38
-
39
- return { showLines: lines };
40
- }
41
-
42
- /**
43
- * Parse highlight fn
44
- *
45
- * "highlight(1-3)" => [1,2,3]
46
- * etc.
47
- */
48
- function parseHighlight(directive: string): { highlight: number[] } | null {
49
- const match = directive.match(/highlight\((.*)\)/);
50
- if (!match) return null;
51
-
52
- const lines = parseRangeList(match[1]);
53
-
54
- return { highlight: lines };
55
- }
56
-
57
- type StepDirective = {
58
- showLines?: number[];
59
- highlight?: number[];
60
- name?: string;
61
- };
62
-
63
- /**
64
- * Parse name fn
65
- *
66
- * "name("my name")" => "my name"
67
- */
68
- function parseName(directive: string): { name: string } | null {
69
- const match = directive.match(/name\("(.*)"\)/);
70
- if (!match) return null;
71
-
72
- return { name: match[1] };
73
- }
74
-
75
- /**
76
- * Parse step directive
77
- *
78
- * @example "@step showLines(1-3) highlight(1-3)"
79
- * @example "@step showLines(1-3)"
80
- * @example "@step highlight(1-3)"
81
- */
82
- function parseStepDirective(directive: string): StepDirective {
83
- // Should match a showLines(1-3) or highlight(1-3) directive
84
- // Should match name("(string)")
85
- const regex = /showLines\([^)]+\)|highlight\([^)]+\)|name\("(.*)"\)/g;
86
-
87
- const directives = directive.match(regex) || [];
88
-
89
- const name = directives.map(parseName).find(Boolean);
90
- const showLines = directives.map(parseShowLines).find(Boolean);
91
- const highlight = directives.map(parseHighlight).find(Boolean);
92
-
93
- return { ...showLines, ...highlight, ...name };
94
- }
95
-
96
- export type Step = {
97
- hiddenLines: number[];
98
- highlight: number[];
99
- name?: string;
100
- };
101
-
102
- /**
103
- * Reduce steps directives
104
- */
105
- export function combineStepDirectives(directives: StepDirective[]): Step[] {
106
- let hiddenLines = directives.reduce((acc, { showLines }) => {
107
- if (!showLines) return acc;
108
-
109
- return [...acc, ...showLines];
110
- }, [] as number[]);
111
-
112
- return directives.map(({ highlight, showLines, name }) => {
113
- hiddenLines = hiddenLines.filter((line) => !showLines?.includes(line));
114
- return {
115
- highlight: highlight || [],
116
- hiddenLines,
117
- name,
118
- };
119
- });
120
- }
121
-
122
- /**
123
- * Parse step directives
124
- */
125
- export function parseStepDirectives(directives: string[]): Step[] {
126
- const parsedDirectives = directives.map(parseStepDirective);
127
-
128
- return combineStepDirectives(parsedDirectives);
129
- }
@@ -1,85 +0,0 @@
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: Bitter, "Helvetica Neue", Helvetica, Arial, sans-serif;
32
- color: #f49676;
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
- }
@@ -1,18 +0,0 @@
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";
@@ -1,140 +0,0 @@
1
- import React from "react";
2
- import { animated, useSpring } from "react-spring";
3
- import { Stepper } from "spectacle";
4
- import styled from "styled-components";
5
-
6
- const Container = styled.div`
7
- display: grid;
8
- grid-gap: 2rem;
9
- `;
10
-
11
- export default function HorizontalList({
12
- children,
13
- columns = 3,
14
- }: {
15
- columns?: number;
16
- children: React.ReactNode;
17
- }) {
18
- const items = React.Children.toArray(children);
19
- return (
20
- <Stepper values={items}>
21
- {(_, step) => (
22
- <Container
23
- style={{
24
- gridTemplateColumns: `repeat(${columns}, 1fr)`,
25
- }}
26
- >
27
- {items.map((item, k) => {
28
- if (!React.isValidElement(item)) {
29
- return item;
30
- }
31
- return React.cloneElement(item, {
32
- // @ts-expect-error cloning
33
- position: k + 1,
34
- isVisible: k <= step,
35
- isLast: k === step,
36
- });
37
- })}
38
- </Container>
39
- )}
40
- </Stepper>
41
- );
42
- }
43
-
44
- function Pill({ position }: { position: number }) {
45
- return (
46
- <div
47
- style={{ width: 48, transform: "translate(-25%, -25%)", opacity: 0.9 }}
48
- >
49
- <svg
50
- width="48"
51
- height="48"
52
- viewBox="0 0 18 20"
53
- fill="none"
54
- xmlns="http://www.w3.org/2000/svg"
55
- >
56
- <path
57
- 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"
58
- fill="#ffffff"
59
- ></path>
60
- <text
61
- x="9"
62
- y="11"
63
- text-anchor="middle"
64
- dominant-baseline="middle"
65
- fill="#f49676"
66
- style={{ fontSize: "50%" }}
67
- >
68
- {position}
69
- </text>
70
- <path
71
- 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"
72
- fill="transparent"
73
- ></path>
74
- </svg>
75
- </div>
76
- );
77
- }
78
-
79
- const Item = styled(animated.div)`
80
- display: flex;
81
- flex-direction: column;
82
- font-family: Bitter, "Helvetica Neue", Helvetica, Arial, sans-serif;
83
- `;
84
- const ItemHead = styled.div`
85
- display: flex;
86
- flex-direction: row;
87
- font-size: 1.3rem;
88
- margin-bottom: 0.4rem;
89
-
90
- p {
91
- margin: 0;
92
- }
93
- `;
94
- const ItemContent = styled.div`
95
- > * {
96
- font-size: 1rem;
97
- padding: 4px !important;
98
- line-height: 1.5rem !important;
99
- margin-top: 0;
100
- }
101
- `;
102
-
103
- function getItemOpacity({
104
- isLast,
105
- isVisible,
106
- }: {
107
- isLast?: boolean;
108
- isVisible?: boolean;
109
- }) {
110
- if (isLast) return 1;
111
- if (isVisible) return 0.7;
112
- return 0;
113
- }
114
- export function HorizontalListItem({
115
- title,
116
- children,
117
- position,
118
- isVisible,
119
- isLast,
120
- }: {
121
- title: string;
122
- position: number;
123
- isVisible?: boolean;
124
- isLast?: boolean;
125
- children: React.ReactNode;
126
- }) {
127
- const opacityStyles = useSpring({
128
- opacity: getItemOpacity({ isVisible, isLast }),
129
- });
130
- return (
131
- <Item style={opacityStyles}>
132
- <ItemHead>
133
- <Pill position={position} />
134
- <p>{title}</p>
135
- </ItemHead>
136
-
137
- <ItemContent>{children}</ItemContent>
138
- </Item>
139
- );
140
- }
@@ -1,31 +0,0 @@
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
- }
@@ -1,34 +0,0 @@
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 } = props;
8
- if (!src?.endsWith(".svg")) {
9
- return (
10
- <img
11
- src={src}
12
- alt="image"
13
- style={{
14
- height: height || "100%",
15
- objectFit: "cover",
16
- objectPosition: "center",
17
- }}
18
- />
19
- );
20
- }
21
- return (
22
- <SVGObject
23
- type="image/svg+xml"
24
- data={src}
25
- style={{
26
- height: height || "100%",
27
- minWidth: "30vw",
28
- width: "100%",
29
- }}
30
- />
31
- );
32
- }
33
-
34
- Image.mdxType = "Image";
@@ -1,56 +0,0 @@
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
- alignItems: "center",
17
- height: "100%",
18
- ...style,
19
- }}
20
- {...props}
21
- >
22
- {childrenArray.map((child, index) => {
23
- const isVisible = index <= step;
24
- if (!React.isValidElement(child)) {
25
- return child;
26
- }
27
- return (
28
- <ItemColumnWrapper key={index} isVisible={isVisible}>
29
- {child}
30
- </ItemColumnWrapper>
31
- );
32
- })}
33
- </div>
34
- )}
35
- </Stepper>
36
- );
37
- }
38
-
39
- const ItemColumnWrapperStyled = styled(animated.div)`
40
- * {
41
- text-align: center !important;
42
- }
43
- `;
44
-
45
- function ItemColumnWrapper({
46
- children,
47
- isVisible,
48
- ...props
49
- }: React.ComponentPropsWithRef<"div"> & { isVisible: boolean }) {
50
- const styles = useSpring({ opacity: isVisible ? 1 : 0 });
51
- return (
52
- <ItemColumnWrapperStyled style={styles} {...props}>
53
- {children}
54
- </ItemColumnWrapperStyled>
55
- );
56
- }
@@ -1,24 +0,0 @@
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
- `;
@@ -1,157 +0,0 @@
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
- }
106
- ) {
107
- const { children, title, isPhantom, isLast, ...rest } = props;
108
- const guideLineProps = useSpring({
109
- width: isPhantom || isLast ? "0%" : "100%",
110
- });
111
- const appearStyles = useSpring({
112
- opacity: getItemOpacity({ isPhantom, isLast }),
113
- });
114
- const colorStyles = useSpring({ opacity: isPhantom || isLast ? 1 : 0.15 });
115
- return (
116
- <TimelineItemStyled
117
- {...rest}
118
- style={{
119
- ...appearStyles,
120
- }}
121
- >
122
- <TimelineItemContentPhantom>
123
- <TimelineItemTitle>{title}</TimelineItemTitle>
124
- <TimelineItemBody>{children}</TimelineItemBody>
125
- </TimelineItemContentPhantom>
126
- <TimelineItemGuide style={colorStyles}>
127
- <Hexagon />
128
- <TimelineItemGuideLine style={guideLineProps} />
129
- </TimelineItemGuide>
130
- <TimelineItemContent>
131
- <TimelineItemTitle>{title}</TimelineItemTitle>
132
- <TimelineItemBody>{children}</TimelineItemBody>
133
- </TimelineItemContent>
134
- </TimelineItemStyled>
135
- );
136
- }
137
-
138
- function Hexagon() {
139
- return (
140
- <svg
141
- width="18"
142
- height="20"
143
- viewBox="0 0 18 20"
144
- fill="none"
145
- xmlns="http://www.w3.org/2000/svg"
146
- >
147
- <path
148
- 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"
149
- fill="#F49676"
150
- ></path>
151
- <path
152
- 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"
153
- fill="#F49676"
154
- ></path>
155
- </svg>
156
- );
157
- }