Skip to content

Commit a60f30a

Browse files
authored
Merge branch 'feat/docs' into @ksienkiewicz/docs-fundamentals
2 parents dcc7034 + 3c137f8 commit a60f30a

8 files changed

Lines changed: 95 additions & 207 deletions

File tree

docs/docusaurus.config.js

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
// @ts-check
22
// Note: type annotations allow type checking and IDEs autocompletion
33

4+
import { topbarBannerReservationScript } from '@swmansion/t-rex-ui/topbar-banner';
5+
import { TOP_BAR_BANNER } from './src/components/topbarBanner.config.ts';
6+
47
const lightCodeTheme = require('./src/theme/CodeBlock/highlighting-light.js');
58
const darkCodeTheme = require('./src/theme/CodeBlock/highlighting-dark.js');
69

@@ -19,6 +22,21 @@ function reactNativeWebPlugin() {
1922
};
2023
}
2124

25+
const firstBannerZone = TOP_BAR_BANNER.zones[0];
26+
const bannerReservationHeadTags = firstBannerZone
27+
? [
28+
{
29+
tagName: 'script',
30+
attributes: { type: 'text/javascript' },
31+
innerHTML: topbarBannerReservationScript(
32+
firstBannerZone.zoneId,
33+
firstBannerZone.contentId,
34+
TOP_BAR_BANNER.hiddenPaths,
35+
),
36+
},
37+
]
38+
: [];
39+
2240
/** @type {import('@docusaurus/types').Config} */
2341
const config = {
2442
title: 'React Native Enriched HTML',
@@ -79,6 +97,10 @@ const config = {
7997
require.resolve('@swmansion/t-rex-ui/preset'),
8098
],
8199

100+
headTags: bannerReservationHeadTags,
101+
102+
clientModules: [require.resolve('./src/clientModules/topbarBannerRefresh.ts')],
103+
82104
plugins: [
83105
reactNativeWebPlugin,
84106
function transpileTRexUiTheme() {
@@ -100,13 +122,12 @@ const config = {
100122
},
101123
};
102124
},
103-
// TODO: enable Google Tag Manager with a container id for this site.
104-
// process.env.NODE_ENV === 'production' && [
105-
// '@docusaurus/plugin-google-tag-manager',
106-
// {
107-
// containerId: 'GTM-XXXXXXX',
108-
// },
109-
// ],
125+
process.env.NODE_ENV === 'production' && [
126+
'@docusaurus/plugin-google-tag-manager',
127+
{
128+
containerId: 'GTM-N5QK8TMT',
129+
},
130+
],
110131
].filter(Boolean),
111132

112133
themeConfig:

docs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"@emotion/styled": "^11.14.0",
2828
"@mdx-js/react": "^3.0.0",
2929
"@mui/material": "^7.1.0",
30-
"@swmansion/t-rex-ui": "1.3.2",
30+
"@swmansion/t-rex-ui": "1.3.4",
3131
"clsx": "^2.1.0",
3232
"copy-text-to-clipboard": "3.2.2",
3333
"prettier": "^3.6.2",
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import type { ClientModule } from '@docusaurus/types';
2+
import type { BannerZone } from '@swmansion/t-rex-ui';
3+
import { TOP_BAR_BANNER } from '../components/topbarBanner.config';
4+
5+
// Revive's async tag only scans <ins> slots once, on initial load; re-trigger it after each SPA nav so remounted slots get filled.
6+
const contentIds = Array.from(
7+
new Set(TOP_BAR_BANNER.zones.map((zone: BannerZone) => zone.contentId)),
8+
);
9+
10+
function refreshBannerContent() {
11+
contentIds.forEach((contentId) => {
12+
document.dispatchEvent(new CustomEvent(`content-${contentId}-refresh`));
13+
});
14+
}
15+
16+
export const onRouteDidUpdate: ClientModule['onRouteDidUpdate'] = ({
17+
previousLocation,
18+
location,
19+
}) => {
20+
if (!previousLocation || previousLocation.pathname === location.pathname) {
21+
return;
22+
}
23+
// Defer until after the new route's <ins> nodes are actually in the DOM.
24+
setTimeout(refreshBannerContent, 0);
25+
};

docs/src/components/TopPromoRotator/index.tsx

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

docs/src/components/TopPromoRotator/styles.module.css

Lines changed: 0 additions & 77 deletions
This file was deleted.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
2+
export const TOP_BAR_BANNER = {
3+
rotateIntervalMs: 4000,
4+
zones: [
5+
{
6+
zoneId: 'enriched-topbar-1',
7+
contentId: 'ea15c4216158c4097b65fe6504a4b3b7',
8+
fallbackBgColor: '#001a72',
9+
},
10+
{
11+
zoneId: 'enriched-topbar-2',
12+
contentId: 'ea15c4216158c4097b65fe6504a4b3b7',
13+
fallbackBgColor: '#001a72',
14+
},
15+
{
16+
zoneId: 'enriched-topbar-3',
17+
contentId: 'ea15c4216158c4097b65fe6504a4b3b7',
18+
fallbackBgColor: '#001a72',
19+
},
20+
] satisfies BannerZone[],
21+
};

docs/src/theme/Navbar/index.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
11
import React from 'react';
2-
import { Navbar } from '@swmansion/t-rex-ui';
3-
import TopPromoRotator from '@site/src/components/TopPromoRotator';
2+
import { useLocation } from '@docusaurus/router';
3+
import { Navbar, TopbarBanner, isBannerHidden } from '@swmansion/t-rex-ui';
4+
import { TOP_BAR_BANNER } from '@site/src/components/topbarBanner.config';
45

56
export default function NavbarWrapper(props) {
7+
const location = useLocation();
8+
const bannerHidden = isBannerHidden(
9+
location.pathname,
10+
TOP_BAR_BANNER.hiddenPaths,
11+
);
612
return (
713
<div style={{ display: 'flex', flexDirection: 'column', flexShrink: 0 }}>
8-
<TopPromoRotator />
14+
{!bannerHidden && (
15+
<TopbarBanner
16+
zones={TOP_BAR_BANNER.zones}
17+
rotateIntervalMs={TOP_BAR_BANNER.rotateIntervalMs}
18+
/>
19+
)}
920
<Navbar
1021
useLandingLogoDualVariant={true}
1122
isAlgoliaActive={false}

docs/yarn.lock

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4088,9 +4088,9 @@ __metadata:
40884088
languageName: node
40894089
linkType: hard
40904090

4091-
"@swmansion/t-rex-ui@npm:1.3.2":
4092-
version: 1.3.2
4093-
resolution: "@swmansion/t-rex-ui@npm:1.3.2"
4091+
"@swmansion/t-rex-ui@npm:1.3.4":
4092+
version: 1.3.4
4093+
resolution: "@swmansion/t-rex-ui@npm:1.3.4"
40944094
dependencies:
40954095
"@docusaurus/core": "npm:3.9.2"
40964096
"@docusaurus/module-type-aliases": "npm:3.9.2"
@@ -4111,10 +4111,11 @@ __metadata:
41114111
"@emotion/styled": "*"
41124112
"@mui/material": ">=5.0.0"
41134113
copy-text-to-clipboard: ^3.2.2
4114+
prism-react-renderer: ^2.0.0
41144115
react: "*"
41154116
react-dom: "*"
41164117
react-icons: "*"
4117-
checksum: 10c0/8e88ca4efbc892b01cea5e07f6b46332f32c04008685c7083f52a8f9b0c269f74e6afa2ba5458aae106fcd1ea746a22176f8ec13f5e3823d5405e651e94438ec
4118+
checksum: 10c0/64adad0bcce8856d1855e2da153af9429c8a6ae759fb510933163e523db83a70eeceded9d8e50d108f269f7129f143b5f401509aa3ab0331f5fd14eea3295d66
41184119
languageName: node
41194120
linkType: hard
41204121

@@ -7527,7 +7528,7 @@ __metadata:
75277528
"@emotion/styled": "npm:^11.14.0"
75287529
"@mdx-js/react": "npm:^3.0.0"
75297530
"@mui/material": "npm:^7.1.0"
7530-
"@swmansion/t-rex-ui": "npm:1.3.2"
7531+
"@swmansion/t-rex-ui": "npm:1.3.4"
75317532
clsx: "npm:^2.1.0"
75327533
copy-text-to-clipboard: "npm:3.2.2"
75337534
prettier: "npm:^3.6.2"

0 commit comments

Comments
 (0)