mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-31 12:17:54 +01:00
chore(module): update
This commit is contained in:
@@ -2,25 +2,6 @@ import { defu } from 'defu'
|
|||||||
import { createResolver, defineNuxtModule, addComponentsDir, addImportsDir, addVitePlugin, addPlugin, installModule } from '@nuxt/kit'
|
import { createResolver, defineNuxtModule, addComponentsDir, addImportsDir, addVitePlugin, addPlugin, installModule } from '@nuxt/kit'
|
||||||
import tailwindcss from '@tailwindcss/vite'
|
import tailwindcss from '@tailwindcss/vite'
|
||||||
import createTemplates from './templates'
|
import createTemplates from './templates'
|
||||||
// import type { DeepPartial } from './runtime/types'
|
|
||||||
// import * as theme from './runtime/theme'
|
|
||||||
|
|
||||||
// type UI = {
|
|
||||||
// primary?: string
|
|
||||||
// gray?: string
|
|
||||||
// [key: string]: any
|
|
||||||
// } & DeepPartial<typeof theme>
|
|
||||||
|
|
||||||
// declare module 'nuxt/schema' {
|
|
||||||
// interface AppConfigInput {
|
|
||||||
// ui?: UI
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// declare module '@nuxt/schema' {
|
|
||||||
// interface AppConfigInput {
|
|
||||||
// ui?: UI
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
export interface ModuleOptions {
|
export interface ModuleOptions {
|
||||||
colors: string[]
|
colors: string[]
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { tv } from 'tailwind-variants'
|
import { tv } from 'tailwind-variants'
|
||||||
// import appConfig from '#build/app.config'
|
import appConfig from '#build/app.config'
|
||||||
import theme from '#build/ui/container'
|
import theme from '#build/ui/container'
|
||||||
|
|
||||||
const container = tv(theme)
|
const container = tv({ extend: tv(theme), ...(appConfig.ui?.container || {}) })
|
||||||
// const appContainer = tv({ extend: container, ...(appConfig.ui?.container || {}) })
|
|
||||||
|
|
||||||
export interface ContainerProps {
|
export interface ContainerProps {
|
||||||
as?: string
|
as?: string
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import type { TooltipRootProps, TooltipRootEmits, TooltipContentProps } from 'ra
|
|||||||
import theme from '#build/ui/tooltip'
|
import theme from '#build/ui/tooltip'
|
||||||
|
|
||||||
const tooltip = tv(theme)
|
const tooltip = tv(theme)
|
||||||
// const appTooltip = tv({ extend: tooltip, ...(appConfig.ui?.tooltip || {}) })
|
// const tooltip = tv({ extend: tv(theme), ...(appConfig.ui?.tooltip || {}) })
|
||||||
|
|
||||||
export interface TooltipProps extends TooltipRootProps, Omit<TooltipContentProps, 'as' | 'asChild'> {
|
export interface TooltipProps extends TooltipRootProps, Omit<TooltipContentProps, 'as' | 'asChild'> {
|
||||||
text?: string
|
text?: string
|
||||||
|
|||||||
3
src/runtime/types/index.d.ts
vendored
3
src/runtime/types/index.d.ts
vendored
@@ -1,3 +0,0 @@
|
|||||||
export type DeepPartial<T> = Partial<{
|
|
||||||
[P in keyof T]: DeepPartial<T[P]> | { [key: string]: string | object }
|
|
||||||
}>
|
|
||||||
@@ -7,10 +7,9 @@ export default function createTemplates (options: ModuleOptions, nuxt: Nuxt) {
|
|||||||
const shades = [50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950]
|
const shades = [50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950]
|
||||||
|
|
||||||
const template = addTemplate({
|
const template = addTemplate({
|
||||||
filename: 'ui.css',
|
filename: 'ui/index.css',
|
||||||
write: true,
|
write: true,
|
||||||
getContents: () => `
|
getContents: () => `@import "tailwindcss";
|
||||||
@import "tailwindcss";
|
|
||||||
|
|
||||||
@theme {
|
@theme {
|
||||||
--color-gray-*: initial;
|
--color-gray-*: initial;
|
||||||
@@ -40,14 +39,39 @@ export default function createTemplates (options: ModuleOptions, nuxt: Nuxt) {
|
|||||||
write: true,
|
write: true,
|
||||||
getContents: () => `export default ${JSON.stringify((theme as any)[component]({ colors: options.colors }), null, 2)}`
|
getContents: () => `export default ${JSON.stringify((theme as any)[component]({ colors: options.colors }), null, 2)}`
|
||||||
})
|
})
|
||||||
|
|
||||||
// addTypeTemplate({
|
|
||||||
// filename: `ui/${component}.d.ts`,
|
|
||||||
// write: true,
|
|
||||||
// getContents: () => `import ${component} from './${component}'
|
|
||||||
|
|
||||||
// type T = typeof ${component}
|
|
||||||
// export default T`
|
|
||||||
// })
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addTemplate({
|
||||||
|
filename: 'ui/index.ts',
|
||||||
|
write: true,
|
||||||
|
getContents: () => Object.keys(theme).map(component => `export { default as ${component} } from './${component}'`).join('\n')
|
||||||
|
})
|
||||||
|
|
||||||
|
addTypeTemplate({
|
||||||
|
filename: 'types/ui.d.ts',
|
||||||
|
getContents: () => `
|
||||||
|
import * as ui from '#build/ui'
|
||||||
|
|
||||||
|
type DeepPartial<T> = Partial<{
|
||||||
|
[P in keyof T]: DeepPartial<T[P]> | { [key: string]: string | object }
|
||||||
|
}>
|
||||||
|
|
||||||
|
type UI = {
|
||||||
|
primary?: string
|
||||||
|
gray?: string
|
||||||
|
[key: string]: any
|
||||||
|
} & DeepPartial<typeof ui>
|
||||||
|
|
||||||
|
declare module 'nuxt/schema' {
|
||||||
|
interface AppConfigInput {
|
||||||
|
ui?: UI
|
||||||
|
}
|
||||||
|
}
|
||||||
|
declare module '@nuxt/schema' {
|
||||||
|
interface AppConfigInput {
|
||||||
|
ui?: UI
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export {}`
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,12 @@ export default (config: any) => ({
|
|||||||
icon: 'shrink-0'
|
icon: 'shrink-0'
|
||||||
},
|
},
|
||||||
variants: {
|
variants: {
|
||||||
color: Object.fromEntries(config.colors.map((color: string) => [color, ''])),
|
color: {
|
||||||
|
...Object.fromEntries(config.colors.map((color: string) => [color, ''])),
|
||||||
|
white: '',
|
||||||
|
gray: '',
|
||||||
|
black: ''
|
||||||
|
},
|
||||||
variant: {
|
variant: {
|
||||||
solid: '',
|
solid: '',
|
||||||
outline: '',
|
outline: '',
|
||||||
|
|||||||
Reference in New Issue
Block a user