-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: better handle for windi config
- Loading branch information
Showing
18 changed files
with
183 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
</head> | ||
<body> | ||
<div id="app"></div> | ||
<script> | ||
(function() { | ||
const prefersDark = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches | ||
const setting = localStorage.getItem('color-schema') || 'auto' | ||
if (setting === 'dark' || (prefersDark && setting !== 'light')) | ||
document.documentElement.classList.toggle('dark', true) | ||
})() | ||
</script> | ||
<script type="module" src="/@fs/Users/antfu/i/vite-slides/packages/vite-slides/client/main.ts"></script> | ||
<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -89,7 +89,3 @@ | |
@apply opacity-40 mb-10 text-2xl; | ||
} | ||
} | ||
|
||
.layout-master.center { | ||
@apply h-full grid place-content-center; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { resolve } from 'path' | ||
import { mergeWindicssConfig } from 'vite-slides' | ||
import { defineConfig } from 'windicss/helpers' | ||
import BaseConfig from 'vite-slides/client/windi.config' | ||
|
||
export default mergeWindicssConfig( | ||
BaseConfig, | ||
defineConfig({ | ||
extract: { | ||
include: [ | ||
resolve(__dirname, '**/*.{vue,ts}'), | ||
], | ||
exclude: [ | ||
resolve(__dirname, 'node_modules/**/*'), | ||
], | ||
}, | ||
shortcuts: { | ||
'bg-main': 'bg-white text-[#181818] dark:(bg-[#121212] text-[#ddd])', | ||
'disabled': 'opacity-25 pointer-events-none', | ||
'abs-t': 'absolute bottom-0 left-0 right-0', | ||
'abs-tl': 'absolute top-0 left-0', | ||
'abs-tr': 'absolute top-0 right-0', | ||
'abs-b': 'absolute bottom-0 left-0 right-0', | ||
'abs-bl': 'absolute bottom-0 left-0', | ||
'abs-br': 'absolute bottom-0 right-0', | ||
}, | ||
theme: { | ||
extend: { | ||
fontFamily: { | ||
sans: '"Avenir Next"', | ||
}, | ||
colors: { | ||
primary: { | ||
DEFAULT: '#42b883', | ||
}, | ||
}, | ||
}, | ||
}, | ||
}), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,28 @@ | ||
<script setup lang="ts"> | ||
import { defineProps, onMounted } from 'vue' | ||
import { defineProps, onMounted, ref } from 'vue' | ||
import { isDark } from '../logic' | ||
defineProps<{ | ||
url?: string | ||
const props = defineProps<{ | ||
id: string | number | ||
scale?: string | number | ||
}>() | ||
const tweet = ref<HTMLElement | null>() | ||
onMounted(() => { | ||
// @ts-ignore | ||
window?.twttr.widgets.load() | ||
window?.twttr.widgets.createTweet( | ||
props.id.toString(), | ||
tweet.value, | ||
{ | ||
theme: isDark.value ? 'dark' : 'light', | ||
}, | ||
) | ||
}) | ||
</script> | ||
|
||
<template> | ||
<Transform :scale="scale || 0.7" class="tweet"> | ||
<blockquote class="twitter-tweet" :data-theme="isDark ? 'dark': 'light'"> | ||
<slot> | ||
<a :href="url" /> | ||
</slot> | ||
</blockquote> | ||
<Transform :scale="scale || 0.7"> | ||
<div ref="tweet"></div> | ||
</Transform> | ||
</template> | ||
|
||
<style> | ||
.tweet blockquote { | ||
opacity: 0; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<script setup lang="ts"> | ||
import { defineProps } from 'vue' | ||
defineProps<{ | ||
id: string | ||
width?: number | ||
height?: number | ||
}>() | ||
</script> | ||
|
||
<template> | ||
<iframe | ||
:width="width" | ||
:height="height" | ||
:src="`https://www.youtube.com/embed/${id}`" | ||
title="YouTube" | ||
frameborder="0" | ||
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" | ||
allowfullscreen | ||
></iframe> | ||
</template> |
2 changes: 1 addition & 1 deletion
2
packages/theme-default/layouts/center.vue → ...ges/vite-slides/client/layouts/center.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<template> | ||
<div class="layout-master full w-full h-full"> | ||
<slot class="w-full h-full"/> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { resolve } from 'path' | ||
import { defineConfig } from 'windicss/helpers' | ||
|
||
export default defineConfig({ | ||
extract: { | ||
include: [ | ||
resolve(__dirname, '**/*.{vue,ts}'), | ||
'src/**/*.{vue,ts}', | ||
'components/**/*.{vue,ts}', | ||
'slides.md', | ||
], | ||
exclude: [ | ||
'.git/**', | ||
], | ||
}, | ||
safelist: [ | ||
'!opacity-0', | ||
], | ||
darkMode: 'class', | ||
preflight: { | ||
includeAll: true, | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,19 @@ | ||
import { resolve } from 'path' | ||
import { defineConfig } from 'windicss/helpers' | ||
import { ResolvedViteSlidesOptions } from './options' | ||
import { isObject } from '@antfu/utils' | ||
import { Config as WindiCssConfig } from 'windicss/types/interfaces' | ||
|
||
export function getDefultWindiConfig({ packageRoot, themeRoot }: ResolvedViteSlidesOptions) { | ||
return defineConfig({ | ||
extract: { | ||
include: [ | ||
resolve(packageRoot, 'client/**/*.{vue,ts}'), | ||
resolve(themeRoot, '**/*.{vue,ts}'), | ||
'src/**/*.{vue,ts}', | ||
'components/**/*.{vue,ts}', | ||
'slides.md', | ||
], | ||
exclude: [ | ||
'.git/**', | ||
resolve(themeRoot, 'node_modules/*'), | ||
], | ||
}, | ||
safelist: [ | ||
'!opacity-0', | ||
], | ||
darkMode: 'class', | ||
preflight: { | ||
includeAll: true, | ||
}, | ||
shortcuts: { | ||
'bg-main': 'bg-white text-[#181818] dark:(bg-[#121212] text-[#ddd])', | ||
'disabled': 'opacity-25 pointer-events-none', | ||
'abs-t': 'absolute bottom-0 left-0 right-0', | ||
'abs-tl': 'absolute top-0 left-0', | ||
'abs-tr': 'absolute top-0 right-0', | ||
'abs-b': 'absolute bottom-0 left-0 right-0', | ||
'abs-bl': 'absolute bottom-0 left-0', | ||
'abs-br': 'absolute bottom-0 right-0', | ||
}, | ||
theme: { | ||
extend: { | ||
fontFamily: { | ||
sans: '"Avenir Next"', | ||
}, | ||
colors: { | ||
primary: { | ||
DEFAULT: '#42b883', | ||
}, | ||
}, | ||
}, | ||
}, | ||
function deepMerge(a: any, b: any, rootPath: string) { | ||
a = { ...a } | ||
Object.keys(b).forEach((key) => { | ||
if (isObject(a[key])) | ||
a[key] = deepMerge(a[key], b[key], rootPath ? `${rootPath}.${key}` : key) | ||
else if (Array.isArray(a[key])) | ||
a[key] = [...a[key], ...b[key]] | ||
else | ||
a[key] = b[key] | ||
}) | ||
return a | ||
} | ||
|
||
export function mergeWindicssConfig(a: WindiCssConfig, b: WindiCssConfig) { | ||
return deepMerge(a, b, '') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.