Skip to content

Commit 857b296

Browse files
authored
fix: the style dom should be preserve (#45)
1 parent a8af843 commit 857b296

2 files changed

Lines changed: 13 additions & 18 deletions

File tree

src/background-image/global.scss

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

src/background-image/index.tsx

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { type FC, useEffect, useState } from 'react';
22
import styles from './index.module.scss';
3-
import './global.scss';
43

54
const useTopArrived = () => {
65
const [scrollY, setScrollY] = useState(0);
@@ -45,10 +44,18 @@ export const BackgroundImage: FC<BackgroundProps> = ({
4544
}, [topArrived, navBarTopArrived]);
4645

4746
return (
48-
<img
49-
className={styles.background}
50-
src="https://assets.rspack.rs/rspack/assets/landingpage-background-compressed.png"
51-
alt="background"
52-
/>
47+
<>
48+
{/* For transparent navbar, overrides css only in homepage, and unmounted in other pages */}
49+
<style>
50+
{
51+
':root {--rp-c-bg: #0b0c0e;}:root:not(.dark) {--rp-c-bg: #fff;}.rspress-nav {transition: background 0.4s;}body:not(.notTopArrived) .rspress-nav {background: transparent !important;}'
52+
}
53+
</style>
54+
<img
55+
className={styles.background}
56+
src="https://assets.rspack.rs/rspack/assets/landingpage-background-compressed.png"
57+
alt="background"
58+
/>
59+
</>
5360
);
5461
};

0 commit comments

Comments
 (0)