Skip to content

Commit

Permalink
feat: use nuxt-icon
Browse files Browse the repository at this point in the history
  • Loading branch information
benjamincanac committed Feb 16, 2023
1 parent 6018f00 commit f5d068b
Show file tree
Hide file tree
Showing 19 changed files with 562 additions and 559 deletions.
2 changes: 1 addition & 1 deletion docs/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ const toggleDark = () => {
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: '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: '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' }] },
Expand Down
4 changes: 2 additions & 2 deletions docs/pages/examples.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<UModal v-model="isModalOpen" @submit.prevent="onSubmit">
<div class="sm:flex sm:items-start">
<div class="mx-auto flex-shrink-0 flex items-center justify-center h-12 w-12 rounded-full bg-red-100 sm:mx-0 sm:h-10 sm:w-10">
<UIcon name="heroicons-outline:exclamation" class="h-6 w-6 text-red-600" aria-hidden="true" />
<IconCSS name="heroicons-outline:exclamation" class="h-6 w-6 text-red-600" aria-hidden="true" />
</div>
<div class="mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left">
<h3 class="text-lg leading-6 font-medium u-text-gray-900">
Expand Down Expand Up @@ -117,7 +117,7 @@
</div>

<UTooltip text="Hello tooltip!" :shortcuts="['', 'G']">
<UIcon name="heroicons-outline:information-circle" class="w-6 h-6 u-text-gray-900 cursor-pointer" />
<IconCSS name="heroicons-outline:information-circle" class="w-6 h-6 u-text-gray-900 cursor-pointer" />
</UTooltip>
</div>

Expand Down
7 changes: 0 additions & 7 deletions docs/pages/migration.vue
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,6 @@ const components = [
preset: true,
typescript: true
},
{
label: 'Icon',
to: '/components/Icon',
nuxt3: true,
capi: true,
typescript: true
},
{
label: 'Link',
to: '/components/Link',
Expand Down
17 changes: 9 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@
"release": "yarn lint && standard-version && git push --follow-tags"
},
"dependencies": {
"@headlessui/vue": "1.7.9",
"@headlessui/vue": "^1.7.10",
"@iconify/vue": "^4.1.0",
"@nuxt/kit": "^3.1.2",
"@nuxt/kit": "^3.2.0",
"@nuxtjs/color-mode": "^3.2.0",
"@nuxtjs/tailwindcss": "^6.3.1",
"@nuxtjs/tailwindcss": "^6.4.0",
"@popperjs/core": "^2.11.6",
"@tailwindcss/aspect-ratio": "^0.4.2",
"@tailwindcss/forms": "^0.5.3",
Expand All @@ -40,18 +40,19 @@
"defu": "^6.1.2",
"fuse.js": "^6.6.2",
"lodash-es": "^4.17.21",
"tailwindcss": "^3.2.4"
"nuxt-icon": "^0.3.1",
"tailwindcss": "^3.2.6"
},
"devDependencies": {
"@nuxt/module-builder": "^0.2.1",
"@nuxtjs/eslint-config-typescript": "^12.0.0",
"@types/lodash-es": "^4.17.6",
"@types/node": "^18.11.18",
"eslint": "^8.33.0",
"nuxt": "^3.1.2",
"@types/node": "^18.13.0",
"eslint": "^8.34.0",
"nuxt": "^3.2.0",
"standard-version": "^9.5.0",
"unbuild": "^1.1.1",
"vue-tsc": "^1.0.24"
"vue-tsc": "^1.1.0"
},
"build": {
"externals": [
Expand Down
3 changes: 3 additions & 0 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ export default defineNuxtModule<ModuleOptions>({
})
})

nuxt.options.appConfig.nuxtIcon = defu(nuxt.options.appConfig.nuxtIcon, { size: false })

await installModule('nuxt-icon')
await installModule('@nuxtjs/color-mode', { classSuffix: '' })
await installModule('@nuxtjs/tailwindcss', {
viewer: false,
Expand Down
5 changes: 2 additions & 3 deletions src/runtime/components/elements/Button.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
:aria-label="ariaLabel"
v-bind="buttonProps"
>
<Icon v-if="isLeading && leadingIconName" :name="leadingIconName" :class="leadingIconClass" aria-hidden="true" />
<IconCSS v-if="isLeading && leadingIconName" :name="leadingIconName" :class="leadingIconClass" aria-hidden="true" />
<slot>
<span :class="[truncate ? 'text-left break-all line-clamp-1' : '', compact ? 'hidden sm:block' : '']">
<span :class="[labelCompact && 'hidden sm:block']">{{ label }}</span>
<span v-if="labelCompact" class="sm:hidden">{{ labelCompact }}</span>
</span>
</slot>
<Icon v-if="isTrailing && trailingIconName" :name="trailingIconName" :class="trailingIconClass" aria-hidden="true" />
<IconCSS v-if="isTrailing && trailingIconName" :name="trailingIconName" :class="trailingIconClass" aria-hidden="true" />
</component>
</template>

Expand All @@ -22,7 +22,6 @@ import { ref, computed, useSlots } from 'vue'
import type { PropType } from 'vue'
import type { RouteLocationNormalized, RouteLocationRaw } from 'vue-router'
import NuxtLink from '#app/components/nuxt-link'
import Icon from '../elements/Icon.vue'
import { classNames } from '../../utils'
import $ui from '#build/ui'
Expand Down
3 changes: 1 addition & 2 deletions src/runtime/components/elements/Dropdown.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
@click="item.click"
>
<slot :name="item.slot" :item="item">
<Icon v-if="item.icon" :name="item.icon" :class="[itemIconClass, item.iconClass]" />
<IconCSS v-if="item.icon" :name="item.icon" :class="[itemIconClass, item.iconClass]" />
<Avatar v-if="item.avatar" v-bind="{ size: 'xxs', ...item.avatar }" :class="itemAvatarClass" />

<span class="truncate">{{ item.label }}</span>
Expand Down Expand Up @@ -57,7 +57,6 @@ import type { RouteLocationNormalized } from 'vue-router'
import { ref, computed, onMounted } from 'vue'
import { defu } from 'defu'
import NuxtLink from '#app/components/nuxt-link'
import Icon from '../elements/Icon.vue'
import Avatar from '../elements/Avatar.vue'
import { classNames, omit } from '../../utils'
import { usePopper } from '../../composables/usePopper'
Expand Down
56 changes: 0 additions & 56 deletions src/runtime/components/elements/Icon.vue

This file was deleted.

3 changes: 1 addition & 2 deletions src/runtime/components/feedback/Alert.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="rounded-md p-4" :class="variantClass">
<div class="flex">
<div class="flex-shrink-0">
<Icon v-if="iconName" :name="iconName" :class="iconClass" class="h-5 w-5" />
<IconCSS v-if="iconName" :name="iconName" :class="iconClass" class="h-5 w-5" />
</div>
<div class="ml-3 flex-1 md:flex md:justify-between">
<p v-if="title" class="text-sm leading-5" :class="titleClass">
Expand All @@ -27,7 +27,6 @@
import { computed } from 'vue'
import type { PropType } from 'vue'
import type { RouteLocationNormalized } from 'vue-router'
import Icon from '../elements/Icon.vue'
const props = defineProps({
variant: {
Expand Down
3 changes: 1 addition & 2 deletions src/runtime/components/feedback/AlertDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Modal v-model="isOpen" :appear="appear" class="w-full" @close="onClose">
<div class="sm:flex sm:items-start">
<div v-if="icon" :class="iconWrapperClass" class="mx-auto flex-shrink-0 flex items-center justify-center rounded-full sm:mx-0">
<Icon :name="icon" :class="iconClass" />
<IconCSS :name="icon" :class="iconClass" />
</div>
<div class="mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left space-y-2">
<DialogTitle v-if="title" as="h3" :class="titleClass">
Expand All @@ -25,7 +25,6 @@ import { computed } from 'vue'
import { DialogTitle, DialogDescription } from '@headlessui/vue'
import Modal from '../overlays/Modal.vue'
import Button from '../elements/Button.vue'
import Icon from '../elements/Icon.vue'
import $ui from '#build/ui'
const props = defineProps({
Expand Down
5 changes: 2 additions & 3 deletions src/runtime/components/forms/Input.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,16 @@
>
<slot />
<div v-if="isLeading" :class="iconLeadingWrapperClass">
<Icon v-if="iconName" :name="iconName" :class="iconClass" />
<IconCSS v-if="iconName" :name="iconName" :class="iconClass" />
</div>
<div v-if="isTrailing" :class="iconTrailingWrapperClass">
<Icon v-if="iconName" :name="iconName" :class="iconClass" />
<IconCSS v-if="iconName" :name="iconName" :class="iconClass" />
</div>
</div>
</template>

<script setup lang="ts">
import { ref, computed, onMounted } from 'vue'
import Icon from '../elements/Icon.vue'
import { classNames } from '../../utils'
import $ui from '#build/ui'
Expand Down
3 changes: 1 addition & 2 deletions src/runtime/components/forms/Select.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,14 @@
</select>

<div v-if="icon" :class="iconWrapperClass">
<Icon :name="icon" :class="iconClass" />
<IconCSS :name="icon" :class="iconClass" />
</div>
</div>
</template>

<script setup lang="ts">
import { computed } from 'vue'
import { get } from 'lodash-es'
import Icon from '../elements/Icon.vue'
import { classNames } from '../../utils'
import $ui from '#build/ui'
Expand Down
5 changes: 2 additions & 3 deletions src/runtime/components/forms/SelectCustom.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
</slot>
<slot name="icon">
<span :class="iconWrapperClass">
<Icon v-if="icon" :name="icon" :class="iconClass" aria-hidden="true" />
<IconCSS v-if="icon" :name="icon" :class="iconClass" aria-hidden="true" />
</span>
</slot>
</button>
Expand Down Expand Up @@ -58,7 +58,7 @@
</div>

<span v-if="selected" :class="resolveOptionIconClass({ active })">
<Icon v-if="listOptionIcon" :name="listOptionIcon" :class="listOptionIconSizeClass" aria-hidden="true" />
<IconCSS v-if="listOptionIcon" :name="listOptionIcon" :class="listOptionIconSizeClass" aria-hidden="true" />
</span>
</li>
</ComboboxOption>
Expand Down Expand Up @@ -94,7 +94,6 @@ import {
ComboboxOption,
ComboboxInput
} from '@headlessui/vue'
import Icon from '../elements/Icon.vue'
import { classNames } from '../../utils'
import { usePopper } from '../../composables/usePopper'
import type { PopperOptions } from '../../types'
Expand Down
5 changes: 2 additions & 3 deletions src/runtime/components/forms/Toggle.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
>
<span :class="[active ? containerActiveClass : containerInactiveClass, containerBaseClass]">
<span v-if="iconOn" :class="[active ? iconActiveClass : iconInactiveClass, iconBaseClass]" aria-hidden="true">
<Icon :name="iconOn" :class="iconOnClass" />
<IconCSS :name="iconOn" :class="iconOnClass" />
</span>
<span v-if="iconOff" :class="[active ? iconInactiveClass : iconActiveClass, iconBaseClass]" aria-hidden="true">
<Icon :name="iconOff" :class="iconOffClass" />
<IconCSS :name="iconOff" :class="iconOffClass" />
</span>
</span>
</Switch>
Expand All @@ -17,7 +17,6 @@
<script setup lang="ts">
import { computed } from 'vue'
import { Switch } from '@headlessui/vue'
import Icon from '../elements/Icon.vue'
import $ui from '#build/ui'
const props = defineProps({
Expand Down
5 changes: 2 additions & 3 deletions src/runtime/components/navigation/CommandPalette.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
>
<div :class="$ui.commandPalette.wrapper">
<div v-show="searchable" class="relative flex items-center">
<Icon v-if="inputIcon" :name="inputIcon" :class="$ui.commandPalette.input.icon.base" aria-hidden="true" />
<IconCSS v-if="inputIcon" :name="inputIcon" :class="$ui.commandPalette.input.icon.base" aria-hidden="true" />
<ComboboxInput
ref="comboboxInput"
:value="query"
Expand Down Expand Up @@ -46,7 +46,7 @@
</ComboboxOptions>

<div v-else-if="placeholder" class="flex flex-col items-center justify-center flex-1 px-6 py-14 sm:px-14">
<Icon v-if="emptyIcon" :name="emptyIcon" class="w-6 h-6 mx-auto u-text-gray-400 mb-4" aria-hidden="true" />
<IconCSS v-if="emptyIcon" :name="emptyIcon" class="w-6 h-6 mx-auto u-text-gray-400 mb-4" aria-hidden="true" />
<p class="text-sm text-center u-text-gray-900">
{{ query ? "We couldn't find any items with that term. Please try again." : "We couldn't find any items." }}
</p>
Expand All @@ -64,7 +64,6 @@ import { groupBy, map } from 'lodash-es'
import { defu } from 'defu'
import type { UseFuseOptions } from '@vueuse/integrations/useFuse'
import type { Group, Command } from '../../types/command-palette'
import Icon from '../elements/Icon.vue'
import Button from '../elements/Button.vue'
import CommandPaletteGroup from './CommandPaletteGroup.vue'
import $ui from '#build/ui'
Expand Down
5 changes: 2 additions & 3 deletions src/runtime/components/navigation/CommandPaletteGroup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
>
<div :class="['flex justify-between select-none items-center rounded-md px-3 py-2 gap-3 relative', active && 'bg-gray-100 dark:bg-gray-800 u-text-gray-900', command.disabled ? 'cursor-not-allowed' : 'cursor-pointer']">
<div class="flex items-center gap-2 min-w-0">
<Icon v-if="command.icon" :name="command.icon" :class="['h-4 w-4 flex-shrink-0', active ? 'text-opacity-100 dark:text-opacity-100' : 'text-opacity-40 dark:text-opacity-40', command.iconClass || 'text-gray-900 dark:text-gray-50']" aria-hidden="true" />
<IconCSS v-if="command.icon" :name="command.icon" :class="['h-4 w-4 flex-shrink-0', active ? 'text-opacity-100 dark:text-opacity-100' : 'text-opacity-40 dark:text-opacity-40', command.iconClass || 'text-gray-900 dark:text-gray-50']" aria-hidden="true" />
<Avatar
v-else-if="command.avatar"
v-bind="{ size: 'xxxs', ...command.avatar }"
Expand All @@ -35,7 +35,7 @@
</div>
</div>
<Icon v-if="selected" name="heroicons-outline:check" class="h-5 w-5 u-text-gray-900 flex-shrink-0" aria-hidden="true" />
<IconCSS v-if="selected" name="heroicons-outline:check" class="h-5 w-5 u-text-gray-900 flex-shrink-0" aria-hidden="true" />
<slot v-else-if="active && (group.active || $slots[`${group.key}-active`])" :name="`${group.key}-active`" :group="group" :command="command">
<span v-if="group.active" class="flex-shrink-0 u-text-gray-500">{{ group.active }}</span>
</slot>
Expand All @@ -54,7 +54,6 @@
<script setup lang="ts">
import { ComboboxOption } from '@headlessui/vue'
import type { PropType } from 'vue'
import Icon from '../elements/Icon.vue'
import Avatar from '../elements/Avatar.vue'
import type { Group } from '../../types/command-palette'
Expand Down
3 changes: 1 addition & 2 deletions src/runtime/components/navigation/VerticalNavigation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
/>
</slot>
<slot name="icon" :link="link" :is-active="isActive">
<Icon
<IconCSS
v-if="link.icon"
:name="link.icon"
:class="[iconBaseClass, link.label && iconSpacingClass, isActive ? iconActiveClass : iconInactiveClass, link.iconClass]"
Expand All @@ -40,7 +40,6 @@
<script setup lang="ts">
import type { PropType } from 'vue'
import type { RouteLocationNormalized } from 'vue-router'
import Icon from '../elements/Icon.vue'
import Link from '../elements/Link.vue'
import Avatar from '../elements/Avatar.vue'
import type { Avatar as AvatarType } from '../../types/avatar'
Expand Down
Loading

1 comment on commit f5d068b

@vercel
Copy link

@vercel vercel bot commented on f5d068b Feb 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

ui – ./

ui-git-dev-nuxtlabs.vercel.app
ui-nuxtlabs.vercel.app
nuxthq-ui.vercel.app

Please sign in to comment.