-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0d23edc
commit 5e4a9c8
Showing
12 changed files
with
302 additions
and
61 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,56 @@ | ||
<template> | ||
<Story group="forms" :layout="{ type: 'grid' }"> | ||
<Variant title="Playground"> | ||
<AGForm :form="form"> | ||
<DateInput name="date" :label="label" /> | ||
</AGForm> | ||
|
||
<template #controls> | ||
<HstText v-model="label" title="Label" /> | ||
<HstCheckbox v-model="hasErrors" title="Errors" /> | ||
</template> | ||
</Variant> | ||
|
||
<Variant title="Default"> | ||
<DateInput label="What time is it?" /> | ||
</Variant> | ||
|
||
<Variant title="Hover"> | ||
<DateInput label="What time is it?" input-class=":hover" /> | ||
</Variant> | ||
|
||
<Variant title="Focus"> | ||
<DateInput label="What time is it?" input-class=":focus :focus-visible" /> | ||
</Variant> | ||
|
||
<Variant title="Error"> | ||
<AGForm :form="errorForm"> | ||
<DateInput name="date" label="What time is it?" class=":focus :focus-visible" /> | ||
</AGForm> | ||
</Variant> | ||
</Story> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { requiredDateInput, useForm } from '@aerogel/core'; | ||
import { ref, watchEffect } from 'vue'; | ||
const form = useForm({ date: requiredDateInput() }); | ||
const errorForm = useForm({ date: requiredDateInput() }); | ||
const label = ref('What time is it?'); | ||
const hasErrors = ref(false); | ||
errorForm.submit(); | ||
watchEffect(() => (hasErrors.value ? form.submit() : form.reset())); | ||
</script> | ||
|
||
<style> | ||
.story-dateinput { | ||
grid-template-columns: repeat(2, 300px) !important; | ||
} | ||
.story-dateinput .variant-playground { | ||
grid-column: 1 / -1; | ||
} | ||
</style> |
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,36 @@ | ||
<template> | ||
<AGHeadlessInput ref="$input" v-bind="inputProps" :class="className"> | ||
<AGHeadlessInputLabel class="block text-sm font-medium leading-6 text-gray-900" /> | ||
<div :class="$input?.label && 'mt-2'"> | ||
<AGHeadlessInputInput type="date" v-bind="attrs" :class="renderedInputClass" /> | ||
<AGHeadlessInputDescription /> | ||
<AGHeadlessInputError class="mt-1 text-sm text-red-600" /> | ||
</div> | ||
</AGHeadlessInput> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { componentRef, extractInputProps, stringProp, useInputAttrs, useInputProps } from '@aerogel/core'; | ||
import { twMerge } from 'tailwind-merge'; | ||
import { computed } from 'vue'; | ||
import type { IAGHeadlessInput } from '@aerogel/core'; | ||
defineOptions({ inheritAttrs: false }); | ||
const props = defineProps({ | ||
...useInputProps(), | ||
inputClass: stringProp(''), | ||
}); | ||
const inputProps = extractInputProps(props); | ||
const $input = componentRef<IAGHeadlessInput>(); | ||
const [attrs, className] = useInputAttrs(); | ||
const renderedInputClass = computed(() => | ||
twMerge( | ||
[ | ||
'w-full rounded-md border-0 px-2 py-1.5', | ||
'text-base text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300', | ||
'placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-[--primary-600]', | ||
].join(' '), | ||
props.inputClass, | ||
)); | ||
</script> |
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
Oops, something went wrong.