Compare commits

...

2 commits

Author SHA1 Message Date
2684f9faa6 Added backgrund built-in component 2025-08-01 15:15:58 +08:00
d39d7263c5 Updated README 2025-08-01 15:15:43 +08:00
3 changed files with 33 additions and 0 deletions

View file

@ -33,3 +33,8 @@ pnpm install
```
pnpm update
```
# To Use Background
Place your background image in `assets/images/background.avif` or `assets/images/background.webp`.
Then, enable by adding <Background image /> or <Background color="#123456">

View file

@ -0,0 +1 @@
@use '/src/styles/classes.sass'

View file

@ -0,0 +1,27 @@
import './Background.sass'
import { Show } from 'solid-js'
import backgroundAvif from '../../assets/images/background.avif'
import backgroundWebp from '../../assets/images/background.webp'
interface Props {
image?: boolean
color?: string
}
export default (props: Props) => {
return (
<>
<Show when={props.image}>
<picture class="fullscreen">
<source srcset={backgroundAvif.src} type="image/avif" />
<source srcset={backgroundWebp.src} type="image/webp" />
<img src={backgroundWebp.src} width="1920" height="auto" decoding="async" loading="lazy" alt="An image background" />
</picture>
</Show>
<Show when={!props.image}>
<div style={{ background: props.color }} class="fullscreen" />
</Show>
</>
)
}