Skip to content

Commit 82277f9

Browse files
authored
Merge pull request #6 from profcomff/VuSearch
VuSearch ui-kit element
2 parents e9d6ae6 + 6cf38c9 commit 82277f9

File tree

12 files changed

+134
-28
lines changed

12 files changed

+134
-28
lines changed

.storybook/main.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const config: StorybookConfig = {
88
'@storybook/addon-onboarding',
99
'@storybook/addon-a11y',
1010
'@storybook/addon-vitest',
11+
'storybook-addon-pseudo-states',
1112
],
1213
framework: {
1314
name: '@storybook/vue3-vite',

.storybook/preview.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import 'vuetify/styles';
12
import { vuetify } from '@/vuetify';
23
import { type Preview, setup } from '@storybook/vue3-vite';
34
import { withVuetifyTheme } from './withVuetifyTheme.decorator';

README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,17 @@ pnpm sb
6464
2. Создай в этой папке файл `Vu{НазваниеКомпонента}.vue` и в нем описываем шаблон компонента.
6565
3. Стилизуй компонент с помощью классов vuetify.
6666
4. Опиши модели и пропы, которые может принимать компонент. С помощью /\*\* \*/ опиши пропы и модели (так автоматически генерируется документация).
67-
5. В этой же папке создай `Vu{НазваниеКомпонента}.stories.ts`.
68-
6. В этом файле опиши meta, а потом истории -- различные состояния и опции компонента. Подробнее смотри в туториале Storybook или в уже написанных компонентах.
67+
5. Чтобы отразить псевдо-состяния (hover, active и т.д.), напиши в истории:
68+
```ts
69+
parameters: {
70+
pseudo: {
71+
hover: true,
72+
}
73+
}
74+
```
75+
или посмотри [доку](https://storybook.js.org/addons/storybook-addon-pseudo-states) аддона.
76+
6. В этой же папке создай `Vu{НазваниеКомпонента}.stories.ts`.
77+
7. В этом файле опиши meta, а потом истории -- различные состояния и опции компонента. Подробнее смотри в туториале Storybook или в уже написанных компонентах.
6978

7079
### Пулл-реквест
7180

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
"prettier": "^3.5.2",
6161
"sass": "^1.93.2",
6262
"sass-loader": "^16.0.6",
63+
"storybook-addon-pseudo-states": "^10.0.3",
6364
"stylelint": "^16.15.0",
6465
"stylelint-config-recommended": "^15.0.0",
6566
"stylelint-config-recommended-vue": "^1.6.0",

pnpm-lock.yaml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import type { Meta, StoryObj } from '@storybook/vue3-vite';
2+
import { fn } from 'storybook/test';
3+
import VuSearch from './VuSearch.vue';
4+
5+
const meta = {
6+
title: 'Viribus Unitis/Search',
7+
component: VuSearch,
8+
tags: ['autodocs'],
9+
args: {
10+
'onClick:filter': fn(),
11+
'onUpdate:modelValue': fn(),
12+
placeholder: 'Поиск преподавателя',
13+
},
14+
argTypes: {
15+
modelValue: {
16+
control: 'text',
17+
description: 'Значение v-model',
18+
},
19+
placeholder: {
20+
control: 'text',
21+
description: 'Текст плейсхолдера',
22+
},
23+
},
24+
} satisfies Meta<typeof VuSearch>;
25+
26+
export default meta;
27+
type Story = StoryObj<typeof meta>;
28+
29+
export const Default: Story = {
30+
args: {
31+
modelValue: '',
32+
},
33+
};
34+
35+
export const WithValue: Story = {
36+
args: {
37+
modelValue: 'Поисковый запрос',
38+
},
39+
};
40+
41+
export const Hovered: Story = {
42+
parameters: {
43+
pseudo: {
44+
hover: true,
45+
},
46+
},
47+
};
48+
49+
export const Active: Story = {
50+
args: {
51+
modelValue: 'Печатаем...',
52+
},
53+
play: ({ canvasElement }) => {
54+
const field = canvasElement.querySelector('.v-field');
55+
field?.classList.add('v-field--focused');
56+
},
57+
};

src/components/Search/VuSearch.vue

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<script setup lang="ts">
2+
const modelValue = defineModel<string>();
3+
4+
defineEmits<{
5+
(e: 'update:modelValue', value: string): void;
6+
(e: 'click:filter'): void;
7+
}>();
8+
9+
defineProps<{
10+
placeholder?: string;
11+
}>();
12+
</script>
13+
14+
<template>
15+
<v-text-field
16+
v-model="modelValue"
17+
class="text-body-1"
18+
:placeholder="placeholder"
19+
hide-details="auto"
20+
density="compact"
21+
variant="outlined"
22+
prepend-inner-icon="mdi-magnify"
23+
append-inner-icon="mdi-filter-variant"
24+
@click:append-inner="$emit('click:filter')"
25+
/>
26+
</template>

src/components/button/VuButton.stories.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,10 @@ export default meta;
1616

1717
type Story = StoryObj<typeof meta>;
1818

19-
export const Default: Story = {};
19+
export const Default: Story = {
20+
parameters: {
21+
pseudo: {
22+
active: true,
23+
},
24+
},
25+
};

src/components/checkBox/VuCheckbox.stories.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Meta, StoryObj } from '@storybook/vue3-vite';
22
import VuCheckbox from './VuCheckbox.vue';
33

44
const meta = {
5-
title: 'checkBox/VuCheckbox',
5+
title: 'Viribus Unitis/VuCheckbox',
66
component: VuCheckbox,
77
} satisfies Meta<typeof VuCheckbox>;
88

@@ -14,20 +14,20 @@ export const Default: Story = {
1414
args: {
1515
disabled: false,
1616
modelValue: false,
17-
label: "Оценок нет"
17+
label: 'Оценок нет',
1818
},
1919
};
2020
export const Active: Story = {
2121
args: {
2222
disabled: false,
2323
modelValue: true,
24-
label: "Оценок нет"
24+
label: 'Оценок нет',
2525
},
2626
};
2727
export const Disabled: Story = {
2828
args: {
2929
disabled: true,
3030
modelValue: true,
31-
label: "Оценок нет"
31+
label: 'Оценок нет',
3232
},
3333
};
Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,23 @@
11
<script setup lang="ts">
2-
import { computed } from 'vue';
2+
defineProps({
3+
modelValue: {
4+
type: Boolean,
5+
default: false,
6+
},
7+
label: String,
8+
disabled: Boolean,
9+
});
310
4-
interface Props {
5-
disabled: boolean;
6-
modelValue: boolean;
7-
label: string;
8-
}
9-
const props = defineProps<Props>();
10-
const emit = defineEmits(['update:modelValue'])
11-
12-
const value = computed({
13-
get: () => props.modelValue,
14-
set: (value) => emit('update:modelValue', value)
15-
})
11+
defineEmits(['update:modelValue']);
1612
</script>
1713

1814
<template>
19-
<v-checkbox
20-
density="compact"
21-
:label="label"
22-
v-model="value"
23-
:disabled="disabled">
24-
</v-checkbox>
15+
<v-checkbox
16+
density="compact"
17+
:label="label"
18+
:model-value="modelValue"
19+
@update:model-value="$emit('update:modelValue', $event)"
20+
:disabled="disabled"
21+
>
22+
</v-checkbox>
2523
</template>

0 commit comments

Comments
 (0)