mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-24 10:20:19 +08:00
docs(ConfigProvider): optimize theme demo (#11725)
This commit is contained in:
parent
28885fdee5
commit
53260297bd
@ -1,10 +1,9 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, computed } from 'vue';
|
import { ref } from 'vue';
|
||||||
import VanCell from '../../cell';
|
import VanCell from '../../cell';
|
||||||
import VanForm from '../../form';
|
import VanForm from '../../form';
|
||||||
import VanField from '../../field';
|
import VanField from '../../field';
|
||||||
import VanRate from '../../rate';
|
import VanRate from '../../rate';
|
||||||
import VanSwitch from '../../switch';
|
|
||||||
import VanSlider from '../../slider';
|
import VanSlider from '../../slider';
|
||||||
import VanButton from '../../button';
|
import VanButton from '../../button';
|
||||||
import VanConfigProvider from '..';
|
import VanConfigProvider from '..';
|
||||||
@ -19,7 +18,7 @@ const t = useTranslate({
|
|||||||
customTheme: '定制主题',
|
customTheme: '定制主题',
|
||||||
defaultTheme: '默认主题',
|
defaultTheme: '默认主题',
|
||||||
darkMode: '深色模式',
|
darkMode: '深色模式',
|
||||||
switchDarkMode: '切换深色模式',
|
switchDarkMode: '请点击文档右上角的按钮,切换深浅模式。',
|
||||||
},
|
},
|
||||||
'en-US': {
|
'en-US': {
|
||||||
rate: 'Rate',
|
rate: 'Rate',
|
||||||
@ -29,12 +28,11 @@ const t = useTranslate({
|
|||||||
customTheme: 'Custom Theme',
|
customTheme: 'Custom Theme',
|
||||||
defaultTheme: 'DefaultTheme',
|
defaultTheme: 'DefaultTheme',
|
||||||
darkMode: 'Dark Mode',
|
darkMode: 'Dark Mode',
|
||||||
switchDarkMode: 'Switch Dark Mode',
|
switchDarkMode:
|
||||||
|
'Please click the button in the upper right corner to switch between dark and light modes.',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const darkMode = ref(false);
|
|
||||||
const theme = computed(() => (darkMode.value ? 'dark' : 'light'));
|
|
||||||
const rate = ref(4);
|
const rate = ref(4);
|
||||||
const slider = ref(50);
|
const slider = ref(50);
|
||||||
const themeVars = {
|
const themeVars = {
|
||||||
@ -49,17 +47,12 @@ const themeVars = {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div :style="{ background: darkMode ? 'black' : '', minHeight: '100vh' }">
|
<div :style="{ minHeight: '100vh' }">
|
||||||
<demo-block :title="t('darkMode')">
|
<demo-block :title="t('darkMode')">
|
||||||
<van-cell center :title="t('switchDarkMode')">
|
<van-cell :title="t('switchDarkMode')" />
|
||||||
<template #right-icon>
|
|
||||||
<van-switch v-model="darkMode" />
|
|
||||||
</template>
|
|
||||||
</van-cell>
|
|
||||||
</demo-block>
|
</demo-block>
|
||||||
|
|
||||||
<demo-block :title="t('defaultTheme')">
|
<demo-block :title="t('defaultTheme')">
|
||||||
<van-config-provider :theme="theme">
|
|
||||||
<van-form>
|
<van-form>
|
||||||
<van-field name="rate" :label="t('rate')">
|
<van-field name="rate" :label="t('rate')">
|
||||||
<template #input>
|
<template #input>
|
||||||
@ -79,11 +72,10 @@ const themeVars = {
|
|||||||
</van-button>
|
</van-button>
|
||||||
</div>
|
</div>
|
||||||
</van-form>
|
</van-form>
|
||||||
</van-config-provider>
|
|
||||||
</demo-block>
|
</demo-block>
|
||||||
|
|
||||||
<demo-block :title="t('customTheme')">
|
<demo-block :title="t('customTheme')">
|
||||||
<van-config-provider :theme="theme" :theme-vars="themeVars">
|
<van-config-provider :theme-vars="themeVars">
|
||||||
<van-form>
|
<van-form>
|
||||||
<van-field name="rate" :label="t('rate')">
|
<van-field name="rate" :label="t('rate')">
|
||||||
<template #input>
|
<template #input>
|
||||||
|
@ -3,24 +3,15 @@
|
|||||||
exports[`should render demo and match snapshot 1`] = `
|
exports[`should render demo and match snapshot 1`] = `
|
||||||
<div style="min-height: 100vh;">
|
<div style="min-height: 100vh;">
|
||||||
<div>
|
<div>
|
||||||
<div class="van-cell van-cell--center">
|
<div class="van-cell">
|
||||||
<div class="van-cell__title">
|
<div class="van-cell__title">
|
||||||
<span>
|
<span>
|
||||||
Switch Dark Mode
|
Please click the button in the upper right corner to switch between dark and light modes.
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div role="switch"
|
|
||||||
class="van-switch"
|
|
||||||
tabindex="0"
|
|
||||||
aria-checked="false"
|
|
||||||
>
|
|
||||||
<div class="van-switch__node">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<div class="van-config-provider">
|
|
||||||
<form class="van-form">
|
<form class="van-form">
|
||||||
<div class="van-cell van-field">
|
<div class="van-cell van-field">
|
||||||
<div class="van-cell__title van-field__label">
|
<div class="van-cell__title van-field__label">
|
||||||
@ -139,7 +130,6 @@ exports[`should render demo and match snapshot 1`] = `
|
|||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
<div>
|
<div>
|
||||||
<div class="van-config-provider"
|
<div class="van-config-provider"
|
||||||
style="--van-rate-icon-full-color: #07c160; --van-slider-bar-height: 4px; --van-slider-button-width: 20px; --van-slider-button-height: 20px; --van-slider-active-background: #07c160; --van-button-primary-background: #07c160; --van-button-primary-border-color: #07c160;"
|
style="--van-rate-icon-full-color: #07c160; --van-slider-bar-height: 4px; --van-slider-button-width: 20px; --van-slider-button-height: 20px; --van-slider-active-background: #07c160; --van-button-primary-background: #07c160; --van-button-primary-border-color: #07c160;"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user