Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: rewrite to use app config and rework docs #143

Merged
merged 60 commits into from
May 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
2b713f1
up
benjamincanac Apr 9, 2023
8c8a173
up
benjamincanac Apr 9, 2023
c695e58
up
benjamincanac Apr 9, 2023
d94056c
up
benjamincanac Apr 10, 2023
b87cb8c
up
benjamincanac Apr 10, 2023
db3d3af
up
benjamincanac Apr 10, 2023
937768e
up
benjamincanac Apr 11, 2023
a6b5b7c
up
benjamincanac Apr 11, 2023
a054701
up
benjamincanac Apr 11, 2023
417012a
up
benjamincanac Apr 11, 2023
fa8e24c
up
benjamincanac Apr 11, 2023
b954143
fix: avoid importing directly from `#build/app.config` (#146)
danielroe Apr 15, 2023
50c372a
up
benjamincanac Apr 15, 2023
bbc57ce
up
benjamincanac Apr 15, 2023
7aca7ea
up
benjamincanac Apr 15, 2023
207b558
up
benjamincanac Apr 15, 2023
e219122
up
benjamincanac Apr 16, 2023
a4cf706
up
benjamincanac Apr 17, 2023
717a661
up
benjamincanac Apr 17, 2023
8e2391b
up
benjamincanac Apr 18, 2023
d5c446a
up
benjamincanac Apr 18, 2023
d1f3591
up
benjamincanac Apr 18, 2023
7c0cfc9
up
benjamincanac Apr 18, 2023
731fb4d
up
benjamincanac Apr 19, 2023
0dceff6
up
benjamincanac Apr 19, 2023
89063bf
up
benjamincanac Apr 19, 2023
511befc
up
benjamincanac Apr 19, 2023
f253b1b
up
benjamincanac Apr 19, 2023
0af2f5a
up
benjamincanac Apr 19, 2023
dcea72b
up
benjamincanac Apr 20, 2023
a880e6c
up
benjamincanac Apr 20, 2023
6634024
up
benjamincanac Apr 21, 2023
48e2296
up
benjamincanac Apr 26, 2023
d3af06d
up
benjamincanac Apr 26, 2023
971a279
up
benjamincanac Apr 27, 2023
2c7294d
up
benjamincanac May 2, 2023
efd5c6d
up
benjamincanac May 2, 2023
f1d62a3
up
benjamincanac May 2, 2023
a984327
up
benjamincanac May 2, 2023
0948971
up
benjamincanac May 2, 2023
ca30852
up
benjamincanac May 2, 2023
689f410
up
benjamincanac May 2, 2023
18d0eb3
up
benjamincanac May 2, 2023
a4841a2
up
benjamincanac May 2, 2023
96649cc
up
benjamincanac May 2, 2023
8e1dea1
up
benjamincanac May 3, 2023
9e7a25f
up
benjamincanac May 3, 2023
3cf2d98
up
benjamincanac May 3, 2023
9bdaf72
up
benjamincanac May 3, 2023
e5d1f5a
up
benjamincanac May 3, 2023
d73187f
up
benjamincanac May 3, 2023
503292d
Merge branch 'dev' into docs/rework
benjamincanac May 4, 2023
1e0c9d3
up
benjamincanac May 4, 2023
cbf3670
chore: add node engines
Atinux May 4, 2023
d805cb2
docs: add routeRules for production
Atinux May 4, 2023
5d581ed
docs: test payloadExtraction
Atinux May 4, 2023
21fa40d
up
benjamincanac May 4, 2023
4e3882a
docs: perf improvements
Atinux May 4, 2023
c91c280
up
benjamincanac May 4, 2023
044b38e
up
benjamincanac May 4, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/ci-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest] # macos-latest, windows-latest
node: [16]
node: [18]

steps:
- uses: actions/setup-node@v2
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}

Expand All @@ -29,7 +29,7 @@ jobs:
fetch-depth: 0

- name: Cache
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: node_modules
key: ${{ matrix.os }}-node-v${{ matrix.node }}-deps-${{ hashFiles(format('{0}{1}', github.workspace, '/yarn.lock')) }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest] # macos-latest, windows-latest
node: [16]
node: [18]

steps:
- uses: actions/setup-node@v2
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}

Expand All @@ -29,7 +29,7 @@ jobs:
fetch-depth: 0

- name: Cache
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: node_modules
key: ${{ matrix.os }}-node-v${{ matrix.node }}-deps-${{ hashFiles(format('{0}{1}', github.workspace, '/yarn.lock')) }}
Expand Down
42 changes: 1 addition & 41 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# @nuxthq/ui

Components library as a Nuxt module using [TailwindCSS](https://tailwindcss.com).
Components library as a Nuxt module using [TailwindCSS](https://tailwindcss.com) and [HeadlessUI](https://headlessui.com).

## Installation

Expand Down Expand Up @@ -29,43 +29,3 @@ If you want latest updates, please use `@nuxthq/ui-edge` in your `package.json`:
}
}
```

## Options

- `primary`

Define the primary variant. Defaults to `indigo`. You can specify your own object of colors like here:

**Example:**

```js
import { defineNuxtConfig } from 'nuxt'

export default defineNuxtConfig({
buildModules: [
'@nuxthq/ui'
],
ui: {
primary: 'blue'
}
})
```

- `prefix`

Define the prefix of the imported components. Defaults to `u`.

**Example:**

```js
import { defineNuxtConfig } from 'nuxt'

export default defineNuxtConfig({
buildModules: [
'@nuxthq/ui'
],
ui: {
prefix: 'tw'
}
})
```
12 changes: 0 additions & 12 deletions build.config.ts

This file was deleted.

104 changes: 26 additions & 78 deletions docs/app.vue
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>
48 changes: 48 additions & 0 deletions docs/app/router.options.ts
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 }
}
}
112 changes: 112 additions & 0 deletions docs/components/Header.vue
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>
5 changes: 5 additions & 0 deletions docs/components/Logo.vue
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>