-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #59 from selemondev/auto-imports
feat(app): #58 Auto Imports
- Loading branch information
Showing
17 changed files
with
170 additions
and
135 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import type { ComponentResolver } from 'unplugin-vue-components' | ||
|
||
export function WindiUIComponentResolver(): ComponentResolver { | ||
return { | ||
type: 'component', | ||
resolve: (name: string) => { | ||
if (name.match(/^W[A-Z]/)) | ||
return { name, from: '@windi-ui/vue' } | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
export { default as WAvatar } from './Avatar/WAvatar.vue' | ||
export { default as WAvatarGroup } from './Avatar/WAvatarGroup.vue' | ||
export { default as WAccordion } from './Accordion/WAccordion.vue' | ||
export { default as WAccordionItem } from './Accordion/WAccordionItem.vue' | ||
export { default as WAlert } from './Alert/WAlert.vue' | ||
export { default as WAlertDescription } from './Alert/WAlertDescription.vue' | ||
export { default as WBadge } from './Badge/WBadge.vue' | ||
export { default as WButton } from './Button/WButton.vue' | ||
export { default as WButtonGroup } from './Button/WButtonGroup.vue' | ||
export { default as WCheckbox } from './Checkbox/WCheckbox.vue' | ||
export { default as WDivider } from './Divider/WDivider.vue' | ||
export { default as WIcon } from './Icon/WIcon.vue' | ||
export { default as WInput } from './Input/WInput.vue' | ||
export { default as WKbd } from './Kbd/WKbd.vue' | ||
export { default as WModal } from './Modal/WModal.vue' | ||
export { default as WSwitch } from './Switch/WSwitch.vue' | ||
export { default as WTag } from './Tag/WTag.vue' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,7 @@ | ||
import type { App, defineComponent } from 'vue' | ||
import './assets/css/tailwind.css' | ||
import Alert from './components/Alert/WAlert.vue' | ||
import AlertDescription from './components/Alert/WAlertDescription.vue' | ||
import Avatar from './components/Avatar/WAvatar.vue' | ||
import Icon from './components/Icon/WIcon.vue' | ||
import type { WindiUIConfiguration } from './Types/variant' | ||
import AvatarGroup from './components/Avatar/WAvatarGroup.vue' | ||
import Badge from './components/Badge/WBadge.vue' | ||
import Button from './components/Button/WButton.vue' | ||
import ButtonGroup from './components/Button/WButtonGroup.vue' | ||
import Accordion from './components/Accordion/WAccordion.vue' | ||
import AccordionItem from './components/Accordion/WAccordionItem.vue' | ||
import Kbd from './components/Kbd/WKbd.vue' | ||
import Input from './components/Input/WInput.vue' | ||
import Checkbox from './components/Checkbox/WCheckbox.vue' | ||
import Divider from './components/Divider/WDivider.vue' | ||
import Switch from './components/Switch/WSwitch.vue' | ||
import Tag from './components/Tag/WTag.vue' | ||
import windiTheme from './theme/windiTheme' | ||
import Modal from './components/Modal/WModal.vue' | ||
export * from './components' | ||
|
||
const components: Record<string, ReturnType<typeof defineComponent>> = { | ||
Accordion, | ||
AccordionItem, | ||
Alert, | ||
AlertDescription, | ||
Icon, | ||
Avatar, | ||
AvatarGroup, | ||
Badge, | ||
Button, | ||
ButtonGroup, | ||
Kbd, | ||
Input, | ||
Checkbox, | ||
Divider, | ||
Switch, | ||
Tag, | ||
Modal, | ||
} | ||
export { default as createWindiUI } from './plugin' | ||
|
||
function install(app: App, configuration: WindiUIConfiguration) { | ||
for (const component in components) | ||
app.component(components[component].name, components[component]) | ||
app.provide('config', configuration) | ||
} | ||
export { WindiUIComponentResolver } from './componentResolver' | ||
|
||
export default { install, windiTheme } | ||
|
||
export { default as Alert } from './components/Alert' | ||
export { default as AlertDescription } from './components/Alert' | ||
export { default as Icon } from './components/Icon' | ||
export { default as Avatar } from './components/Avatar' | ||
export { default as AvatarGroup } from './components/Avatar' | ||
export { default as Badge } from './components/Badge' | ||
export { default as Button } from './components/Button' | ||
export { default as ButtonGroup } from './components/Button' | ||
export { default as Accordion } from './components/Accordion' | ||
export { default as AccordionItem } from './components/Accordion' | ||
export { default as Kbd } from './components/Kbd' | ||
export { default as Input } from './components/Input' | ||
export { default as Checkbox } from './components/Checkbox' | ||
export { default as Divider } from './components/Divider' | ||
export { default as Switch } from './components/Switch' | ||
export { default as Tag } from './components/Tag' | ||
export { default as Modal } from './components/Modal' | ||
export { default } from './install' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import * as components from './components' | ||
import create from './plugin' | ||
|
||
export default create({ | ||
components: Object.keys(components).map( | ||
key => components[key as keyof object], | ||
), | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import type { App } from 'vue' | ||
import './assets/css/tailwind.css' | ||
import type { WindiUIConfiguration } from './Types/variant' | ||
|
||
const defaultOptions: WindiUIOptions = { | ||
prefix: 'W', | ||
registerComponents: true, | ||
} | ||
|
||
export interface WindiUIOptions { | ||
prefix?: string | ||
components?: any | ||
theme?: any | ||
registerComponents?: boolean | ||
} | ||
|
||
function create(createOptions: WindiUIOptions = {}) { | ||
const install = (app: App, installOptions: WindiUIConfiguration) => { | ||
const options = { | ||
...defaultOptions, | ||
...createOptions, | ||
...installOptions, | ||
} | ||
if (options.registerComponents) { | ||
if (options.components) { | ||
options.components.forEach((component: any) => { | ||
const name = component.name.startsWith('W') ? component.name.slice(1) : component.name | ||
|
||
app.component(`${options.prefix}${name}`, component) | ||
}) | ||
} | ||
} | ||
app.provide('config', installOptions) | ||
} | ||
|
||
return { | ||
install, | ||
} | ||
} | ||
|
||
export default create |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +0,0 @@ | ||
import install from '@selemondev/windi-ui' | ||
export * from '@selemondev/windi-ui' | ||
export default install | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.