feat(Toast): new component (#50)

This commit is contained in:
Benjamin Canac
2024-04-10 18:22:09 +02:00
committed by GitHub
parent 90f18a3505
commit 3da1e1a518
13 changed files with 566 additions and 12 deletions

View File

@@ -35,6 +35,23 @@ export function addTemplates (options: ModuleOptions, nuxt: Nuxt) {
to { height: var(--radix-collapsible-content-height); }
}
@keyframes toast-slide-down {
from { transform: var(--transform); }
to { transform: translateY(calc((var(--offset) - var(--height)) * -1px)); }
}
@keyframes toast-slide-up {
from { transform: var(--transform); }
to { transform: translateY(calc((var(--offset) - var(--height)) * 1px)); }
}
@keyframes toast-slide-left {
from { transform: translateX(0) translateY(var(--translate)); }
to { transform: translateX(-100%) translateY(var(--translate)); }
}
@keyframes toast-slide-right {
from { transform: translateX(0) translateY(var(--translate)); }
to { transform: translateX(100%) translateY(var(--translate)); }
}
@keyframes fade-in {
from { opacity: 0; }
to { opacity: 1; }
@@ -172,7 +189,11 @@ export function addTemplates (options: ModuleOptions, nuxt: Nuxt) {
let json = JSON.stringify(result, null, 2)
for (const variant of variants) {
json = json.replaceAll(new RegExp(`("${variant}": "[0-9a-z-]+")`, 'g'), '$1 as const')
json = json.replace(new RegExp(`("${variant}": "[^"]+")`, 'g'), '$1 as const')
json = json.replace(new RegExp(`("${variant}": \\[\\s*)((?:"[^"]+",?\\s*)+)(\\])`, 'g'), (_, before, match, after) => {
const replaced = match.replace(/("[^"]+")/g, '$1 as const')
return `${before}${replaced}${after}`
})
}
return `export default ${json}`