Skip to content

Commit 8e9115c

Browse files
changed in approach. added a new key in Svg component.
1 parent 9de0343 commit 8e9115c

File tree

4 files changed

+21
-16
lines changed

4 files changed

+21
-16
lines changed

Diff for: docs/src/components/HomepageFeatures/index.tsx

+10-7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable react/require-default-props */
12
/* eslint-disable import/no-unresolved */
23
/* eslint-disable @typescript-eslint/no-var-requires */
34
/* eslint-disable global-require */
@@ -9,6 +10,7 @@ type FeatureItem = {
910
title: string
1011
Svg: React.ComponentType<React.ComponentProps<'svg'>>
1112
description: JSX.Element
13+
allowsDarkMode?: boolean
1214
}
1315

1416
const FeatureList: FeatureItem[] = [
@@ -28,6 +30,7 @@ const FeatureList: FeatureItem[] = [
2830
community to always try to improve ReactTooltip.
2931
</>
3032
),
33+
allowsDarkMode: true,
3134
},
3235
{
3336
title: 'Focus on What Matters',
@@ -41,16 +44,16 @@ const FeatureList: FeatureItem[] = [
4144
},
4245
]
4346

44-
function Feature({ title, Svg, description }: FeatureItem) {
45-
let svgClassName = styles.featureSvg
46-
if (Svg === require('@site/static/img/github.svg').default) {
47-
svgClassName = `${styles.featureSvg} ${styles.githubLogo}`
48-
}
49-
47+
function Feature({ title, Svg, description,allowsDarkMode }: FeatureItem) {
5048
return (
5149
<div className={clsx('col col--4')}>
5250
<div className="text--center">
53-
<Svg className={svgClassName} role="img" />
51+
<Svg
52+
className={clsx(styles.featureSvg, {
53+
[styles.svgDarkMode]: allowsDarkMode,
54+
})}
55+
role="img"
56+
/>
5457
</div>
5558
<div className="text--center padding-horiz--md">
5659
<h3>{title}</h3>

Diff for: docs/src/components/HomepageFeatures/styles.module.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@
1010
width: 200px;
1111
}
1212

13-
html[data-theme='dark'] .githubLogo {
13+
html[data-theme='dark'] .svgDarkMode {
1414
fill: #fff;
1515
}

Diff for: docs/src/components/HomepageSponsored/index.tsx

+9-7
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ type FeatureItem = {
1414
// eslint-disable-next-line react/no-unused-prop-types
1515
eventTitle?: string
1616
link: string
17+
allowsDarkMode?: boolean
1718
}
1819

1920
type SponsorItem = FeatureItem & {
@@ -30,6 +31,7 @@ const FeatureList: FeatureItem[] = [
3031
title: 'Algolia',
3132
Svg: require('@site/static/img/Algolia-logo.svg').default,
3233
link: 'https://docsearch.algolia.com/',
34+
allowsDarkMode: true,
3335
},
3436
]
3537

@@ -50,17 +52,17 @@ const SponsorList: SponsorItem[] = [
5052
// },
5153
]
5254

53-
function Feature({ title, Svg, link }: FeatureItem) {
54-
let svgClassName = styles.featureSvg
55-
if (Svg === require('@site/static/img/Algolia-logo.svg').default) {
56-
svgClassName = `${styles.featureSvg} ${styles.AlgoliaLogo}`
57-
}
58-
55+
function Feature({ title, Svg, link,allowsDarkMode}: FeatureItem) {
5956
return (
6057
<div className={clsx('col col--6')}>
6158
<div className="text--center">
6259
<a href={link} title={title} target="_blank" rel="noreferrer" aria-label={title}>
63-
<Svg className={svgClassName} role="img"/>
60+
<Svg
61+
className={clsx(styles.featureSvg, {
62+
[styles.svgDarkMode]: allowsDarkMode,
63+
})}
64+
role="img"
65+
/>
6466
</a>
6567
</div>
6668
</div>

Diff for: docs/src/components/HomepageSponsored/styles.module.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@
3030
}
3131
}
3232

33-
html[data-theme='dark'] .AlgoliaLogo{
33+
html[data-theme='dark'] .svgDarkMode {
3434
fill: #fff;
3535
}

0 commit comments

Comments
 (0)