Skip to content
Closed
Show file tree
Hide file tree
Changes from 3 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
30 changes: 30 additions & 0 deletions src/components/Input/VuInput.stories.ts
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',
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Подключи tags: ['autodocs'], чтобы дока сгенерировалась.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Здесь же можно дефолтные аргументы для всех историй прописать

component: VuInput,
} satisfies Meta<typeof VuInput>;

export default meta;

type Story = StoryObj<typeof meta>;

export const Default: Story = {
args: {
message: 'Номер группы',
},
};
export const Hover: Story = {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Вынеси эту историю в отдельную, типа "Validate"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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
},
};
49 changes: 49 additions & 0 deletions src/components/Input/VuInput.vue
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;

Check failure on line 5 in src/components/Input/VuInput.vue

View workflow job for this annotation

GitHub Actions / Проверяем стили

Unexpected any. Specify a different type

defineProps({
message: {
type: String,
default: ""
},
color: {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Поскольку у нас дизайн-система, и там всего один вариант цвета, лучше не отдавать это поле. Поставь одно значение и все

type: String,
default: "#000000"
},
variant: {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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>
Loading