Skip to content

Commit 76827a2

Browse files
committed
Remove unused codeblock-tabs handling
1 parent a5e1f86 commit 76827a2

File tree

3 files changed

+2
-124
lines changed

3 files changed

+2
-124
lines changed

src/components/Pre.js

Lines changed: 0 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,8 @@ import { useActiveVersion } from '@docusaurus/plugin-content-docs/client';
22
import { useColorMode } from '@docusaurus/theme-common';
33
import { usePluginData } from '@docusaurus/useGlobalData';
44
import MDXPre from '@theme-original/MDXComponents/Pre';
5-
import TabItem from '@theme/TabItem';
6-
import Tabs from '@theme/Tabs';
75
import React from 'react';
86

9-
const SUPPORTED_TABS = {
10-
config: [
11-
{ value: 'static', label: 'Static', default: true },
12-
{ value: 'dynamic', label: 'Dynamic' },
13-
],
14-
};
15-
167
const COMMENTS = {
178
HIGHLIGHT_START: '// highlight-start',
189
HIGHLIGHT_END: '// highlight-end',
@@ -26,7 +17,6 @@ export default function Pre({
2617
'data-name': name,
2718
'data-snack': snack,
2819
'data-dependencies': deps,
29-
'data-tabs': tabs,
3020
'data-lang': lang,
3121
...rest
3222
}) {
@@ -38,62 +28,6 @@ export default function Pre({
3828

3929
const child = React.Children.only(children);
4030

41-
// If we encounter tabs, we need to render 2 code blocks
42-
if (tabs && tabs in SUPPORTED_TABS) {
43-
return (
44-
<Tabs groupId="config" queryString="config">
45-
{SUPPORTED_TABS[tabs].map((tab) => {
46-
const code = child.props.children;
47-
48-
if (typeof code !== 'string') {
49-
throw new Error(
50-
'Code to display in tabs must be a string, but received ' +
51-
typeof code
52-
);
53-
}
54-
55-
const lines = code.split('\n');
56-
57-
let content = '';
58-
let exclude = false;
59-
let indent;
60-
61-
for (const line of lines) {
62-
if (line.trim().startsWith('// codeblock-tabs=')) {
63-
exclude = line.trim() !== `// codeblock-tabs=${tab.value}`;
64-
} else if (line.trim() === '// codeblock-tabs-end') {
65-
exclude = false;
66-
} else if (!exclude) {
67-
content += line + '\n';
68-
}
69-
}
70-
71-
return (
72-
<TabItem
73-
key={tab.value}
74-
value={tab.value}
75-
label={tab.label}
76-
default={tab.default}
77-
>
78-
<Pre
79-
{...rest}
80-
data-name={name}
81-
data-snack={snack}
82-
data-dependencies={deps}
83-
data-lang={lang}
84-
>
85-
{React.cloneElement(children, {
86-
...child.props,
87-
children: content.trim(),
88-
})}
89-
</Pre>
90-
</TabItem>
91-
);
92-
})}
93-
</Tabs>
94-
);
95-
}
96-
9731
// Handle diffs with language
9832
if (child.props.className === 'language-diff' && lang) {
9933
const code = child.props.children;

versioned_docs/version-7.x/bottom-tab-navigator.md

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ The `state.routes` array contains all the routes defined in the navigator. Each
111111

112112
Example:
113113

114-
```js name="Custom tab bar" snack tabs=config
114+
```js name="Custom tab bar" snack static2dynamic
115115
import * as React from 'react';
116116
import {
117117
createStaticNavigation,
@@ -198,7 +198,6 @@ function ProfileScreen() {
198198
);
199199
}
200200

201-
// codeblock-tabs=static
202201
// codeblock-focus-start
203202
const MyTabs = createBottomTabNavigator({
204203
// highlight-next-line
@@ -215,33 +214,6 @@ const Navigation = createStaticNavigation(MyTabs);
215214
export default function App() {
216215
return <Navigation />;
217216
}
218-
// codeblock-tabs-end
219-
220-
// codeblock-tabs=dynamic
221-
const Tab = createBottomTabNavigator();
222-
223-
// codeblock-focus-start
224-
function MyTabs() {
225-
return (
226-
<Tab.Navigator
227-
// highlight-next-line
228-
tabBar={(props) => <MyTabBar {...props} />}
229-
>
230-
<Tab.Screen name="Home" component={HomeScreen} />
231-
<Tab.Screen name="Profile" component={ProfileScreen} />
232-
</Tab.Navigator>
233-
);
234-
}
235-
// codeblock-focus-end
236-
237-
export default function App() {
238-
return (
239-
<NavigationContainer>
240-
<MyTabs />
241-
</NavigationContainer>
242-
);
243-
}
244-
// codeblock-tabs-end
245217
```
246218

247219
This example will render a basic tab bar with labels.

versioned_docs/version-8.x/bottom-tab-navigator.md

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ The `state.routes` array contains all the routes defined in the navigator. Each
188188

189189
Example:
190190

191-
```js name="Custom tab bar" snack tabs=config
191+
```js name="Custom tab bar" snack static2dynamic
192192
import * as React from 'react';
193193
import {
194194
createStaticNavigation,
@@ -275,7 +275,6 @@ function ProfileScreen() {
275275
);
276276
}
277277

278-
// codeblock-tabs=static
279278
// codeblock-focus-start
280279
const MyTabs = createBottomTabNavigator({
281280
// highlight-next-line
@@ -292,33 +291,6 @@ const Navigation = createStaticNavigation(MyTabs);
292291
export default function App() {
293292
return <Navigation />;
294293
}
295-
// codeblock-tabs-end
296-
297-
// codeblock-tabs=dynamic
298-
const Tab = createBottomTabNavigator();
299-
300-
// codeblock-focus-start
301-
function MyTabs() {
302-
return (
303-
<Tab.Navigator
304-
// highlight-next-line
305-
tabBar={(props) => <MyTabBar {...props} />}
306-
>
307-
<Tab.Screen name="Home" component={HomeScreen} />
308-
<Tab.Screen name="Profile" component={ProfileScreen} />
309-
</Tab.Navigator>
310-
);
311-
}
312-
// codeblock-focus-end
313-
314-
export default function App() {
315-
return (
316-
<NavigationContainer>
317-
<MyTabs />
318-
</NavigationContainer>
319-
);
320-
}
321-
// codeblock-tabs-end
322294
```
323295

324296
This example will render a basic tab bar with labels.

0 commit comments

Comments
 (0)