-
Notifications
You must be signed in to change notification settings - Fork 462
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: rewrite to use app config and rework docs (#143)
Co-authored-by: Daniel Roe <daniel@roe.dev> Co-authored-by: Sébastien Chopin <seb@nuxt.com>
- Loading branch information
1 parent
56230ea
commit 6da0db0
Showing
144 changed files
with
10,342 additions
and
7,981 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
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 was deleted.
Oops, something went wrong.
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,95 +1,43 @@ | ||
<template> | ||
<div> | ||
<nav class="u-bg-white border-b u-border-gray-200 fixed top-0 inset-x-0 z-10"> | ||
<UContainer padded> | ||
<div class="flex items-center justify-between h-16"> | ||
<div class="flex items-center"> | ||
<NuxtLink to="/" class="block font-bold text-lg u-text-gray-900"> | ||
@nuxthq/ui | ||
</NuxtLink> | ||
</div> | ||
<Header /> | ||
|
||
<div class="flex items-center"> | ||
<ColorScheme placeholder="" tag="span"> | ||
<UButton variant="transparent" :icon="colorMode.value === 'dark' ? 'i-heroicons-moon' : 'i-heroicons-sun'" @click="toggleDark" /> | ||
</ColorScheme> | ||
<UButton to="https://github.com/nuxtlabs/ui" target="_blank" variant="transparent" icon="i-mdi-github" /> | ||
</div> | ||
</div> | ||
</UContainer> | ||
</nav> | ||
|
||
<UContainer class="mt-16"> | ||
<div class="lg:grid lg:grid-cols-10 lg:gap-10 lg:relative"> | ||
<aside class="lg:flex lg:flex-col pb-8 lg:pb-0 lg:sticky lg:top-0 px-4 sm:px-6 lg:px-0 lg:pt-16 lg:-mt-16 lg:self-start lg:col-span-2 lg:overflow-hidden lg:h-screen"> | ||
<nav class="overflow-y-auto h-auto pt-8 lg:py-12"> | ||
<ul class="space-y-6"> | ||
<li v-for="section of sections" :key="section"> | ||
<h5 class="mb-3 uppercase tracking-wide font-semibold text-xs u-text-gray-900"> | ||
{{ section.label }} | ||
</h5> | ||
<ul class="space-y-1.5"> | ||
<li v-for="(link, index) of section.links" :key="index"> | ||
<ULink | ||
:to="link.to" | ||
class="relative block text-sm rounded-md" | ||
active-class="text-primary-600" | ||
inactive-class="u-text-gray-500 hover:u-text-gray-700" | ||
exact | ||
> | ||
{{ link.label }} | ||
</ULink> | ||
</li> | ||
</ul> | ||
</li> | ||
</ul> | ||
</nav> | ||
</aside> | ||
|
||
<div class="space-y-6 sm:px-6 lg:px-0 lg:col-span-8 lg:py-12"> | ||
<NuxtPage /> | ||
</div> | ||
</div> | ||
<UContainer> | ||
<NuxtPage /> | ||
</UContainer> | ||
|
||
<ClientOnly> | ||
<UNotifications /> | ||
</ClientOnly> | ||
<DocsSearch /> | ||
|
||
<UNotifications /> | ||
</div> | ||
</template> | ||
|
||
<script setup> | ||
<script setup lang="ts"> | ||
const colorScheme = usePreferredColorScheme() | ||
const colorMode = useColorMode() | ||
// Computed | ||
const href = computed(() => colorScheme.value === 'dark' ? '/icon-dark.svg' : '/icon-light.svg') | ||
const color = computed(() => colorMode.value === 'dark' ? '#18181b' : 'white') | ||
// Head | ||
useHead({ | ||
title: '@nuxthq/ui', | ||
titleTemplate: title => title && title !== 'nuxthq/ui' ? `${title} - nuxthq/ui` : 'nuxthq/ui', | ||
meta: [ | ||
{ name: 'viewport', content: 'width=device-width, initial-scale=1, maximum-scale=1' } | ||
{ name: 'viewport', content: 'width=device-width, initial-scale=1, maximum-scale=1' }, | ||
{ key: 'theme-color', name: 'theme-color', content: color } | ||
], | ||
link: [ | ||
{ rel: 'stylesheet', href: 'https://rsms.me/inter/inter.css' } | ||
{ rel: 'stylesheet', href: 'https://rsms.me/inter/inter.css' }, | ||
{ rel: 'icon', type: 'image/svg+xml', href } | ||
], | ||
htmlAttrs: { | ||
lang: 'en' | ||
}, | ||
bodyAttrs: { | ||
class: 'antialiased font-sans text-gray-700 bg-gray-50 dark:bg-gray-900 dark:text-gray-200 bg-white dark:bg-black' | ||
class: 'antialiased font-sans text-gray-500 dark:text-gray-400 bg-white dark:bg-gray-900' | ||
} | ||
}) | ||
const colorMode = useColorMode() | ||
const toggleDark = () => { | ||
colorMode.preference = colorMode.value === 'dark' ? 'light' : 'dark' | ||
} | ||
const sections = [ | ||
{ 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: 'Feedback', links: [{ label: 'Alert', to: '/components/Alert' }, { label: 'AlertDialog', to: '/components/AlertDialog' }] }, | ||
{ label: 'Forms', links: [{ label: 'Checkbox', to: '/components/Checkbox' }, { label: 'Input', to: '/components/Input' }, { label: 'FormGroup', to: '/components/FormGroup' }, { label: 'Radio', to: '/components/Radio' }, { label: 'Select', to: '/components/Select' }, { label: 'SelectCustom', to: '/components/SelectCustom' }, { label: 'Textarea', to: '/components/Textarea' }, { label: 'Toggle', to: '/components/Toggle' }] }, | ||
{ label: 'Layout', links: [{ label: 'Card', to: '/components/Card' }, { label: 'Container', to: '/components/Container' }] }, | ||
{ label: 'Navigation', links: [{ label: 'Pills', to: '/components/Pills' }, { label: 'Tabs', to: '/components/Tabs' }, { label: 'VerticalNavigation', to: '/components/VerticalNavigation' }, { label: 'CommandPalette', to: '/components/CommandPalette' }] }, | ||
{ label: 'Overlays', links: [{ label: 'ContextMenu', to: '/components/ContextMenu' }, { label: 'Modal', to: '/components/Modal' }, { label: 'Notification', to: '/components/Notification' }, { label: 'Popover', to: '/components/Popover' }, { label: 'Slideover', to: '/components/Slideover' }, { label: 'Tooltip', to: '/components/Tooltip' }] } | ||
] | ||
</script> | ||
|
||
<style> | ||
html.dark { | ||
@apply bg-black; | ||
} | ||
</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,48 @@ | ||
import type { RouterConfig } from '@nuxt/schema' | ||
|
||
function findHashPosition (hash): { el: any, behavior: ScrollBehavior, top: number } { | ||
const el = document.querySelector(hash) | ||
// vue-router does not incorporate scroll-margin-top on its own. | ||
if (el) { | ||
const top = parseFloat(getComputedStyle(el).scrollMarginTop) | ||
|
||
return { | ||
el: hash, | ||
behavior: 'smooth', | ||
top | ||
} | ||
} | ||
} | ||
|
||
// https://router.vuejs.org/api/#routeroptions | ||
export default <RouterConfig>{ | ||
scrollBehavior (to, from, savedPosition) { | ||
const nuxtApp = useNuxtApp() | ||
|
||
// If history back | ||
if (savedPosition) { | ||
// Handle Suspense resolution | ||
return new Promise((resolve) => { | ||
nuxtApp.hooks.hookOnce('page:finish', () => { | ||
setTimeout(() => resolve(savedPosition), 50) | ||
}) | ||
}) | ||
} | ||
|
||
// Scroll to heading on click | ||
if (to.hash) { | ||
return new Promise((resolve) => { | ||
if (to.path === from.path) { | ||
setTimeout(() => resolve(findHashPosition(to.hash)), 50) | ||
} else { | ||
nuxtApp.hooks.hookOnce('page:finish', () => { | ||
setTimeout(() => resolve(findHashPosition(to.hash)), 50) | ||
}) | ||
} | ||
}) | ||
} | ||
|
||
// Scroll to top of window | ||
return { top: 0 } | ||
} | ||
} |
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,112 @@ | ||
<template> | ||
<header class="sticky top-0 z-50 w-full backdrop-blur flex-none border-b border-gray-900/10 dark:border-gray-50/[0.06] bg-white/75 dark:bg-gray-900/75"> | ||
<UContainer> | ||
<div class="flex items-center justify-between h-16"> | ||
<div class="flex items-center gap-3"> | ||
<NuxtLink to="/" class="flex items-end gap-2 font-bold text-xl text-gray-900 dark:text-white"> | ||
<Logo class="w-8 h-8 text-primary-500 dark:text-primary-400" /> | ||
|
||
nuxthq/ui | ||
</NuxtLink> | ||
</div> | ||
|
||
<div class="flex items-center -mr-1.5"> | ||
<div class="mr-1.5 hidden lg:block"> | ||
<ThemeSelect /> | ||
</div> | ||
|
||
<UButton | ||
color="gray" | ||
variant="ghost" | ||
class="lg:hidden" | ||
icon="i-heroicons-magnifying-glass-20-solid" | ||
@click="openDocsSearch" | ||
/> | ||
|
||
<ClientOnly> | ||
<UButton | ||
:icon="isDark ? 'i-heroicons-moon' : 'i-heroicons-sun'" | ||
color="gray" | ||
variant="ghost" | ||
aria-label="Theme" | ||
@click="isDark = !isDark" | ||
/> | ||
</ClientOnly> | ||
<UButton | ||
to="https://github.com/nuxtlabs/ui" | ||
target="_blank" | ||
color="gray" | ||
variant="ghost" | ||
icon="i-simple-icons-github" | ||
/> | ||
|
||
<UButton | ||
color="gray" | ||
variant="ghost" | ||
class="lg:hidden" | ||
icon="i-heroicons-bars-3-20-solid" | ||
@click="isDialogOpen = true" | ||
/> | ||
</div> | ||
</div> | ||
</UContainer> | ||
|
||
<TransitionRoot :show="isDialogOpen" as="template"> | ||
<Dialog as="div" @close="isDialogOpen = false"> | ||
<DialogPanel class="fixed inset-0 z-50 overflow-y-auto bg-white dark:bg-gray-900 lg:hidden"> | ||
<div class="px-4 sm:px-6 sticky top-0 border-b border-gray-900/10 dark:border-gray-50/[0.06] bg-white/75 dark:bg-gray-900/75 backdrop-blur z-10"> | ||
<div class="flex items-center justify-between h-16"> | ||
<div class="flex items-center gap-3"> | ||
<NuxtLink to="/" class="flex items-end gap-2 font-bold text-xl text-gray-900 dark:text-white"> | ||
<Logo class="w-8 h-8 text-primary-500 dark:text-primary-400" /> | ||
|
||
nuxthq/ui | ||
</NuxtLink> | ||
</div> | ||
|
||
<div class="flex -mr-1.5"> | ||
<UButton | ||
color="gray" | ||
variant="ghost" | ||
icon="i-heroicons-x-mark-20-solid" | ||
@click="isDialogOpen = false" | ||
/> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="px-4 sm:px-6 py-4 sm:py-6"> | ||
<ThemeSelect class="mb-4 sm:mb-6 w-full" /> | ||
|
||
<DocsAsideLinks @click="isDialogOpen = false" /> | ||
</div> | ||
</DialogPanel> | ||
</Dialog> | ||
</TransitionRoot> | ||
</header> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { Dialog, DialogPanel, TransitionRoot } from '@headlessui/vue' | ||
const { isSearchModalOpen } = useDocs() | ||
const colorMode = useColorMode() | ||
const isDialogOpen = ref(false) | ||
const isDark = computed({ | ||
get () { | ||
return colorMode.value === 'dark' | ||
}, | ||
set () { | ||
colorMode.preference = colorMode.value === 'dark' ? 'light' : 'dark' | ||
} | ||
}) | ||
function openDocsSearch () { | ||
isDialogOpen.value = false | ||
setTimeout(() => { | ||
isSearchModalOpen.value = true | ||
}, 100) | ||
} | ||
</script> |
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> | ||
<svg width="900" height="900" viewBox="0 0 900 900" fill="none" xmlns="http://www.w3.org/2000/svg"> | ||
<path d="M504.908 750H839.476C850.103 750.001 860.542 747.229 869.745 741.963C878.948 736.696 886.589 729.121 891.9 719.999C897.211 710.876 900.005 700.529 900 689.997C899.995 679.465 897.193 669.12 891.873 660.002L667.187 274.289C661.876 265.169 654.237 257.595 645.036 252.329C635.835 247.064 625.398 244.291 614.773 244.291C604.149 244.291 593.711 247.064 584.511 252.329C575.31 257.595 567.67 265.169 562.36 274.289L504.908 372.979L392.581 179.993C387.266 170.874 379.623 163.301 370.42 158.036C361.216 152.772 350.777 150 340.151 150C329.525 150 319.086 152.772 309.883 158.036C300.679 163.301 293.036 170.874 287.721 179.993L8.12649 660.002C2.80743 669.12 0.00462935 679.465 5.72978e-06 689.997C-0.00461789 700.529 2.78909 710.876 8.10015 719.999C13.4112 729.121 21.0523 736.696 30.255 741.963C39.4576 747.229 49.8973 750.001 60.524 750H270.538C353.748 750 415.112 713.775 457.336 643.101L559.849 467.145L614.757 372.979L779.547 655.834H559.849L504.908 750ZM267.114 655.737L120.551 655.704L340.249 278.586L449.87 467.145L376.474 593.175C348.433 639.03 316.577 655.737 267.114 655.737Z" fill="currentColor" /> | ||
</svg> | ||
</template> |
Oops, something went wrong.