docs: update

This commit is contained in:
Benjamin Canac
2022-02-18 11:58:52 +01:00
parent f1a830f7a6
commit fc50834448
4 changed files with 18 additions and 34 deletions

View File

@@ -11,10 +11,7 @@
<div class="flex items-center gap-3"> <div class="flex items-center gap-3">
<UButton to="https://github.com/nuxtlabs/ui" target="_blank" variant="transparent" icon="fa-brands:github" /> <UButton to="https://github.com/nuxtlabs/ui" target="_blank" variant="transparent" icon="fa-brands:github" />
<UButton variant="transparent" :icon="colorMode.value === 'dark' ? 'heroicons-outline:moon' : 'heroicons-outline:sun'" @click="toggleDark" />
<UseDark v-slot="{ isDark, toggleDark }">
<UButton variant="transparent" :icon="isDark ? 'heroicons-outline:moon' : 'heroicons-outline:sun'" @click="toggleDark()" />
</UseDark>
</div> </div>
</div> </div>
</UContainer> </UContainer>
@@ -60,17 +57,17 @@
</template> </template>
<script setup> <script setup>
import { UseDark } from '@vueuse/components'
useMeta({ useMeta({
htmlAttrs: {
class: 'bg-white dark:bg-black'
},
bodyAttrs: { bodyAttrs: {
class: 'antialiased font-sans text-gray-700 bg-gray-50 dark:bg-gray-900 dark:text-gray-200' class: 'antialiased font-sans text-gray-700 bg-gray-50 dark:bg-gray-900 dark:text-gray-200'
} }
}) })
const colorMode = useColorMode()
const toggleDark = () => {
colorMode.preference = colorMode.value === 'dark' ? 'light' : 'dark'
}
const sections = [ const sections = [
{ label: 'Getting Started', links: [{ label: 'Usage', to: '/' }, { label: 'Examples', to: '/examples' }, { label: 'Migration', to: '/migration' }, { label: 'Dark mode', to: '/dark' }] }, { label: 'Getting Started', links: [{ label: 'Usage', to: '/' }, { label: 'Examples', to: '/examples' }, { label: 'Migration', to: '/migration' }, { label: 'Dark mode', to: '/dark' }] },
{ label: 'Elements', links: [{ label: 'Avatar', to: '/components/Avatar' }, { label: 'AvatarGroup', to: '/components/AvatarGroup' }, { label: 'Badge', to: '/components/Badge' }, { label: 'Button', to: '/components/Button' }, { label: 'Dropdown', to: '/components/Dropdown' }, { label: 'Icon', to: '/components/Icon' }] }, { label: 'Elements', links: [{ label: 'Avatar', to: '/components/Avatar' }, { label: 'AvatarGroup', to: '/components/AvatarGroup' }, { label: 'Badge', to: '/components/Badge' }, { label: 'Button', to: '/components/Button' }, { label: 'Dropdown', to: '/components/Dropdown' }, { label: 'Icon', to: '/components/Icon' }] },

View File

@@ -12,7 +12,10 @@ export default defineNuxtConfig({
], ],
link: [ link: [
{ rel: 'stylesheet', href: 'https://rsms.me/inter/inter.css' } { rel: 'stylesheet', href: 'https://rsms.me/inter/inter.css' }
] ],
htmlAttrs: {
class: 'bg-white dark:bg-black'
}
}, },
buildModules: [ buildModules: [
module module

View File

@@ -72,7 +72,7 @@
</UFormGroup> </UFormGroup>
</div> </div>
<div class="border-t u-border-gray-200 u-bg-gray-50"> <div class="border-t u-border-gray-200">
<pre class="text-sm leading-6 u-text-gray-900 flex-1 relative flex ligatures-none lg:overflow-y-auto overflow-x-hidden px-4 sm:px-6 py-5 sm:py-6"> <pre class="text-sm leading-6 u-text-gray-900 flex-1 relative flex ligatures-none lg:overflow-y-auto overflow-x-hidden px-4 sm:px-6 py-5 sm:py-6">
<code class="flex-none min-w-full whitespace-pre-wrap break-all">{{ code }}</code> <code class="flex-none min-w-full whitespace-pre-wrap break-all">{{ code }}</code>

View File

@@ -8,7 +8,7 @@
</div> </div>
<p class="mt-1 text-lg u-text-gray-500"> <p class="mt-1 text-lg u-text-gray-500">
Dark mode implementation with <a href="https://vueuse.org" target="_blank" class="underline">VueUse</a>. Dark mode implementation with <a href="https://color-mode.nuxtjs.org/" target="_blank" class="underline">Color Mode</a> module.
</p> </p>
</div> </div>
@@ -16,13 +16,7 @@
Usage Usage
</h2> </h2>
<pre class="u-bg-gray-900 rounded-md u-text-white px-4"> <p>TailwindCSS takes advantage of the `dark` class on the html tag:</p>
<code class="text-sm">
{{ code5 }}
</code>
</pre>
<p>The VueUse <a href="https://vueuse.org/core/useDark" target="_blank" class="underline">useDark</a> composable makes use of the `dark` class on the html tag so you can easily take advantage of the UnoCSS `dark` variant.</p>
<pre class="u-bg-gray-900 rounded-md u-text-white px-4"> <pre class="u-bg-gray-900 rounded-md u-text-white px-4">
<code class="text-sm"> <code class="text-sm">
@@ -30,13 +24,8 @@
</code> </code>
</pre> </pre>
<p>You can implement a toggle button easily by doing:</p> <p>The `@nuxtjs/color-mode` module is now installed by default, you can easily implement a toggle button:</p>
<pre class="u-bg-gray-900 rounded-md u-text-white px-4">
<code class="text-sm">
{{ code2 }}
</code>
</pre>
<pre class="u-bg-gray-900 rounded-md u-text-white px-4"> <pre class="u-bg-gray-900 rounded-md u-text-white px-4">
<code class="text-sm"> <code class="text-sm">
{{ code1 }} {{ code1 }}
@@ -63,19 +52,14 @@
<script setup> <script setup>
const code1 = ` const code1 = `
<UseDark v-slot="{ isDark, toggleDark }"> const colorMode = useColorMode()
<UButton variant="transparent" :icon="isDark ? 'heroicons-outline:moon' : 'heroicons-outline:sun'" @click="toggleDark()" /> const toggleDark = () => {
</UseDark>` colorMode.preference = colorMode.value === 'dark' ? 'light' : 'dark'
const code2 = ` }`
import { UseDark } from '@vueuse/components'
`
const code3 = ` const code3 = `
<div class="u-bg-gray-100 border u-border-gray-200 u-text-gray-700"></div> <div class="u-bg-gray-100 border u-border-gray-200 u-text-gray-700"></div>
` `
const code4 = ` const code4 = `
<div class="bg-white dark:bg-black"></div> <div class="bg-white dark:bg-black"></div>
` `
const code5 = `
yarn add @vueuse/components @vueuse/core
`
</script> </script>