Skip to content

Commit 367c24e

Browse files
authored
Merge branch 'feat/docs' into @ksienkiewicz/docs-colors
2 parents 6828d41 + 3c137f8 commit 367c24e

8 files changed

Lines changed: 96 additions & 207 deletions

File tree

docs/docusaurus.config.js

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,28 @@
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

10+
11+
const firstBannerZone = TOP_BAR_BANNER.zones[0];
12+
const bannerReservationHeadTags = firstBannerZone
13+
? [
14+
{
15+
tagName: 'script',
16+
attributes: { type: 'text/javascript' },
17+
innerHTML: topbarBannerReservationScript(
18+
firstBannerZone.zoneId,
19+
firstBannerZone.contentId,
20+
TOP_BAR_BANNER.hiddenPaths,
21+
),
22+
},
23+
]
24+
: [];
25+
726
/** @type {import('@docusaurus/types').Config} */
827
const config = {
928
title: 'React Native Enriched HTML',
@@ -64,6 +83,10 @@ const config = {
6483
require.resolve('@swmansion/t-rex-ui/preset'),
6584
],
6685

86+
headTags: bannerReservationHeadTags,
87+
88+
clientModules: [require.resolve('./src/clientModules/topbarBannerRefresh.ts')],
89+
6790
plugins: [
6891
function transpileTRexUiTheme() {
6992
return {
@@ -84,13 +107,12 @@ const config = {
84107
},
85108
};
86109
},
87-
// TODO: enable Google Tag Manager with a container id for this site.
88-
// process.env.NODE_ENV === 'production' && [
89-
// '@docusaurus/plugin-google-tag-manager',
90-
// {
91-
// containerId: 'GTM-XXXXXXX',
92-
// },
93-
// ],
110+
process.env.NODE_ENV === 'production' && [
111+
'@docusaurus/plugin-google-tag-manager',
112+
{
113+
containerId: 'GTM-N5QK8TMT',
114+
},
115+
],
94116
].filter(Boolean),
95117

96118
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
@@ -3925,9 +3925,9 @@ __metadata:
39253925
languageName: node
39263926
linkType: hard
39273927

3928-
"@swmansion/t-rex-ui@npm:1.3.2":
3929-
version: 1.3.2
3930-
resolution: "@swmansion/t-rex-ui@npm:1.3.2"
3928+
"@swmansion/t-rex-ui@npm:1.3.4":
3929+
version: 1.3.4
3930+
resolution: "@swmansion/t-rex-ui@npm:1.3.4"
39313931
dependencies:
39323932
"@docusaurus/core": "npm:3.9.2"
39333933
"@docusaurus/module-type-aliases": "npm:3.9.2"
@@ -3948,10 +3948,11 @@ __metadata:
39483948
"@emotion/styled": "*"
39493949
"@mui/material": ">=5.0.0"
39503950
copy-text-to-clipboard: ^3.2.2
3951+
prism-react-renderer: ^2.0.0
39513952
react: "*"
39523953
react-dom: "*"
39533954
react-icons: "*"
3954-
checksum: 10c0/8e88ca4efbc892b01cea5e07f6b46332f32c04008685c7083f52a8f9b0c269f74e6afa2ba5458aae106fcd1ea746a22176f8ec13f5e3823d5405e651e94438ec
3955+
checksum: 10c0/64adad0bcce8856d1855e2da153af9429c8a6ae759fb510933163e523db83a70eeceded9d8e50d108f269f7129f143b5f401509aa3ab0331f5fd14eea3295d66
39553956
languageName: node
39563957
linkType: hard
39573958

@@ -6976,7 +6977,7 @@ __metadata:
69766977
"@emotion/styled": "npm:^11.14.0"
69776978
"@mdx-js/react": "npm:^3.0.0"
69786979
"@mui/material": "npm:^7.1.0"
6979-
"@swmansion/t-rex-ui": "npm:1.3.2"
6980+
"@swmansion/t-rex-ui": "npm:1.3.4"
69806981
clsx: "npm:^2.1.0"
69816982
copy-text-to-clipboard: "npm:3.2.2"
69826983
prettier: "npm:^3.6.2"

0 commit comments

Comments
 (0)