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(resolver): add headlessUi resolver #43

Merged
merged 1 commit into from
May 12, 2021

Conversation

YannicEl
Copy link
Collaborator

@YannicEl YannicEl commented May 12, 2021

Hi people!

I created a resolver for headlessUi
https://github.com/tailwindlabs/headlessui

The problem with headlessUi is, that its components are not prefixed and therefore a simple regex or startsWith cannot be used to identify them. As you can see the solution for this was having a string array with all component names and checking if the resolved component is included. Having a hardcoded array of names is not an optimal solution.

The headlessUi package exports all the components. A dynamic solution could look something like this:

import * as components from '@headlessui/vue'
const components = Object.keys(components)

The downside to this is, that you have to import the whole package.

I do not know which solution is better, so feedback is welcome.

PS: This is my first contribution to an open source project. Please let me know if I did anything wrong.

Greetings
Yannic

@antfu
Copy link
Member

antfu commented May 12, 2021

We could accept a config to specify the prefix, and do something like:

import { Menu as HeadlessMean } from '@headlessui/vue'

But we could have it in later PR if you want. Thanks

@antfu antfu changed the title Add headlessUi resolver feat(resolver): add headlessUi resolver May 12, 2021
@antfu antfu merged commit 429e40f into unplugin:master May 12, 2021
ascott18 pushed a commit to ascott18/unplugin-vue-components that referenced this pull request Mar 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants