Skip to content
This repository has been archived by the owner on Dec 10, 2024. It is now read-only.

Commit

Permalink
feat(nuxt): add neoconfetti package and configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
productdevbook committed Jan 17, 2024
1 parent 4b46216 commit 60df021
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 4 deletions.
1 change: 1 addition & 0 deletions packages/box/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"@faker-js/faker": "^8.3.1",
"@iconify-json/carbon": "^1.1.27",
"@iconify-json/ph": "^1.1.9",
"@neoconfetti/vue": "^2.2.1",
"@nuxtjs/color-mode": "^3.3.2",
"@nuxtjs/i18n": "^8.0.0",
"@nuxtjs/tailwindcss": "^6.10.3",
Expand Down
2 changes: 2 additions & 0 deletions packages/nuxt/playground/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ const isDark = computed({
</script>

<template>
<div v-confetti="{ particleCount: 200, force: 0.3 }" />

<Body class="h-full" />
<Html class="h-full" />
<Notivue
Expand Down
5 changes: 5 additions & 0 deletions packages/nuxt/playground/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ export default defineNuxtConfig({
},
lucia: true,
drizzle: true,
box: {
packages: {
neoconfetti: true,
},
},
},
test2: {
S3: true,
Expand Down
4 changes: 2 additions & 2 deletions packages/nuxt/playground/pergel/README.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"pergel": {
"comment-block-1": "This file is generated by pergel. Do not edit it manually.",
"comment-block-2": "Version: 0.6.1"
"comment-block-2": "Version: 0.7.1"
},
"test": {
"ui": {
"box": {
"comment-block": "If pergel cli is installed, you can run `pergel install` automatically to install",
"themes": {
"authDefault": "pergel download -t=templates -j=official-auth-1 -p=test"
Expand Down
6 changes: 5 additions & 1 deletion packages/nuxt/src/runtime/modules/box/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { join } from 'node:path'
import { addComponent, addImports, createResolver, installModule } from '@nuxt/kit'
import { addComponent, addImports, addPlugin, createResolver, installModule } from '@nuxt/kit'
import { isPackageExists } from 'local-pkg'

import type { IconsPluginOptions } from '@egoist/tailwindcss-icons'
Expand Down Expand Up @@ -38,6 +38,7 @@ export default definePergelModule<BoxOptions, ResolvedBoxOptions>({
i18n: false,
pinia: false,
vueUse: false,
neoconfetti: false,
},
},
async setup({ nuxt, options }) {
Expand Down Expand Up @@ -309,6 +310,9 @@ export default definePergelModule<BoxOptions, ResolvedBoxOptions>({
if (options.packages.vueUse)
await installModule('@vueuse/nuxt')

if (options.packages.neoconfetti)
addPlugin(resolver.resolve('plugins/neoconfetti.ts'))

addDownloadTemplate({
nuxt,
data: {
Expand Down
7 changes: 7 additions & 0 deletions packages/nuxt/src/runtime/modules/box/plugins/neoconfetti.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { vConfetti } from '@neoconfetti/vue'
import { defineNuxtPlugin } from '#imports'

export default defineNuxtPlugin((app) => {
// Register the directive
app.vueApp.directive('v-confetti', vConfetti)
})
7 changes: 7 additions & 0 deletions packages/nuxt/src/runtime/modules/box/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ export interface BoxOptions extends PergelModuleOptions {
* @see https://vueuse.org
*/
vueUse?: boolean

/**
* @default true
* @see https://github.com/PuruVJ/neoconfetti/tree/main/packages/vue
*/
neoconfetti: boolean
}

}
Expand All @@ -86,5 +92,6 @@ export interface ResolvedBoxOptions extends ResolvedPergelModuleOptions {
i18n?: boolean
pinia?: boolean
vueUse?: boolean
neoconfetti: boolean
}
}
9 changes: 8 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 60df021

Please sign in to comment.