1
- import React , { useContext } from "react"
1
+ import React , { ComponentPropsWithoutRef , useContext } from "react"
2
2
import { graphql , PageProps } from "gatsby"
3
3
import { MDXProvider } from "@mdx-js/react"
4
4
import { MDXRenderer } from "gatsby-plugin-mdx"
5
- import styled from "@emotion/styled"
6
- import { Badge } from "@chakra-ui/react"
5
+ import {
6
+ Badge ,
7
+ Divider as ChakraDivider ,
8
+ Flex ,
9
+ FlexProps ,
10
+ Heading ,
11
+ ListItem as ChakraListItem ,
12
+ ListItemProps ,
13
+ Text ,
14
+ TextProps ,
15
+ Box ,
16
+ useToken ,
17
+ HeadingProps ,
18
+ UnorderedList as ChakraUnorderedList ,
19
+ OrderedList as ChakraOrderedList ,
20
+ ListProps ,
21
+ } from "@chakra-ui/react"
7
22
8
23
import BannerNotification from "../components/BannerNotification"
9
24
import ButtonLink from "../components/ButtonLink"
@@ -21,117 +36,160 @@ import TableOfContents, {
21
36
} from "../components/TableOfContents"
22
37
import SectionNav from "../components/SectionNav"
23
38
import Translation from "../components/Translation"
24
- import Emoji from "../components/OldEmoji "
39
+ import Emoji from "../components/Emoji "
25
40
import DocsNav from "../components/DocsNav"
26
41
import DeveloperDocsLinks from "../components/DeveloperDocsLinks"
27
42
import RollupProductDevDoc from "../components/RollupProductDevDoc"
28
43
import YouTube from "../components/YouTube"
29
- import {
30
- Divider ,
31
- Paragraph ,
32
- Header1 ,
33
- Header2 ,
34
- Header3 ,
35
- Header4 ,
36
- ListItem ,
37
- } from "../components/SharedStyledComponents"
44
+
38
45
import PostMergeBanner from "../components/Banners/PostMergeBanner"
39
46
40
47
import { ZenModeContext } from "../contexts/ZenModeContext"
41
48
import { isLangRightToLeft } from "../utils/translations"
42
49
import { Lang } from "../utils/languages"
43
- import { Context } from "../types"
50
+ import { ChildOnlyProp , Context } from "../types"
44
51
45
- const Page = styled . div `
46
- display: flex;
47
- flex-direction: column;
48
- width: 100%;
49
- border-bottom: 1px solid ${ ( props ) => props . theme . colors . border } ;
50
- `
52
+ const Page = ( props : ChildOnlyProp & Pick < FlexProps , "dir" > ) => (
53
+ < Flex
54
+ direction = "column"
55
+ w = "full"
56
+ borderBottom = "1px"
57
+ borderColor = "border"
58
+ { ...props }
59
+ />
60
+ )
51
61
52
- const ContentContainer = styled . div < { isZenMode : boolean } > `
53
- display: flex;
54
- justify-content: ${ ( props ) => ( props . isZenMode ? "center" : "space-between" ) } ;
55
- width: 100%;
56
- padding: 0 2rem 0 0;
57
- @media (max-width: ${ ( props ) => props . theme . breakpoints . l } ) {
58
- padding: 0;
59
- }
60
- background-color: ${ ( props ) => props . theme . colors . ednBackground } ;
61
- `
62
+ const Divider = ( ) => (
63
+ < ChakraDivider
64
+ my = { 16 }
65
+ w = "10%"
66
+ borderBottomWidth = { 1 }
67
+ borderColor = "homeDivider"
68
+ />
69
+ )
70
+ const baseHeadingStyle : HeadingProps = {
71
+ fontFamily : "mono" ,
72
+ textTransform : "uppercase" ,
73
+ fontWeight : "bold" ,
74
+ }
62
75
63
- // Apply styles for classes within markdown here
64
- const Content = styled . article `
65
- flex: 1 1 ${ ( props ) => props . theme . breakpoints . m } ;
66
- max-width: ${ ( props ) => props . theme . breakpoints . m } ;
67
- padding: 3rem 4rem 4rem;
68
- margin: 0px auto;
69
- @media (max-width: ${ ( props ) => props . theme . breakpoints . l } ) {
70
- max-width: 100%;
71
- }
72
- @media (max-width: ${ ( props ) => props . theme . breakpoints . m } ) {
73
- padding: 8rem 2rem 2rem;
74
- }
76
+ const H1 = ( props : HeadingProps ) => (
77
+ < Heading
78
+ { ...baseHeadingStyle }
79
+ as = "h1"
80
+ fontSize = { { base : "2rem" , md : "2.5rem" } }
81
+ lineHeight = { { md : 1.4 } }
82
+ mt = { { base : 0 , md : 8 } }
83
+ mb = { { base : 4 , md : 8 } }
84
+ { ...props }
85
+ />
86
+ )
75
87
76
- .featured {
77
- padding-left: 1rem;
78
- margin-left: -1rem;
79
- border-left: 1px dotted ${ ( props ) => props . theme . colors . primary } ;
80
- }
88
+ const H2 = ( props : HeadingProps ) => (
89
+ < Heading
90
+ { ...baseHeadingStyle }
91
+ fontSize = "2xl"
92
+ lineHeight = { { base : 1.2 , md : 1.4 } }
93
+ pb = { 2 }
94
+ borderBottom = "1px"
95
+ borderColor = "border"
96
+ { ...props }
97
+ />
98
+ )
81
99
82
- .citation {
83
- p {
84
- color: ${ ( props ) => props . theme . colors . text200 } ;
85
- }
86
- }
87
- `
100
+ const baseSubHeadingStyles : HeadingProps = {
101
+ lineHeight : 1.4 ,
102
+ fontWeight : "semibold" ,
103
+ fontSize : "md" ,
104
+ }
88
105
89
- const H1 = styled ( Header1 ) `
90
- font-size: 2.5rem;
91
- font-family: ${ ( props ) => props . theme . fonts . monospace } ;
92
- text-transform: uppercase;
93
- @media (max-width: ${ ( props ) => props . theme . breakpoints . m } ) {
94
- font-size: 2rem;
95
- line-height: 1.2;
96
- margin-top: 0;
97
- margin-bottom: 1rem;
98
- }
99
- `
106
+ const H3 = ( props : HeadingProps ) => (
107
+ < Heading
108
+ { ...baseSubHeadingStyles }
109
+ as = "h3"
110
+ fontSize = { { md : "2xl" } }
111
+ mt = { 12 }
112
+ { ...props }
113
+ />
114
+ )
100
115
101
- const H2 = styled ( Header2 ) `
102
- font-family: ${ ( props ) => props . theme . fonts . monospace } ;
103
- text-transform: uppercase;
116
+ const H4 = ( props : HeadingProps ) => (
117
+ < Heading
118
+ { ...baseSubHeadingStyles }
119
+ as = "h4"
120
+ fontSize = { { md : "xl" } }
121
+ { ...props }
122
+ />
123
+ )
104
124
105
- font-size: 1.5rem;
106
- padding-bottom: 0.5rem;
107
- border-bottom: 1px solid ${ ( props ) => props . theme . colors . border } ;
108
- `
125
+ const Paragraph = ( props : TextProps ) => (
126
+ < Text fontSize = "md" color = "text300" mt = { 8 } mb = { 4 } { ...props } />
127
+ )
109
128
110
- const H3 = styled ( Header3 ) `
111
- margin-top: 3rem;
129
+ const UnorderedList = ( props : ListProps ) => (
130
+ < ChakraUnorderedList ms = "1.45rem" { ...props } />
131
+ )
132
+ const OrderedList = ( props : ListProps ) => (
133
+ < ChakraOrderedList ms = "1.45rem" { ...props } />
134
+ )
112
135
113
- @media (max-width: ${ ( props ) => props . theme . breakpoints . m } ) {
114
- font-size: 1rem;
115
- font-weight: 600;
116
- }
117
- `
136
+ const ListItem = ( props : ListItemProps ) => (
137
+ < ChakraListItem color = "text300" { ...props } />
138
+ )
118
139
119
- const H4 = styled ( Header4 ) `
120
- @media (max-width: ${ ( props ) => props . theme . breakpoints . m } ) {
121
- font-size: 1rem;
122
- font-weight: 600;
123
- }
124
- `
140
+ const ContentContainer = ( props : ChildOnlyProp & { isZenMode : boolean } ) => (
141
+ < Flex
142
+ justify = { props . isZenMode ? "center" : "space-between" }
143
+ w = "full"
144
+ py = { 0 }
145
+ pl = { 0 }
146
+ pr = { { base : 0 , lg : 8 } }
147
+ backgroundColor = "ednBackground"
148
+ { ...props }
149
+ />
150
+ )
125
151
126
- const BackToTop = styled . div `
127
- margin-top: 3rem;
128
- display: flex;
129
- padding-top: 2rem;
130
- border-top: 1px solid ${ ( props ) => props . theme . colors . border } ;
131
- @media (min-width: ${ ( props ) => props . theme . breakpoints . l } ) {
132
- display: none;
133
- }
134
- `
152
+ // Apply styles for classes within markdown here
153
+ const Content = ( props : ChildOnlyProp ) => {
154
+ const mdBreakpoint = useToken ( "breakpoints" , "md" )
155
+
156
+ return (
157
+ < Box
158
+ as = "article"
159
+ flex = { `1 1 ${ mdBreakpoint } ` }
160
+ maxW = { { base : "full" , lg : mdBreakpoint } }
161
+ pt = { { base : 32 , md : 12 } }
162
+ pb = { { base : 8 , md : 16 } }
163
+ px = { { base : 8 , md : 16 } }
164
+ m = "0 auto"
165
+ sx = { {
166
+ ".featured" : {
167
+ paddingLeft : 4 ,
168
+ marginLeft : - 4 ,
169
+ borderLeft : "1px dotted" ,
170
+ borderColor : "primary" ,
171
+ } ,
172
+ ".citation" : {
173
+ p : {
174
+ color : "text200" ,
175
+ } ,
176
+ } ,
177
+ } }
178
+ { ...props }
179
+ />
180
+ )
181
+ }
182
+
183
+ const BackToTop = ( props : ChildOnlyProp ) => (
184
+ < Flex
185
+ display = { { lg : "none" } }
186
+ mt = { 12 }
187
+ pt = { 8 }
188
+ borderTop = "1px"
189
+ borderColor = "border"
190
+ { ...props }
191
+ />
192
+ )
135
193
136
194
// Note: you must pass components to MDXProvider in order to render them in markdown files
137
195
// https://www.gatsbyjs.com/plugins/gatsby-plugin-mdx/#mdxprovider
@@ -142,6 +200,8 @@ const components = {
142
200
h3 : H3 ,
143
201
h4 : H4 ,
144
202
p : Paragraph ,
203
+ ul : UnorderedList ,
204
+ ol : OrderedList ,
145
205
li : ListItem ,
146
206
pre : Codeblock ,
147
207
table : MarkdownTable ,
@@ -158,11 +218,9 @@ const components = {
158
218
RollupProductDevDoc,
159
219
}
160
220
161
- const Contributors = styled ( FileContributors ) `
162
- @media (max-width: ${ ( props ) => props . theme . breakpoints . l } ) {
163
- padding-bottom: 2rem;
164
- }
165
- `
221
+ const Contributors = (
222
+ props : ComponentPropsWithoutRef < typeof FileContributors >
223
+ ) => < FileContributors p = { { base : 0 , lg : 2 } } pb = { { base : 8 , lg : 2 } } { ...props } />
166
224
167
225
const DocsPage = ( {
168
226
data : { siteData, pageData : mdx } ,
0 commit comments