Skip to content

Commit

Permalink
feat: rename options and wording
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Dec 17, 2024
1 parent 2a5438d commit f0304c8
Show file tree
Hide file tree
Showing 14 changed files with 37 additions and 31 deletions.
4 changes: 2 additions & 2 deletions docs/custom/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ keywords: keyword1,keyword2

# enable presenter mode, can be boolean, 'dev' or 'build'
presenter: true
# enable exporting UI, can be boolean, 'dev' or 'build'
exportingUI: dev
# enable browser exporter, can be boolean, 'dev' or 'build'
browserExporter: dev
# enabled pdf downloading in SPA build, can also be a custom url
download: false
# filename of the export file
Expand Down
2 changes: 1 addition & 1 deletion packages/client/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export const HEADMATTER_FIELDS = [
'author',
'keywords',
'presenter',
'exportingUI',
'browserExporter',
'download',
'exportFilename',
'export',
Expand Down
9 changes: 7 additions & 2 deletions packages/client/internals/IconButton.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
<script setup lang="ts">
defineProps<{
import { computed } from 'vue'
const props = defineProps<{
title: string
icon?: string
as?: string
to?: string
}>()
const type = computed(() => props.as || (props.to ? 'router-link' : 'button'))
</script>

<template>
<component :is="as || 'button'" class="slidev-icon-btn" :title="title">
<component :is="type" class="slidev-icon-btn" :title="title" :to="to">
<span class="sr-only">{{ title }}</span>
<slot>
<div :class="icon" />
Expand Down
8 changes: 7 additions & 1 deletion packages/client/internals/NavControls.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ if (__SLIDEV_FEATURE_RECORD__)
<template>
<nav ref="root" class="flex flex-col">
<div
class="flex flex-wrap-reverse text-xl gap-0.5 p-1 lg:gap-1 lg:p-2"
class="flex flex-wrap-reverse text-xl gap-0.5 p-1 lg:p-2"
:class="barStyle"
@mouseleave="onMouseLeave"
>
Expand Down Expand Up @@ -142,6 +142,12 @@ if (__SLIDEV_FEATURE_RECORD__)
</IconButton>
</template>

<template v-if="__SLIDEV_FEATURE_BROWSER_EXPORTER__">
<IconButton title="Browser Explorer" to="/export">
<div class="i-carbon:document-pdf" />
</IconButton>
</template>

<IconButton
v-if="!isPresenter && configs.info && !isEmbedded"
title="Show info"
Expand Down
12 changes: 4 additions & 8 deletions packages/client/internals/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,9 @@ const wakeLockItems: SelectionItem<boolean>[] = [
<template>
<div class="text-sm select-none mb-2">
<SelectList v-model="slideScale" title="Scale" :items="scaleItems" />
<SelectList v-if="__SLIDEV_FEATURE_WAKE_LOCK__ && isSupported" v-model="wakeLockEnabled" title="Wake lock" :items="wakeLockItems" />
<div class="text-xs uppercase opacity-50 tracking-widest px-7 py-1 select-none text-nowrap">
Actions
</div>
<RouterLink v-if="__SLDIEV_FEATURE_EXPORTING_UI__" to="/export" class="block px-2 flex gap-1 py-1 hover:bg-gray-400 hover:bg-opacity-10">
<div class="i-carbon:export text-3 w-4 op-80 my-a" />
Export as
</RouterLink>
<SelectList
v-if="__SLIDEV_FEATURE_WAKE_LOCK__ && isSupported"
v-model="wakeLockEnabled" title="Wake lock" :items="wakeLockItems"
/>
</div>
</template>
2 changes: 1 addition & 1 deletion packages/client/pages/export.vue
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ if (import.meta.hot) {
<div class="print:hidden min-w-fit flex flex-wrap md:flex-nowrap md:of-y-auto md:flex-col gap-2 p-6 max-w-100">
<h1 class="text-3xl md:my-4 flex items-center gap-2 w-full">
<RouterLink to="/" class="i-carbon:previous-outline op-70 hover:op-100" />
Export Slides
Browser Exporter
<sup op50 italic text-sm>Experimental</sup>
</h1>
<div flex="~ col gap-2">
Expand Down
2 changes: 1 addition & 1 deletion packages/client/setup/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export default function setupRoutes() {
)
}

if (__SLDIEV_FEATURE_EXPORTING_UI__) {
if (__SLIDEV_FEATURE_BROWSER_EXPORTER__) {
routes.push(
{
name: 'export',
Expand Down
3 changes: 1 addition & 2 deletions packages/client/styles/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@ html {

.slidev-icon-btn {
aspect-ratio: 1;
display: inline-block;
user-select: none;
outline: none;
cursor: pointer;
@apply opacity-75 transition duration-200 ease-in-out align-middle rounded p-1;
@apply inline-flex items-center justify-center opacity-75 transition duration-200 ease-in-out align-middle rounded p-1;
@apply hover:(opacity-100 bg-gray-400 bg-opacity-10);
@apply focus-visible:(opacity-100 outline outline-2 outline-offset-2 outline-black dark:outline-white);
@apply md:p-2;
Expand Down
2 changes: 1 addition & 1 deletion packages/parser/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export function getDefaultConfig(): SlidevConfig {
record: 'dev',
css: 'unocss',
presenter: true,
exportingUI: 'dev',
browserExporter: 'dev',
htmlAttrs: {},
transition: null,
editor: true,
Expand Down
8 changes: 4 additions & 4 deletions packages/slidev/node/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -447,11 +447,11 @@ cli.command(
for (const entryFile of entry as unknown as string) {
const options = await resolveOptions({ entry: entryFile, theme }, 'export')

if (options.data.config.exportingUI !== false && !warned) {
if (options.data.config.browserExporter !== false && !warned) {
warned = true
console.log(lightCyan('[Slidev] Try the new exporting UI!'))
console.log(lightCyan('[Slidev] Try the new browser exporter!'))
console.log(
lightCyan('You can use the exporting UI instead by starting the dev server as normal and visit'),
lightCyan('You can use the browser exporter instead by starting the dev server as normal and visit'),
`${blue('localhost:')}${dim('<port>')}${blue('/export')}\n`,
)
}
Expand Down Expand Up @@ -647,7 +647,7 @@ function printInfo(
if (options.utils.define.__SLIDEV_FEATURE_PRESENTER__)
console.log(`${dim(' presenter mode ')} > ${blue(`http://localhost:${bold(port)}${presenterPath}`)}`)
console.log(`${dim(' slides overview ')} > ${blue(`http://localhost:${bold(port)}${overviewPath}`)}`)
if (options.utils.define.__SLDIEV_FEATURE_EXPORTING_UI__)
if (options.utils.define.__SLIDEV_FEATURE_BROWSER_EXPORTER__)
console.log(`${dim(' export slides')} > ${blue(`http://localhost:${bold(port)}/export/`)}`)
if (options.inspect)
console.log(`${dim(' vite inspector')} > ${yellow(`http://localhost:${bold(port)}/__inspect/`)}`)
Expand Down
2 changes: 1 addition & 1 deletion packages/slidev/node/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ function getDefine(options: Omit<ResolvedSlidevOptions, 'utils'>): Record<string
__SLIDEV_FEATURE_RECORD__: matchMode(options.data.config.record),
__SLIDEV_FEATURE_PRESENTER__: matchMode(options.data.config.presenter),
__SLIDEV_FEATURE_PRINT__: options.mode === 'export' || (options.mode === 'build' && [true, 'true', 'auto'].includes(options.data.config.download)),
__SLDIEV_FEATURE_EXPORTING_UI__: matchMode(options.data.config.exportingUI),
__SLIDEV_FEATURE_BROWSER_EXPORTER__: matchMode(options.data.config.browserExporter),
__SLIDEV_FEATURE_WAKE_LOCK__: matchMode(options.data.config.wakeLock),
__SLIDEV_HAS_SERVER__: options.mode !== 'build',
},
Expand Down
4 changes: 2 additions & 2 deletions packages/types/src/frontmatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,11 @@ export interface HeadmatterConfig extends TransitionOptions {
*/
presenter?: boolean | 'dev' | 'build'
/**
* Enable exporting user interface
* Enable browser exporter
*
* @default 'dev'
*/
exportingUI?: boolean | 'dev' | 'build'
browserExporter?: boolean | 'dev' | 'build'
/**
* Attributes to apply to the HTML element
*
Expand Down
6 changes: 3 additions & 3 deletions packages/vscode/schema/headmatter.json
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@
"markdownDescription": "Enable presenter mode",
"default": true
},
"exportingUI": {
"browserExporter": {
"anyOf": [
{
"type": "boolean"
Expand All @@ -359,8 +359,8 @@
"const": "build"
}
],
"description": "Enable exporting user interface",
"markdownDescription": "Enable exporting user interface",
"description": "Enable browser exporter",
"markdownDescription": "Enable browser exporter",
"default": "dev"
},
"htmlAttrs": {
Expand Down
4 changes: 2 additions & 2 deletions shim.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ declare global {
const __SLIDEV_FEATURE_RECORD__: boolean
const __SLIDEV_FEATURE_PRESENTER__: boolean
const __SLIDEV_FEATURE_PRINT__: boolean
const __SLDIEV_FEATURE_EXPORTING_UI__: boolean
const __SLIDEV_FEATURE_BROWSER_EXPORTER__: boolean
const __SLIDEV_FEATURE_WAKE_LOCK__: boolean
const __SLIDEV_HAS_SERVER__: boolean
}
Expand All @@ -25,7 +25,7 @@ declare module '@vue/runtime-core' {
__SLIDEV_FEATURE_RECORD__: boolean
__SLIDEV_FEATURE_PRESENTER__: boolean
__SLIDEV_FEATURE_PRINT__: boolean
__SLDIEV_FEATURE_EXPORTING_UI__: boolean
__SLIDEV_FEATURE_BROWSER_EXPORTER__: boolean
__SLIDEV_FEATURE_WAKE_LOCK__: boolean
__SLIDEV_HAS_SERVER__: boolean
}
Expand Down

0 comments on commit f0304c8

Please sign in to comment.