Skip to content

Commit 8e1aa1d

Browse files
authored
Merge pull request #804 from IABTechLab/ibg-TTD-786-banner-tables
ibg-TTD-786-banner-tables
2 parents 144f2ca + f7e1586 commit 8e1aa1d

File tree

7 files changed

+67
-20
lines changed

7 files changed

+67
-20
lines changed

docs/overviews/overview-publishers.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ sidebar_position: 02
66
use_banner: true
77
banner_title: UID2 Overview for Publishers
88
banner_description: Maintain audience targeting in the ever-changing advertising industry for better impression monetization and more relevance.
9+
banner_icon: 'documents'
10+
banner_background_color: ''
11+
banner_background_color_dark: ''
912
displayed_sidebar: sidebarPublishers
1013
---
1114

package-lock.json

Lines changed: 17 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
},
5252
"overrides": {
5353
"body-parser@1": "1.20.3",
54-
"path-to-regexp@0": "0.1.10",
54+
"path-to-regexp@0": "0.1.12",
5555
"path-to-regexp@1": "1.9.0",
5656
"path-to-regexp@2": "8.0.0"
5757
},
Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,54 @@
1-
import React from "react";
1+
import React, { CSSProperties, ComponentType, SVGProps } from "react";
22
import clsx from "clsx";
33
import styles from "./styles.module.scss";
44
import DocumentsSvg from "@site/static/img/documents-icon.svg";
55

6+
const icons: Record<string, ComponentType<SVGProps<SVGSVGElement>>> = {
7+
documents: DocumentsSvg,
8+
};
9+
610
type DocsBannerProps = {
711
title: string;
812
description: string;
13+
icon?: string;
14+
backgroundColor?: string;
15+
backgroundColorDark?: string;
916
};
1017

1118
export default function DocsBanner({
1219
title,
1320
description,
21+
icon,
22+
backgroundColor,
23+
backgroundColorDark,
1424
}: DocsBannerProps): JSX.Element {
25+
const Icon = (icon && icons[icon]) || icons.documents;
26+
27+
backgroundColor ||= "var(--c-dirty-socks)"; // default banner bg color
28+
backgroundColorDark ||= "var(--c-primary-gray)"; // default banner bg color dark theme
29+
1530
//remove the dulpicate html <header> + h1 tags within the .markdown
1631
React.useEffect(() => {
1732
const header = document.querySelector(".markdown > header");
18-
if (header) {
19-
header.remove();
20-
}
33+
if (header) header.remove();
2134
}, []);
2235

2336
return (
24-
<header className={clsx(styles.docsBanner)}>
37+
<header
38+
className={clsx(styles.docsBanner)}
39+
style={
40+
{
41+
"--bg-docs-banner": backgroundColor,
42+
"--bg-docs-banner-dark": backgroundColorDark,
43+
} as CSSProperties
44+
}
45+
>
2546
<div className={styles.docsBannerLeft}>
2647
<h1 className="type-gamma">{title}</h1>
2748
<p className="type-paragraph">{description}</p>
2849
</div>
29-
<DocumentsSvg className={styles.icon} />
50+
51+
<Icon className={styles.icon} />
3052
</header>
3153
);
3254
}

src/components/DocsBanner/styles.module.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
padding: 1.25rem;
44
display: flex;
55
flex-direction: column;
6-
background-color: var(--c-dirty-socks);
6+
background-color: var(--bg-docs-banner); // var is set in html styles
77
margin-bottom: 1.875rem;
88
align-items: center;
99

@@ -34,7 +34,7 @@
3434
}
3535

3636
html[data-theme="dark"] & {
37-
background-color: var(--c-primary-gray);
37+
background-color: var(--bg-docs-banner-dark); // var is set in html styles
3838

3939
h1,
4040
p {

src/css/markdown.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
vertical-align: top;
2424
}
2525

26+
table th {
27+
text-align: left;
28+
}
29+
2630
thead {
2731
@extend .type-eta;
2832
}

src/theme/DocItem/Layout/index.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ type CustomDocFrontMatter = DocFrontMatter & {
2121
use_banner?: boolean;
2222
banner_title?: string;
2323
banner_description?: string;
24+
banner_icon?: string;
25+
banner_background_color?: string;
26+
banner_background_color_dark?: string;
2427
};
2528

2629
/**
@@ -83,7 +86,15 @@ export default function DocItemLayout({ children }: Props): JSX.Element {
8386
{docTOC.mobile}
8487
<DocBreadcrumbs />
8588
{useBanner && (
86-
<DocsBanner title={bannerTitle} description={bannerDescription} />
89+
<DocsBanner
90+
title={bannerTitle}
91+
description={bannerDescription}
92+
icon={customFrontMatter.banner_icon}
93+
backgroundColor={customFrontMatter.banner_background_color}
94+
backgroundColorDark={
95+
customFrontMatter.banner_background_color_dark
96+
}
97+
/>
8798
)}
8899
<DocVersionBadge />
89100
<DocItemContent>{children}</DocItemContent>

0 commit comments

Comments
 (0)