Skip to content

Commit

Permalink
docs: demo!
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed May 1, 2021
1 parent 8f3f761 commit d011632
Show file tree
Hide file tree
Showing 20 changed files with 428 additions and 225 deletions.
Binary file added assets/demo-cover.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion demo/slides.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ A fanatical full-time open sourceror.<br>


---
layout: center
title: Sponsors
layout: image
---

<img class="h-100 -mt-10" src="https://cdn.jsdelivr.net/gh/antfu/static/sponsors.png" /><br>
Expand Down
1 change: 0 additions & 1 deletion docs/.vitepress/theme/Layout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ import { ref, computed, watch, defineAsyncComponent } from 'vue'
import {
useRoute,
useSiteData,
usePageData,
useSiteDataByRoute,
} from 'vitepress'
import type { DefaultTheme } from './config'
Expand Down
2 changes: 1 addition & 1 deletion docs/.vitepress/theme/components/HomeFeatures.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

<script setup lang="ts">
import { computed } from 'vue'
import { useSiteDataByRoute, useFrontmatter } from 'vitepress'
import { useFrontmatter } from 'vitepress'
const data = useFrontmatter()
Expand Down
72 changes: 36 additions & 36 deletions docs/.vitepress/theme/components/HomeHero.vue
Original file line number Diff line number Diff line change
@@ -1,54 +1,54 @@
<template>
<header v-if="showHero" class="home-hero">
<p align="center">
<a href="https://github.com/slidevjs/slidev">
<img src="/logo-title.png" alt="Slidev" height="300" />
</a>
<br />
</p>
<div class="description !-mt-4">
Presentation
<b>Sli</b>des for
<b>Dev</b>elopers
</div>
<div class="grid lg:grid-cols-[minmax(400px,600px),minmax(500px,1fr)] gap-4">
<div>
<p align="center">
<a href="https://github.com/slidevjs/slidev">
<img src="/logo-title.png" alt="Slidev" height="300" />
</a>
<br />
</p>
<div class="description !-mt-4">
Presentation
<b>Sli</b>des for
<b>Dev</b>elopers
</div>

<NavLink
v-if="hasAction"
:item="{ link: data.actionLink, text: data.actionText }"
class="action mx-2 rounded-tr-4xl rounded-tl-2xl rounded-br-2xl rounded-bl-3xl"
/>

<NavLink
v-if="hasAltAction"
:item="{ link: data.altActionLink, text: data.altActionText }"
class="action alt mx-2 rounded-tr-2xl rounded-tl-3xl rounded-br-4xl rounded-bl-4xl"
/>

<div class="mt-5 flex">
<div class="mx-auto">
<p>or try it now</p>
<div class="language-bash mt-2">
<pre><code><span class="opacity-50">$ </span><span class="token function">npm init</span> <span class="token text-[#408c9e] font-500">slidev</span></code></pre>
<NavLink
v-if="hasAction"
:item="{ link: data.actionLink, text: data.actionText }"
class="action mx-2 rounded-tr-4xl rounded-tl-2xl rounded-br-2xl rounded-bl-3xl"
/>

<NavLink
v-if="hasAltAction"
:item="{ link: data.altActionLink, text: data.altActionText }"
class="action alt mx-2 rounded-tr-2xl rounded-tl-3xl rounded-br-4xl rounded-bl-4xl"
/>

<div class="mt-5 flex">
<div class="mx-auto">
<p>or try it now</p>
<div class="language-bash mt-2">
<pre><code><span class="opacity-50">$ </span><span class="token function">npm init</span> <span class="token text-[#408c9e] font-500">slidev</span></code></pre>
</div>
</div>
</div>
</div>
<Demo />
</div>
</header>
</template>

<script setup lang="ts">
import { computed } from 'vue'
import { useSiteDataByRoute, useFrontmatter } from 'vitepress'
import { isDark } from '../composables/dark'
import { useFrontmatter } from 'vitepress'
import NavLink from './NavLink.vue'
const site = useSiteDataByRoute()
const data = useFrontmatter()
const hasHeroText = computed(() => data.value.heroText !== null)
const heroText = computed(() => data.value.heroText || site.value.title)
const hasTagline = computed(() => data.value.tagline !== null)
const tagline = computed(() => data.value.tagline || site.value.description)
const hasAction = computed(() => data.value.actionLink && data.value.actionText)
const hasAltAction = computed(() => data.value.altActionLink && data.value.altActionText)
Expand All @@ -70,13 +70,13 @@ const showHero = computed(() => {
@media (min-width: 420px) {
.home-hero {
margin: 0rem 0;
margin: 0;
}
}
@media (min-width: 720px) {
.home-hero {
margin: 0rem 0 4.25rem;
margin: 0 3rem;
}
}
Expand Down
101 changes: 101 additions & 0 deletions docs/.vitepress/theme/components/demo/Demo.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
<script setup lang="ts">
import { ref, onMounted, watch, shallowRef } from 'vue'
// @ts-ignore
import TypeIt from 'typeit'
import Markdown from 'markdown-it'
import type { SlidevMarkdown } from '@slidev/types'
import { parse } from '../../../../../packages/parser/src/core'
import Default from '../../../../../packages/client/layouts/default.vue'
import Center from '../../../../../packages/client/layouts/center.vue'
import SlideContainer from '../../../../../packages/client/internals/SlideContainer.vue'
import Cover from '../../../../../packages/theme-default/layouts/cover.vue'
import '../../../../../packages/theme-default/styles/layout.css'
const paused = ref(false)
const code = ref('')
const html = ref('')
let info: SlidevMarkdown
const block = ref<HTMLPreElement>()
const layout = shallowRef<any>(Default)
const markdown = new Markdown()
watch([code, paused], () => {
if (paused.value)
return
try {
info = parse(code.value)
html.value = markdown.render(info.slides[0].content)
const name = info?.slides?.[0]?.frontmatter?.layout || 'default'
layout.value = name === 'cover'
? Cover
: name === 'center'
? Center
: Default
}
catch (e) {
}
})
onMounted(() => {
new TypeIt(block.value, {
speed: 50,
startDelay: 900,
afterStep: () => {
code.value = JSON.parse(JSON.stringify(block.value!.innerText.replace('|', '')))
},
})
.type('<br><span class="token title"># Welcome to Slidev!</span><br><br>', { delay: 400 })
.type('Presentation Slides for Developers', { delay: 400 })
.move('START', { speed: 0 })
.type('<br>')
.move('START')
.exec(() => paused.value = true)
.type('<span class="token punctuation">---<br><br>---</span>')
.move(-4)
.type('<span class="token tag">layout:</span> center')
.exec(() => paused.value = false)
.pause(1000)
.exec(() => paused.value = true)
.delete(6, { delay: 100, speed: 50 })
.type('cover')
.exec(() => paused.value = false)
.pause(1000)
.type('<br>')
.type('<span class="token tag">background:</span> ', { delay: 500 })
.type('https://slidev.antfu.me/demo-cover.png', { speed: 0, delay: 1000 })
.move('END', { speed: 0 })
.type('<br><br><span class="token punctuation">---</span><br><br>', { delay: 400 })
.type('<span class="token title"># Page 2</span><br><br>', { delay: 400 })
.type('- 📄 Write sldies in a simple Markdown file<br>', { delay: 800 })
.type('- 🌈 Themes, code blocks, interactive components<br>', { delay: 800 })
.type('- 😎 Read the docs to learn more!', { delay: 800 })
.go()
})
</script>

<template>
<div>
<DemoEditor>
<div class="text-sm opacity-50">
./slides.md
</div>

<div class="language-md !bg-transparent">
<pre
ref="block"
class="text-left whitespace-normal font-mono bg-transparent"
></pre>
</div>
</DemoEditor>

<DemoSlide class="text-left">
<SlideContainer class="w-full h-full">
<component :is="layout" v-bind="info?.slides?.[0]?.frontmatter">
<div v-html="html"></div>
</component>
</SlideContainer>
</DemoSlide>
</div>
</template>
30 changes: 30 additions & 0 deletions docs/.vitepress/theme/components/demo/DemoEditor.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<template>
<div class="terminal">
<slot/>
</div>
</template>

<style lang="postcss" scoped>
.terminal {
font-size: 1em;
line-height: 1.2em;
min-height: 450px;
margin-top: 25px;
padding: 10px;
border-radius: 7px;
position: relative;
box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.05), 0 0 30px 1px rgba(0, 0, 0, 0.15);
@apply dark:(bg-gray-400 bg-opacity-5);
}
.terminal::after {
content: "";
position: absolute;
top: 12px;
left: 10px;
width: 12px;
height: 12px;
background: #f95c5b;
border-radius: 100%;
box-shadow: 0 0 0 1px #da3d42, 22px 0 0 0 #fabe3b, 22px 0 0 1px #ecb03e, 44px 0 0 0 #38cd46, 44px 0 0 1px #2eae32;
}
</style>
21 changes: 21 additions & 0 deletions docs/.vitepress/theme/components/demo/DemoSlide.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<template>
<div class="slide">
<div class="aspect-9/16"></div>
<div class="absolute top-0 left-0 right-0 bottom-0">
<slot />
</div>
</div>
</template>

<style lang="postcss" scoped>
.slide {
background: var(--c-bg);
font-size: 1em;
line-height: 1.2em;
border-radius: 7px;
position: relative;
box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.05), 0 0 30px 1px rgba(0, 0, 0, 0.15);
@apply mt-4 transform translate-x-20 -translate-y-20;
@apply dark:(bg-gray-400 bg-opacity-5);
}
</style>
6 changes: 0 additions & 6 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,3 @@ altActionLink: /guide/why

footer: MIT Licensed | Copyright © 2021-PRESENT Anthony Fu
---

or directly try it yourself:

```bash
npm init slidev
```
10 changes: 10 additions & 0 deletions docs/windi.config.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
import { defineConfig } from 'vite-plugin-windicss'
import aspectRatio from 'windicss/plugin/aspect-ratio'

export default defineConfig({
extract: {
include: [
'**/*.{md,vue}',
'.vitepress/**/*.{ts,md,vue}',
'../packages/client/internals/SlideContainer.vue',
'../packages/client/layouts/*.vue',
'../packages/@theme-default/layouts/*.vue',
],
},
plugins: [
aspectRatio,
],
theme: {
extend: {
colors: {
Expand All @@ -15,6 +22,9 @@ export default defineConfig({
deep: '#2082A6',
},
},
fontFamily: {
mono: '\'IBM Plex Mono\', source-code-pro, Menlo, Monaco, Consolas, \'Courier New\', monospace',
},
},
},
})
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"devDependencies": {
"@antfu/eslint-config": "^0.6.4",
"@antfu/ni": "^0.5.8",
"@antfu/utils": "^0.1.3",
"@antfu/utils": "^0.1.4",
"@slidev/cli": "workspace:*",
"@types/cli-progress": "^3.9.1",
"@types/file-saver": "^2.0.2",
Expand All @@ -40,8 +40,10 @@
"rimraf": "^3.0.2",
"ts-jest": "^26.5.5",
"tsup": "^4.10.1",
"typeit": "^7.0.4",
"typescript": "^4.2.4",
"vite-plugin-windicss": "^0.16.0-beta.5",
"typewriter-effect": "^2.17.0",
"vite-plugin-windicss": "^0.16.0-beta.6",
"vitepress": "^0.13.2"
}
}
7 changes: 6 additions & 1 deletion packages/client/internals/SlideContainer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ const props = defineProps({
route: {
default: () => ({}) as any as RouteRecordRaw,
},
is: {
type: Object,
},
})
const tab = useVModel(props, 'tab', emit)
Expand Down Expand Up @@ -70,7 +73,9 @@ const style = computed(() => ({
<template>
<div id="slide-container" ref="root">
<div id="slide-content" :style="style">
<component :is="route.component"/>
<slot>
<component :is="props.is || route.component" />
</slot>
</div>
<slot name="controls" />
</div>
Expand Down
2 changes: 1 addition & 1 deletion packages/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"homepage": "https://github.com/slidevjs/slidev",
"bugs": "https://github.com/slidevjs/slidev/issues",
"dependencies": {
"@antfu/utils": "^0.1.3",
"@antfu/utils": "^0.1.4",
"@slidev/types": "workspace:*",
"@vueuse/core": "^4.9.1",
"@vueuse/head": "^0.5.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/create-app/template/slides.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class: "px-20"

# Themes

Slidev come with a powerful theming support. Themes are able to provide styles, layouts, components or even tools configurations. Switching between themes by just **one edit** in your frontmatter:
Slidev comes with powerful theming support. Themes are able to provide styles, layouts, components, or even configurations for tools. Switching between themes by just **one edit** in your frontmatter:

<div grid="~ cols-2 gap-2" m="-t-2">

Expand Down
Loading

0 comments on commit d011632

Please sign in to comment.