|
1 | | -import React, { CSSProperties, ComponentType, SVGProps } from "react"; |
| 1 | +import React from "react"; |
2 | 2 | import clsx from "clsx"; |
3 | 3 | import styles from "./styles.module.scss"; |
4 | 4 | import DocumentsSvg from "@site/static/img/documents-icon.svg"; |
5 | 5 |
|
6 | | -const icons: Record<string, ComponentType<SVGProps<SVGSVGElement>>> = { |
7 | | - documents: DocumentsSvg, |
8 | | -}; |
9 | | - |
10 | 6 | type DocsBannerProps = { |
11 | 7 | title: string; |
12 | 8 | description: string; |
13 | | - icon?: string; |
14 | | - backgroundColor?: string; |
15 | | - backgroundColorDark?: string; |
16 | 9 | }; |
17 | 10 |
|
18 | 11 | export default function DocsBanner({ |
19 | 12 | title, |
20 | 13 | description, |
21 | | - icon, |
22 | | - backgroundColor, |
23 | | - backgroundColorDark, |
24 | 14 | }: 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 | | - |
30 | 15 | //remove the dulpicate html <header> + h1 tags within the .markdown |
31 | 16 | React.useEffect(() => { |
32 | 17 | const header = document.querySelector(".markdown > header"); |
33 | | - if (header) header.remove(); |
| 18 | + if (header) { |
| 19 | + header.remove(); |
| 20 | + } |
34 | 21 | }, []); |
35 | 22 |
|
36 | 23 | return ( |
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 | | - > |
| 24 | + <header className={clsx(styles.docsBanner)}> |
46 | 25 | <div className={styles.docsBannerLeft}> |
47 | 26 | <h1 className="type-gamma">{title}</h1> |
48 | 27 | <p className="type-paragraph">{description}</p> |
49 | 28 | </div> |
50 | | - |
51 | | - <Icon className={styles.icon} /> |
| 29 | + <DocumentsSvg className={styles.icon} /> |
52 | 30 | </header> |
53 | 31 | ); |
54 | 32 | } |
0 commit comments