Skip to content

Commit 887a10b

Browse files
committed
version banners
1 parent 9b26769 commit 887a10b

4 files changed

Lines changed: 76 additions & 25 deletions

File tree

website/docs/styles/index.css

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,43 @@
55
text-align: center;
66
padding: 0.5rem 1rem;
77
font-size: 0.875rem;
8-
position: fixed;
9-
bottom: 0;
10-
left: 0;
11-
right: 0;
12-
z-index: 1000;
138
}
149

1510
.pre-release-banner strong {
1611
font-weight: 600;
1712
}
1813

14+
/* Old Version Banner */
15+
.old-version-banner {
16+
display: flex;
17+
flex-wrap: wrap;
18+
align-items: center;
19+
justify-content: center;
20+
gap: 0.25rem 0.5rem;
21+
padding: 0.5rem 1rem;
22+
background: linear-gradient(90deg, var(--rp-c-brand-darker) 0%, var(--rp-c-brand) 100%);
23+
color: #ffffff;
24+
font-size: 0.875rem;
25+
text-align: center;
26+
}
27+
28+
.old-version-banner strong {
29+
font-weight: 600;
30+
}
31+
32+
.old-version-banner-link {
33+
color: #ffffff !important;
34+
font-weight: 500;
35+
white-space: nowrap;
36+
text-decoration: underline;
37+
text-underline-offset: 2px;
38+
}
39+
40+
.old-version-banner-link:hover {
41+
color: #ffffff !important;
42+
opacity: 0.85;
43+
}
44+
1945
:root {
2046
--rp-nav-height: 60px !important;
2147
--rp-sidebar-width: 320px !important;

website/rspress.config.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,5 +438,4 @@ export default defineConfig({
438438
// @ts-expect-error
439439
pluginVercelAnalytics(),
440440
],
441-
globalUIComponents: [path.join(__dirname, 'theme/PreReleaseBanner.tsx')],
442441
});

website/theme/PreReleaseBanner.tsx

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

website/theme/index.tsx

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import { useLocation } from '@rspress/core/runtime';
2+
import { Link, Layout as RspressLayout } from '@rspress/core/theme-original';
3+
4+
const LATEST_VERSION = '13.x';
5+
6+
const PreReleaseBanner = () => (
7+
<div className="pre-release-banner">
8+
<span>
9+
You are viewing documentation for <strong>v14 alpha</strong>. This version is under active
10+
development and APIs may change.
11+
</span>
12+
</div>
13+
);
14+
15+
const OldVersionBanner = ({ version }: { version: string }) => (
16+
<div className="old-version-banner">
17+
<span>
18+
You're viewing the documentation for <strong>{version}</strong>. Current latest version is{' '}
19+
<strong>{LATEST_VERSION}</strong>.
20+
</span>
21+
<Link href="/react-native-testing-library/docs/start/intro" className="old-version-banner-link">
22+
View latest version <strong>here</strong>.
23+
</Link>
24+
</div>
25+
);
26+
27+
const AnnouncementBanner = () => {
28+
const { pathname } = useLocation();
29+
30+
if (pathname.includes('/14.x/')) {
31+
return <PreReleaseBanner />;
32+
}
33+
34+
if (pathname.includes('/12.x/')) {
35+
return <OldVersionBanner version="12.x" />;
36+
}
37+
38+
return null;
39+
};
40+
41+
const Layout = () => <RspressLayout beforeNav={<AnnouncementBanner />} />;
42+
43+
export { Layout };
44+
45+
export * from '@rspress/core/theme-original';

0 commit comments

Comments
 (0)