Skip to content

Commit

Permalink
feat: make background image configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Apr 25, 2021
1 parent c35e1c9 commit c99e0f9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
1 change: 1 addition & 0 deletions packages/create-app/template/slides.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
theme: '@slidev/theme-seriph'
background: 'https://images.unsplash.com/photo-1619191163166-07a53b7a8f30?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=1950&q=80'
---

# Welcome to Slidev
Expand Down
24 changes: 18 additions & 6 deletions packages/theme-seriph/layouts/cover.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
<script setup lang="ts">
import { defineProps, computed } from 'vue'
const props = defineProps({
background: {
default: 'https://images.unsplash.com/photo-1504275107627-0c2ba7a43dba?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=2167&q=80',
},
})
const style = computed(() => ({
backgroundImage: `linear-gradient(#0005, #0008), url(${props.background})`,
backgroundRepeat: 'no-repeat',
backgroundPosition: 'center',
backgroundSize: 'cover',
}))
</script>

<template>
<div
class="layout-master cover text-white text-center"
style="
background-image: linear-gradient(#0005, #0008), url('https://images.unsplash.com/photo-1504275107627-0c2ba7a43dba?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=2167&q=80');
background-repeat: no-repeat;
background-position: center;
background-size: cover;
"
:style="style"
>
<div class="my-auto w-full">
<slot />
Expand Down

0 comments on commit c99e0f9

Please sign in to comment.