-
Notifications
You must be signed in to change notification settings - Fork 1
создание VuInput компонента #15
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
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| import { Meta, StoryObj } from '@storybook/vue3-vite'; | ||
| import VuInput from './VuInput.vue'; | ||
|
|
||
| const meta = { | ||
| title: 'Viribus Unitis/VuInput', | ||
| component: VuInput, | ||
| } satisfies Meta<typeof VuInput>; | ||
|
|
||
| export default meta; | ||
|
|
||
| type Story = StoryObj<typeof meta>; | ||
|
|
||
| export const Default: Story = { | ||
| args: { | ||
| message: 'Номер группы', | ||
| }, | ||
| }; | ||
| export const Hover: Story = { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Вынеси эту историю в отдельную, типа "Validate"
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. А чтобы показать hover, можешь использовать pseudo. Посмотри, как это сделано в кнопке и поиске |
||
| args: { | ||
| message: 'Номер группы', | ||
| rules: [(value: string) => !!value || 'Обязательное поле'] | ||
| }, | ||
| }; | ||
| export const Active: Story = { | ||
| args: { | ||
| message: 'Номер группы', | ||
| placeholder:"Введите номер группы", | ||
| autofocus: true | ||
| }, | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| <script setup lang="ts"> | ||
| import { PropType } from 'vue'; | ||
|
|
||
| type VariantType = "outlined" | "filled" | "underlined" | "plain" | "solo" | "solo-inverted" | "solo-filled" | ||
| type Rule = (value: any) => string | boolean; | ||
|
|
||
| defineProps({ | ||
| message: { | ||
| type: String, | ||
| default: "" | ||
| }, | ||
| color: { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Поскольку у нас дизайн-система, и там всего один вариант цвета, лучше не отдавать это поле. Поставь одно значение и все |
||
| type: String, | ||
| default: "#000000" | ||
| }, | ||
| variant: { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Аналогично здесь -- в ДС всего один вариант, его и оставляем |
||
| type: String as PropType<VariantType>, | ||
| default: "" | ||
| }, | ||
| placeholder: { | ||
| type: String, | ||
| default: "" | ||
| }, | ||
| autofocus: { | ||
| type: Boolean, | ||
| default: false | ||
| }, | ||
| rules: { | ||
| type: Array as PropType<Rule[]>, | ||
| default: () => [] | ||
| } | ||
| }); | ||
|
|
||
| defineEmits(['update:modelValue']); | ||
| </script> | ||
|
|
||
| <template> | ||
| <v-text-field | ||
| max-width="348px" | ||
| type="input" | ||
| :label="message" | ||
| :color="color" | ||
| :variant="variant || undefined" | ||
| :placeholder="placeholder" | ||
| :autofocus="autofocus" | ||
| :rules="rules" | ||
| > | ||
| </v-text-field> | ||
| </template> | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Подключи
tags: ['autodocs'], чтобы дока сгенерировалась.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Здесь же можно дефолтные аргументы для всех историй прописать