Skip to content

Commit

Permalink
feat: support presets (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
benjamincanac authored Nov 26, 2021
1 parent e05cc89 commit 8f09d0c
Show file tree
Hide file tree
Showing 11 changed files with 351 additions and 269 deletions.
1 change: 1 addition & 0 deletions build.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export default {
entries: [
'./src/index',
{ input: './src/components/', outDir: 'dist/components', ext: 'js' },
{ input: './src/presets/', outDir: 'dist/presets', ext: 'js' },
{ input: './src/utils/', outDir: 'dist/utils', ext: 'js' }
],
declaration: true,
Expand Down
2 changes: 1 addition & 1 deletion docs/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
import { UseDark } from '@vueuse/components'
const sections = [
{ label: 'Getting Started', links: [{ label: 'Installation', to: '/' }, { label: 'Examples', to: '/examples' }, { label: 'Migration', to: '/migration' }, { label: 'Dark mode', to: '/dark' }] },
{ label: 'Getting Started', links: [{ label: 'Usage', to: '/' }, { label: 'Examples', to: '/examples' }, { label: 'Migration', to: '/migration' }, { label: 'Dark mode', to: '/dark' }] },
{ label: 'Elements', links: [{ label: 'Avatar', to: '/components/Avatar' }, { label: 'AvatarGroup', to: '/components/AvatarGroup' }, { label: 'Badge', to: '/components/Badge' }, { label: 'Button', to: '/components/Button' }, { label: 'Dropdown', to: '/components/Dropdown' }, { label: 'Icon', to: '/components/Icon' }, { label: 'Link', to: '/components/Link' }, { label: 'Toggle', to: '/components/Toggle' }] },
{ label: 'Feedback', links: [{ label: 'Alert', to: '/components/Alert' }] },
{ label: 'Forms', links: [{ label: 'Checkbox', to: '/components/Checkbox' }, { label: 'Input', to: '/components/Input' }, { label: 'InputGroup', to: '/components/InputGroup' }, { label: 'Radio', to: '/components/Radio' }, { label: 'RadioGroup', to: '/components/RadioGroup' }, { label: 'Select', to: '/components/Select' }, { label: 'SelectCustom', to: '/components/SelectCustom' }, { label: 'Textarea', to: '/components/Textarea' }] },
Expand Down
13 changes: 11 additions & 2 deletions docs/pages/components/[component].vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@
</template>

<script setup>
import $ui from '#build/ui'
const nuxtApp = useNuxtApp()
const { params } = useRoute()
Expand All @@ -74,8 +76,15 @@ const refProps = Object.entries(componentProps).map(([key, prop]) => {
let values
if (prop.validator) {
const result = prop.validator.toString().match(/\[.*\]/g, '')[0]
values = JSON.parse(result.replace(/'/g, '"')).filter(Boolean)
const arrayRegex = prop.validator.toString().match(/\[.*\]/g, '')
if (arrayRegex) {
values = JSON.parse(arrayRegex[0].replace(/'/g, '"')).filter(Boolean)
} else {
const $uiProp = $ui[params.component.toLowerCase()][key]
if ($uiProp) {
values = Object.keys($uiProp).filter(Boolean)
}
}
}
if (value) {
Expand Down
4 changes: 4 additions & 0 deletions docs/pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ export default defineNuxtConfig({
Options
</h2>

<p>- `preset`</p>

<p>Choose preset. Defaults to `tailwindui`. An object can also be used to override some parts of the default preset.</p>

<p>- `prefix`</p>

<p>Define the prefix of the imported components. Defaults to `u`.</p>
Expand Down
33 changes: 22 additions & 11 deletions docs/pages/migration.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@
Component
</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium u-text-gray-500 uppercase tracking-wider">
Ready?
Composition API
</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium u-text-gray-500 uppercase tracking-wider">
Preset system
</th>
</tr>
</thead>
Expand All @@ -32,7 +35,11 @@
</NuxtLink>
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm u-text-gray-500">
<span v-if="component.ready">✅</span>
<span v-if="component.capi">✅</span>
<span v-else>❌</span>
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm u-text-gray-500">
<span v-if="component.preset">✅</span>
<span v-else>❌</span>
</td>
</tr>
Expand Down Expand Up @@ -63,12 +70,12 @@ const components = [
{
label: 'Dropdown',
to: '/components/Dropdown',
ready: true
capi: true
},
{
label: 'Icon',
to: '/components/Icon',
ready: true
capi: true
},
{
label: 'Link',
Expand All @@ -89,7 +96,8 @@ const components = [
{
label: 'Input',
to: '/components/Input',
ready: true
capi: true,
preset: true
},
{
label: 'InputGroup',
Expand All @@ -105,7 +113,9 @@ const components = [
},
{
label: 'Select',
to: '/components/Select'
to: '/components/Select',
capi: true,
preset: true
},
{
label: 'SelectCustom',
Expand All @@ -114,17 +124,18 @@ const components = [
{
label: 'Textarea',
to: '/components/Textarea',
ready: true
capi: true,
preset: true
},
{
label: 'Card',
to: '/components/Card',
ready: true
capi: true
},
{
label: 'Container',
to: '/components/Container',
ready: true
capi: true
},
{
label: 'Pills',
Expand All @@ -141,7 +152,7 @@ const components = [
{
label: 'Modal',
to: '/components/Modal',
ready: true
capi: true
},
{
label: 'Notification',
Expand All @@ -150,7 +161,7 @@ const components = [
{
label: 'Popover',
to: '/components/Popover',
ready: true
capi: true
},
{
label: 'Slideover',
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,15 @@
"@iconify-json/heroicons-solid": "^1.0.2",
"@popperjs/core": "^2.10.2",
"@unocss/nuxt": "^0.12.9",
"defu": "^5.0.0",
"gradient-avatar": "^1.0.2",
"lodash": "^4.17.21",
"pathe": "^0.2.0"
},
"devDependencies": {
"@vueuse/core": "^7.1.1",
"@vueuse/components": "^7.1.1",
"@nuxtjs/eslint-config-typescript": "7.0.2",
"@vueuse/components": "^7.1.1",
"@vueuse/core": "^7.1.1",
"eslint": "8.3.0",
"nuxt3": "3.0.0-27296423.f3082ca",
"unbuild": "0.5.13"
Expand Down
Loading

1 comment on commit 8f09d0c

@vercel
Copy link

@vercel vercel bot commented on 8f09d0c Nov 26, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

Please sign in to comment.