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: timeInputV2 #4635

Merged
merged 5 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/few-items-dream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@ultraviolet/form": patch
---

New component `<TimeInputFieldV2 />`
5 changes: 5 additions & 0 deletions .changeset/funny-gifts-shave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@ultraviolet/ui": minor
---

New component `<TimeInputV2 />`
lisalupi marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { Template } from './Template.stories'

export const Playground = Template.bind({})

Playground.args = Template.args
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import type { StoryFn } from '@storybook/react'
import { Stack } from '@ultraviolet/ui'
import type { ComponentProps } from 'react'
import { TimeInputFieldV2 } from '..'
import { Submit } from '../../Submit'
import { Template } from './Template.stories'

export const Required: StoryFn<
ComponentProps<typeof TimeInputFieldV2>
> = args => (
<Stack gap={1}>
<TimeInputFieldV2 {...args} />
<Submit>Submit</Submit>
</Stack>
)

Required.args = { ...Template.args, required: true }
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import type { StoryFn } from '@storybook/react'
import { Stack } from '@ultraviolet/ui'
import type { ComponentProps } from 'react'
import { TimeInputFieldV2 } from '..'
import { Submit } from '../..'

export const Template: StoryFn<
ComponentProps<typeof TimeInputFieldV2>
> = args => (
<Stack gap="1">
<TimeInputFieldV2 {...args} />
<Submit>Submit</Submit>
</Stack>
)

Template.args = {
label: 'Label',
name: 'example',
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import type { StoryFn } from '@storybook/react'
import { Stack } from '@ultraviolet/ui'
import type { ComponentProps } from 'react'
import { TimeInputFieldV2 } from '..'
import { Submit } from '../../Submit'
import { Template } from './Template.stories'

export const TimeFormat: StoryFn<
ComponentProps<typeof TimeInputFieldV2>
> = args => (
<Stack gap={1}>
<TimeInputFieldV2 {...args} />
<Submit>Submit</Submit>
</Stack>
)

TimeFormat.args = { ...Template.args, timeFormat: 12 }
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import type { Meta } from '@storybook/react'
import { Snippet, Stack, Text } from '@ultraviolet/ui'
import { Form, TimeInputFieldV2 } from '../..'
import { useForm } from '../../..'
import { mockErrors } from '../../../mocks'

export default {
component: TimeInputFieldV2,
decorators: [
ChildStory => {
const methods = useForm()
const {
errors,
isDirty,
isSubmitting,
touchedFields,
submitCount,
dirtyFields,
isValid,
isLoading,
isSubmitted,
isValidating,
isSubmitSuccessful,
} = methods.formState

return (
<Form onSubmit={() => {}} errors={mockErrors} methods={methods}>
<Stack gap={2}>
<ChildStory />
<Stack gap={1}>
<Text variant="bodyStrong" as="p">
Form input values:
</Text>
<Snippet prefix="lines" initiallyExpanded>
{JSON.stringify(methods.watch(), null, 1)}
</Snippet>
</Stack>
<Stack gap={1}>
<Text variant="bodyStrong" as="p">
Form values:
</Text>
<Snippet prefix="lines">
{JSON.stringify(
{
errors,
isDirty,
isSubmitting,
touchedFields,
submitCount,
dirtyFields,
isValid,
isLoading,
isSubmitted,
isValidating,
isSubmitSuccessful,
},
null,
1,
)}
</Snippet>
</Stack>
</Stack>
</Form>
)
},
],
title: 'Form/Components/Fields/TimeInputFieldV2',
} as Meta

export { Playground } from './Playground.stories'
export { Required } from './Required.stories'
export { TimeFormat } from './TimeFormat.stories'
Loading
Loading