Compare commits
2 commits
9e7c3e6b7f
...
2684f9faa6
| Author | SHA1 | Date | |
|---|---|---|---|
| 2684f9faa6 | |||
| d39d7263c5 |
3 changed files with 33 additions and 0 deletions
|
|
@ -33,3 +33,8 @@ pnpm install
|
||||||
```
|
```
|
||||||
pnpm update
|
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">
|
||||||
|
|
|
||||||
1
src/builtin-components/Background/Background.sass
Normal file
1
src/builtin-components/Background/Background.sass
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
@use '/src/styles/classes.sass'
|
||||||
27
src/builtin-components/Background/Background.tsx
Normal file
27
src/builtin-components/Background/Background.tsx
Normal 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>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue