mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-29 19:30:37 +01:00
chore: support presets for InputGroup and ToggleGroup
This commit is contained in:
@@ -110,6 +110,14 @@ const defaultProps = {
|
|||||||
Input: {
|
Input: {
|
||||||
name: 'input'
|
name: 'input'
|
||||||
},
|
},
|
||||||
|
InputGroup: {
|
||||||
|
name: 'input',
|
||||||
|
label: 'Input group'
|
||||||
|
},
|
||||||
|
ToggleGroup: {
|
||||||
|
name: 'input',
|
||||||
|
label: 'Toggle group'
|
||||||
|
},
|
||||||
Checkbox: {
|
Checkbox: {
|
||||||
name: 'checkbox'
|
name: 'checkbox'
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -101,6 +101,13 @@ const components = [
|
|||||||
nuxt3: true,
|
nuxt3: true,
|
||||||
capi: true
|
capi: true
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
label: 'ToggleGroup',
|
||||||
|
to: '/components/ToggleGroup',
|
||||||
|
nuxt3: true,
|
||||||
|
capi: true,
|
||||||
|
preset: true
|
||||||
|
},
|
||||||
{
|
{
|
||||||
label: 'Alert',
|
label: 'Alert',
|
||||||
to: '/components/Alert'
|
to: '/components/Alert'
|
||||||
@@ -117,7 +124,10 @@ const components = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'InputGroup',
|
label: 'InputGroup',
|
||||||
to: '/components/InputGroup'
|
to: '/components/InputGroup',
|
||||||
|
nuxt3: true,
|
||||||
|
capi: true,
|
||||||
|
preset: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Radio',
|
label: 'Radio',
|
||||||
|
|||||||
@@ -1,30 +1,23 @@
|
|||||||
<template>
|
<template>
|
||||||
<div
|
<div>
|
||||||
:class="{ 'sm:grid sm:grid-cols-3 sm:gap-4 sm:items-start sm:u-border-gray-200': inline }"
|
|
||||||
>
|
|
||||||
<slot name="label">
|
<slot name="label">
|
||||||
<div :class="{ 'flex content-center justify-between': !inline }">
|
<div class="flex content-center justify-between">
|
||||||
<label
|
<label
|
||||||
v-if="label"
|
v-if="label"
|
||||||
:for="name"
|
:for="name"
|
||||||
class="block text-sm font-medium leading-5 u-text-gray-700"
|
:class="labelClass"
|
||||||
:class="{'sm:mt-px sm:pt-2': inline }"
|
|
||||||
>
|
>
|
||||||
{{ label }}
|
{{ label }}
|
||||||
<span v-if="required" class="text-red-400">*</span>
|
<span v-if="required" :class="requiredClass">*</span>
|
||||||
</label>
|
</label>
|
||||||
<span
|
<span v-if="$slots.hint || hint" :class="hintClass">
|
||||||
v-if="$slots.hint || hint"
|
<slot name="hint">{{ hint }}</slot>
|
||||||
class="text-sm leading-5 u-text-gray-500"
|
</span>
|
||||||
:class="{ 'mt-1 max-w-2xl': inline }"
|
|
||||||
><slot name="hint">{{ hint }}</slot></span>
|
|
||||||
</div>
|
</div>
|
||||||
</slot>
|
</slot>
|
||||||
<div
|
<div :class="!!label && containerClass">
|
||||||
:class="{ 'mt-1': label && !inline, 'mt-1 sm:mt-0': label && inline, 'sm:col-span-2': inline }"
|
|
||||||
>
|
|
||||||
<slot />
|
<slot />
|
||||||
<p v-if="help" class="mt-2 text-sm u-text-gray-500">
|
<p v-if="help" :class="helpClass">
|
||||||
{{ help }}
|
{{ help }}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
@@ -32,6 +25,8 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import $ui from '#build/ui'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
name: {
|
name: {
|
||||||
@@ -54,9 +49,25 @@ export default {
|
|||||||
type: String,
|
type: String,
|
||||||
default: null
|
default: null
|
||||||
},
|
},
|
||||||
inline: {
|
containerClass: {
|
||||||
type: Boolean,
|
type: String,
|
||||||
default: false
|
default: () => $ui.inputGroup.container
|
||||||
|
},
|
||||||
|
labelClass: {
|
||||||
|
type: String,
|
||||||
|
default: () => $ui.inputGroup.label
|
||||||
|
},
|
||||||
|
requiredClass: {
|
||||||
|
type: String,
|
||||||
|
default: () => $ui.inputGroup.required
|
||||||
|
},
|
||||||
|
hintClass: {
|
||||||
|
type: String,
|
||||||
|
default: () => $ui.inputGroup.hint
|
||||||
|
},
|
||||||
|
helpClass: {
|
||||||
|
type: String,
|
||||||
|
default: () => $ui.inputGroup.help
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,31 +1,23 @@
|
|||||||
<template>
|
<template>
|
||||||
<SwitchGroup
|
<SwitchGroup as="div">
|
||||||
:class="{ 'sm:grid sm:grid-cols-3 sm:gap-4 sm:items-start sm:u-border-gray-200': inline }"
|
|
||||||
as="div"
|
|
||||||
>
|
|
||||||
<slot name="label">
|
<slot name="label">
|
||||||
<div :class="{ 'flex content-center justify-between': !inline }">
|
<div class="flex content-center justify-between">
|
||||||
<SwitchLabel
|
<SwitchLabel
|
||||||
v-if="label"
|
v-if="label"
|
||||||
:for="name"
|
:for="name"
|
||||||
class="block text-sm font-medium leading-5 u-text-gray-700"
|
:class="labelClass"
|
||||||
:class="{'sm:mt-px sm:pt-2': inline }"
|
|
||||||
>
|
>
|
||||||
{{ label }}
|
{{ label }}
|
||||||
<span v-if="required" class="text-red-400">*</span>
|
<span v-if="required" :class="requiredClass">*</span>
|
||||||
</SwitchLabel>
|
</SwitchLabel>
|
||||||
<span
|
<span v-if="$slots.hint || hint" :class="hintClass">
|
||||||
v-if="$slots.hint || hint"
|
<slot name="hint">{{ hint }}</slot>
|
||||||
class="text-sm leading-5 u-text-gray-500"
|
</span>
|
||||||
:class="{ 'mt-1 max-w-2xl': inline }"
|
|
||||||
><slot name="hint">{{ hint }}</slot></span>
|
|
||||||
</div>
|
</div>
|
||||||
</slot>
|
</slot>
|
||||||
<div
|
<div :class="!!label && containerClass">
|
||||||
:class="{ 'mt-1': label && !inline, 'mt-1 sm:mt-0': label && inline, 'sm:col-span-2': inline }"
|
|
||||||
>
|
|
||||||
<slot />
|
<slot />
|
||||||
<p v-if="help" class="mt-2 text-sm u-text-gray-500">
|
<p v-if="help" :class="helpClass">
|
||||||
{{ help }}
|
{{ help }}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
@@ -34,6 +26,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { SwitchGroup, SwitchLabel } from '@headlessui/vue'
|
import { SwitchGroup, SwitchLabel } from '@headlessui/vue'
|
||||||
|
import $ui from '#build/ui'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
@@ -61,9 +54,25 @@ export default {
|
|||||||
type: String,
|
type: String,
|
||||||
default: null
|
default: null
|
||||||
},
|
},
|
||||||
inline: {
|
containerClass: {
|
||||||
type: Boolean,
|
type: String,
|
||||||
default: false
|
default: () => $ui.toggleGroup.container
|
||||||
|
},
|
||||||
|
labelClass: {
|
||||||
|
type: String,
|
||||||
|
default: () => $ui.toggleGroup.label
|
||||||
|
},
|
||||||
|
requiredClass: {
|
||||||
|
type: String,
|
||||||
|
default: () => $ui.toggleGroup.required
|
||||||
|
},
|
||||||
|
hintClass: {
|
||||||
|
type: String,
|
||||||
|
default: () => $ui.toggleGroup.hint
|
||||||
|
},
|
||||||
|
helpClass: {
|
||||||
|
type: String,
|
||||||
|
default: () => $ui.toggleGroup.help
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -98,6 +98,18 @@ const input = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const inputGroup = {
|
||||||
|
label: 'block text-sm font-medium u-text-gray-700',
|
||||||
|
container: 'mt-1 relative',
|
||||||
|
required: 'text-red-400',
|
||||||
|
hint: 'text-sm leading-5 u-text-gray-500',
|
||||||
|
help: 'mt-2 text-sm u-text-gray-500'
|
||||||
|
}
|
||||||
|
|
||||||
|
const toggleGroup = {
|
||||||
|
...inputGroup
|
||||||
|
}
|
||||||
|
|
||||||
const textarea = {
|
const textarea = {
|
||||||
...input
|
...input
|
||||||
}
|
}
|
||||||
@@ -184,6 +196,8 @@ const button = {
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
input,
|
input,
|
||||||
|
inputGroup,
|
||||||
|
toggleGroup,
|
||||||
textarea,
|
textarea,
|
||||||
select,
|
select,
|
||||||
button
|
button
|
||||||
|
|||||||
Reference in New Issue
Block a user