Skip to content

Commit 88c7550

Browse files
committed
Merge branch 'main' into @stanleyoos/docs-add-links-in-configuring-ts-page
2 parents a476946 + cef7a66 commit 88c7550

20 files changed

+288
-366
lines changed

docusaurus.config.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,6 @@ export default {
9797
},
9898
],
9999
},
100-
footer: {
101-
copyright: `Copyright © ${new Date().getFullYear()} React Navigation. Built with <a target="_blank" rel="noreferrer noopener" href="https://docusaurus.io/">Docusaurus</a>, <a target="_blank" rel="noreferrer noopener" href="https://pages.github.com/">GitHub Pages</a>, and <a target="_blank" rel="noreferrer noopener" href="https://www.netlify.com/">Netlify</a>.`,
102-
},
103100
},
104101
plugins: [
105102
'./src/plugins/react-navigation-versions.mjs',
@@ -128,7 +125,10 @@ export default {
128125
sidebarCollapsed: false,
129126
remarkPlugins: [[remarkNpm2Yarn, { sync: true }]],
130127
rehypePlugins: [
131-
[rehypeCodeblockMeta, { match: { snack: true, lang: true } }],
128+
[
129+
rehypeCodeblockMeta,
130+
{ match: { snack: true, lang: true, tabs: true } },
131+
],
132132
],
133133
},
134134
blog: {

src/components/Pre.js

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,22 @@ import { useColorMode } from '@docusaurus/theme-common';
33
import { usePluginData } from '@docusaurus/useGlobalData';
44
import MDXPre from '@theme-original/MDXComponents/Pre';
55
import React from 'react';
6+
import Tabs from '@theme/Tabs';
7+
import TabItem from '@theme/TabItem';
8+
9+
const SUPPORTED_TABS = {
10+
config: [
11+
{ value: 'static', label: 'Static', default: true },
12+
{ value: 'dynamic', label: 'Dynamic' },
13+
],
14+
};
615

716
export default function Pre({
817
children,
918
'data-name': name,
1019
'data-snack': snack,
1120
'data-dependencies': deps,
21+
'data-tabs': tabs,
1222
'data-lang': lang,
1323
...rest
1424
}) {
@@ -18,6 +28,62 @@ export default function Pre({
1828

1929
const child = React.Children.only(children);
2030

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

src/css/custom.css

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,20 +170,22 @@ p {
170170
line-height: 1.75;
171171
}
172172

173-
@media (min-width: 82.5rem) {
173+
@media (min-width: 90rem) {
174174
.main-wrapper:not(.full-width),
175175
.navbar__inner,
176176
.footer .container {
177-
max-width: 82.5rem;
177+
max-width: 90rem;
178178
margin: auto;
179179
}
180+
}
180181

182+
@media (min-width: 85rem) {
181183
.main-wrapper:not(.full-width) main {
182184
padding: 2rem 0 2rem 2rem;
183185
}
184186

185187
.main-wrapper:not(.full-width) .container > .row > :first-child {
186-
padding-right: 1rem;
188+
padding-right: 3rem;
187189
}
188190
}
189191

@@ -193,7 +195,7 @@ p {
193195
}
194196

195197
.main-wrapper:not(.full-width) .container > .row > :first-child {
196-
padding-right: 3rem;
198+
padding-right: 5rem;
197199
}
198200
}
199201

@@ -397,6 +399,10 @@ p {
397399
background-color: var(--ifm-menu-color-background-active);
398400
}
399401

402+
.col:has(.table-of-contents) {
403+
padding-left: 0;
404+
}
405+
400406
.table-of-contents__link--active {
401407
position: relative;
402408
}
@@ -420,6 +426,10 @@ p {
420426
transform: scale(0.8);
421427
}
422428

429+
article {
430+
text-wrap: pretty;
431+
}
432+
423433
article img,
424434
article video {
425435
vertical-align: top;

src/pages/home/Footer.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import React from 'react';
2+
3+
const links = [
4+
{ title: 'Docusaurus', href: 'https://docusaurus.io/' },
5+
{ title: 'GitHub Pages', href: 'https://pages.github.com/' },
6+
{ title: 'Netlify', href: 'https://www.netlify.com/' },
7+
];
8+
9+
export default function Footer() {
10+
return (
11+
<footer class="footer">
12+
<div class="container container-fluid">
13+
<div class="footer__bottom text--center">
14+
<div class="footer__copyright">
15+
Copyright © 2024 React Navigation. Built with{' '}
16+
{links.map((link, index) => (
17+
<React.Fragment key={link.href}>
18+
{index > 0 && ', '}
19+
<a target="_blank" rel="noreferrer noopener" href={link.href}>
20+
{link.title}
21+
</a>
22+
</React.Fragment>
23+
))}
24+
.
25+
</div>
26+
</div>
27+
</div>
28+
</footer>
29+
);
30+
}

src/pages/index.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
import React from 'react';
2-
import Layout from '@theme/Layout';
3-
import Link from '@docusaurus/Link';
41
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
5-
import useBaseUrl from '@docusaurus/useBaseUrl';
6-
import sponsors from '../data/sponsors';
2+
import Layout from '@theme/Layout';
3+
import React from 'react';
74

8-
import Splash from './home/Splash';
95
import Features from './home/Features';
6+
import Footer from './home/Footer';
7+
import Splash from './home/Splash';
108
import Sponsors from './home/Sponsors';
119

1210
const features = [
@@ -52,6 +50,7 @@ function Home() {
5250
<Splash />
5351
<Features />
5452
<Sponsors />
53+
<Footer />
5554
</Layout>
5655
);
5756
}

static/examples/5.x/stack-actions.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import * as React from 'react';
2-
import { View, Button, Text } from 'react-native';
31
import { NavigationContainer, StackActions } from '@react-navigation/native';
42
import { createStackNavigator } from '@react-navigation/stack';
3+
import * as React from 'react';
4+
import { Button, Text, View } from 'react-native';
55

66
function HomeScreen({ navigation }) {
77
return (
@@ -31,11 +31,11 @@ function ProfileScreen({ navigation, route }) {
3131
<Text>Profile!</Text>
3232
<Text>{route.params.user}'s profile</Text>
3333
<Button
34-
title="Push same screen on the stack"
34+
title="Pop one screen from stack"
3535
onPress={() => navigation.dispatch(StackActions.pop(1))}
3636
/>
3737
<Button
38-
title="Pop one screen from stack"
38+
title="Push same screen on the stack"
3939
onPress={() =>
4040
navigation.dispatch(StackActions.push('Profile', { user: 'Wojtek' }))
4141
}

static/examples/6.x/stack-actions.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import * as React from 'react';
2-
import { View, Button, Text } from 'react-native';
31
import { NavigationContainer, StackActions } from '@react-navigation/native';
42
import { createStackNavigator } from '@react-navigation/stack';
3+
import * as React from 'react';
4+
import { Button, Text, View } from 'react-native';
55

66
function HomeScreen({ navigation }) {
77
return (
@@ -31,11 +31,11 @@ function ProfileScreen({ navigation, route }) {
3131
<Text>Profile!</Text>
3232
<Text>{route.params.user}'s profile</Text>
3333
<Button
34-
title="Push same screen on the stack"
34+
title="Pop one screen from stack"
3535
onPress={() => navigation.dispatch(StackActions.pop(1))}
3636
/>
3737
<Button
38-
title="Pop one screen from stack"
38+
title="Push same screen on the stack"
3939
onPress={() =>
4040
navigation.dispatch(StackActions.push('Profile', { user: 'Wojtek' }))
4141
}

static/examples/7.x/drawer-based-navigation.js

Lines changed: 0 additions & 36 deletions
This file was deleted.

0 commit comments

Comments
 (0)