1
1
import React from 'react'
2
- import Link from 'next/link'
3
2
import { useAmp } from 'next/amp'
4
3
import { withRouter } from 'next/router'
5
4
import { MDXProvider } from '@mdx-js/tag'
@@ -10,17 +9,16 @@ import Layout from '~/components/layout/layout'
10
9
import Main from '~/components/layout/main'
11
10
import Heading from '~/components/text/linked-heading'
12
11
import Sidebar from '~/components/layout/sidebar'
12
+ import VersionSwitcher from '~/components/layout/version-switcher'
13
13
import Content from '~/components/layout/content'
14
14
import ContentFooter from '~/components/layout/content-footer'
15
15
import DocsNavbarDesktop from '~/components/layout/navbar/desktop'
16
- import ToggleGroup , { ToggleItem } from '~/components/toggle-group'
17
16
import { GenericLink } from '~/components/text/link'
18
17
import components from '~/lib/mdx-components'
19
18
import { H1 , H2 , H3 , H4 } from '~/components/text'
20
19
import HR from '~/components/text/hr'
21
20
import dataV1 from '~/lib/data/v1/docs'
22
21
import dataV2 from '~/lib/data/v2/docs'
23
- import Select from '~/components/select'
24
22
import Note from '~/components/text/note'
25
23
import { FooterFeedback } from '~/components/feedback-input'
26
24
@@ -78,31 +76,6 @@ const DocH4 = ({ children }) => (
78
76
79
77
const NonAmpOnly = ( { children } ) => ( useAmp ( ) ? null : children )
80
78
81
- const VersionSelect = ( { onChange, version } ) => {
82
- const isAmp = useAmp ( )
83
- const href = `/docs/${ version === 'v1' ? 'v2' : 'v1' } `
84
- const curSelect = (
85
- < Select
86
- width = "100%"
87
- onChange = { onChange }
88
- defaultValue = { version }
89
- on = {
90
- isAmp ? `change:AMP.navigateTo(url='${ href } ', target=_top)` : undefined
91
- }
92
- >
93
- < option value = "v1" > 1.0</ option >
94
- < option value = "v2" > 2.0 (Latest)</ option >
95
- </ Select >
96
- )
97
- if ( ! isAmp ) return curSelect
98
- // have to wrap it in a form to use `autoComplete="off"`
99
- return (
100
- < form action = "/" method = "GET" autoComplete = "off" target = "_top" >
101
- { curSelect }
102
- </ form >
103
- )
104
- }
105
-
106
79
class withDoc extends React . Component {
107
80
state = {
108
81
navigationActive : false ,
@@ -160,40 +133,13 @@ class withDoc extends React.Component {
160
133
< Main >
161
134
< NonAmpOnly >
162
135
< Sidebar active = { navigationActive } >
163
- < div className = "toggle-group-wrapper" >
164
- < ToggleGroup >
165
- < ToggleItem
166
- active = {
167
- router . pathname . startsWith ( '/docs' ) &&
168
- ! router . pathname . startsWith ( '/docs/api' )
169
- }
170
- >
171
- < Link href = "/docs" >
172
- < a onClick = { this . handleIndexClick } > Docs</ a >
173
- </ Link >
174
- </ ToggleItem >
175
- < ToggleItem
176
- active = { router . pathname . startsWith ( '/docs/api' ) }
177
- >
178
- < Link href = "/docs/api" >
179
- < a onClick = { this . handleIndexClick } > API Reference</ a >
180
- </ Link >
181
- </ ToggleItem >
182
- < ToggleItem
183
- active = { router . pathname . startsWith ( '/examples' ) }
184
- >
185
- < Link href = "/examples" >
186
- < a onClick = { this . handleIndexClick } > Examples</ a >
187
- </ Link >
188
- </ ToggleItem >
189
- </ ToggleGroup >
190
- </ div >
191
136
< DocsNavbarDesktop data = { versionData } url = { router } />
192
- < h5 className = "platform-select-title" > Now Platform Version</ h5 >
193
- < VersionSelect
194
- version = { version }
195
- onChange = { this . handleVersionChange }
196
- />
137
+ < div className = "select-wrapper" >
138
+ < VersionSwitcher
139
+ version = { version }
140
+ onChange = { this . handleVersionChange }
141
+ />
142
+ </ div >
197
143
</ Sidebar >
198
144
</ NonAmpOnly >
199
145
< Content >
@@ -238,6 +184,10 @@ class withDoc extends React.Component {
238
184
padding: 0;
239
185
}
240
186
187
+ .select-wrapper {
188
+ margin-top: 64px;
189
+ }
190
+
241
191
.category-wrapper {
242
192
padding: 40px 0;
243
193
}
@@ -253,19 +203,6 @@ class withDoc extends React.Component {
253
203
margin-bottom: 16px;
254
204
margin-top: 32px;
255
205
}
256
-
257
- .toggle-group-wrapper {
258
- display: none;
259
- }
260
-
261
- @media screen and (max-width: 950px) {
262
- .toggle-group-wrapper {
263
- display: flex;
264
- align-items: center;
265
- justify-content: center;
266
- margin-bottom: 40px;
267
- }
268
- }
269
206
` } </ style >
270
207
</ Layout >
271
208
</ MDXProvider >
0 commit comments