design: confirm message with daisyui design

This commit is contained in:
Julien Calixte
2024-12-29 01:12:54 +01:00
parent 6a84c92f4f
commit c93e4a8b16
6 changed files with 22 additions and 11 deletions

View File

@@ -33,11 +33,11 @@ export const useGitHubContent = ({
} }
) )
confirmMessage('Note saved') confirmMessage('Note saved')
return response?.data.content?.sha ?? null return response?.data.content?.sha ?? null
} catch (error) { } catch (error) {
errorMessage('Note could not be saved') errorMessage('Note could not be saved')
console.warn(error) console.warn(error)
} }

View File

@@ -19,7 +19,7 @@ const saveCredentials = async (token: GithubToken): Promise<void> => {
const accessToken = await saveAccessToken(token) const accessToken = await saveAccessToken(token)
await saveAccessTokenToLocal() await saveAccessTokenToLocal()
confirmMessage(`${accessToken.username} is logged in!`) confirmMessage(`${accessToken.username} is logged in!`)
} }
export const useGitHubLogin = () => { export const useGitHubLogin = () => {

View File

@@ -1,5 +1,5 @@
import './styles/app.css'
import 'notyf/notyf.min.css' import 'notyf/notyf.min.css'
import './styles/app.css'
import { createPinia } from 'pinia' import { createPinia } from 'pinia'
import { createApp } from 'vue' import { createApp } from 'vue'

View File

@@ -1,12 +1,14 @@
<script setup lang="ts"> <script setup lang="ts">
import { useOfflineNotes } from '@/hooks/useOfflineNotes.hook' import { useOfflineNotes } from '@/hooks/useOfflineNotes.hook'
import { confirmMessage } from '@/utils/notif'
const { cacheAllNotes, isLoading, totalOfNotes, noteCompleted } = const { cacheAllNotes, isLoading, totalOfNotes, noteCompleted } =
useOfflineNotes() useOfflineNotes()
const confirmBeforeCachingAllNotes = () => { const confirmBeforeCachingAllNotes = async () => {
confirm('Do you want to cache all notes?') confirm('Do you want to cache all notes?')
cacheAllNotes() await cacheAllNotes()
confirmMessage('✅ All notes have been locally saved')
} }
</script> </script>

View File

@@ -60,9 +60,13 @@ a {
} }
} }
.notif-success { .notyf__wrapper {
background-color: oklch(var(--a)); padding-top: 0;
color: oklch(var(--ac)); padding-bottom: 0;
}
.alert {
max-width: 500px;
} }
.repo-note { .repo-note {

View File

@@ -3,8 +3,12 @@ import { Notyf } from 'notyf'
const notif = new Notyf({ const notif = new Notyf({
types: [ types: [
{ {
className: 'notif-success', className: 'prose alert alert-success',
type: 'confirm' type: 'confirm'
},
{
className: 'prose alert alert-error',
type: 'error'
} }
] ]
}) })
@@ -15,4 +19,5 @@ export const confirmMessage = (message: string) =>
message message
}) })
export const errorMessage = (message: string) => notif.error(message) export const errorMessage = (message: string) =>
notif.open({ type: 'error', message })