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: Switch toast to vue-sonner instead of NuxtUI #39

Merged
merged 3 commits into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified bun.lockb
Binary file not shown.
6 changes: 2 additions & 4 deletions components/content/Contact.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import type { ContactEmail } from '~/types/ContactEmail'
const appConfig = useAppConfig()
const { t } = useI18n()

const toast = useToast()

const demandTypes = [
{
label: 'contact.subject_types.project',
Expand Down Expand Up @@ -66,10 +64,10 @@ async function submitForm() {
fullname.value = ''
budget.value = 450
selected.value = demandTypes[0]
toast.add({ title: t('contact.success'), icon: 'i-heroicons-check-circle', timeout: 2500 })
toast.success(t('contact.success'))
}
else {
toast.add({ title: t('contact.error'), icon: 'i-heroicons-x-circle', timeout: 2500, color: 'red' })
toast.success(t('contact.error'))
}
loading.value = false
}
Expand Down
5 changes: 2 additions & 3 deletions layouts/article.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<script lang="ts" setup>
const { page } = useContent()
const { t } = useI18n()
const toast = useToast()

useContentHead(page)

Expand All @@ -10,15 +9,15 @@ const articleLink = ref(`${runtimeConfig.public.siteUrl}${page.value._path}`)

function copyArticleLink() {
copyToClipboard(articleLink.value)
toast.add({ title: t('global.article_link_copied'), icon: 'i-heroicons-check-circle', timeout: 2500 })
toast.success(t('global.article_link_copied'))
}

defineShortcuts({
meta_k: {
usingInput: true,
handler: () => {
copyToClipboard(articleLink.value)
toast.add({ title: t('global.article_link_copied'), icon: 'i-heroicons-check-circle', timeout: 2500 })
toast.success(t('global.article_link_copied'))
},
},
})
Expand Down
13 changes: 11 additions & 2 deletions nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export default defineNuxtConfig({
'@nuxthq/studio',
'@nuxt/image',
'nuxt-og-image',
"@nuxt/fonts"
'@nuxt/fonts',
],

image: {
Expand All @@ -70,6 +70,15 @@ export default defineNuxtConfig({
},
},

imports: {
presets: [
{
from: 'vue-sonner',
imports: ['toast'],
},
],
},

i18n: {
strategy: 'no_prefix',
detectBrowserLanguage: {
Expand Down Expand Up @@ -113,4 +122,4 @@ export default defineNuxtConfig({
svgo: {
autoImportPath: './assets/logo/',
},
})
})
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,8 @@
"nuxt-svgo": "^3.7.0",
"resend": "^0.17.2",
"sitemap": "^7.1.1"
},
"dependencies": {
"vue-sonner": "^1.1.2"
}
}
7 changes: 4 additions & 3 deletions pages/[...slug].vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<script setup lang="ts">
import { Toaster } from 'vue-sonner'

const runtimeConfig = useRuntimeConfig()
const appConfig = useAppConfig()
const { appName, email } = useAppConfig()
const toast = useToast()
const { t } = useI18n()
const { locale } = useI18n()

Expand Down Expand Up @@ -66,7 +67,7 @@ defineShortcuts({
usingInput: true,
handler: () => {
copyToClipboard(email)
toast.add({ title: t('global.email_copied'), icon: 'i-heroicons-check-circle', timeout: 2500 })
toast.success(t('global.email_copied'))
},
},
})
Expand All @@ -90,7 +91,7 @@ defineShortcuts({
<ContentRenderer :value="data" />
</ContentQuery>
</NuxtLayout>
<UNotifications />
<Toaster close-button />
<DotPattern class="absolute inset-0 -z-10 size-full fill-white/5 [mask-image:radial-gradient(white,transparent_85%)]" />
</Body>
</Html>
Expand Down