Skip to content

Commit

Permalink
feat: add sheet column, fix: ui kit
Browse files Browse the repository at this point in the history
  • Loading branch information
mnenie committed Aug 1, 2024
1 parent 4b34baf commit df3224d
Show file tree
Hide file tree
Showing 10 changed files with 144 additions and 4 deletions.
5 changes: 5 additions & 0 deletions src/features/kanban/config/validation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import * as z from 'zod';

export const validationColumnRules = z.object({
name: z.string({ required_error: 'Name is a required field' })
});
Original file line number Diff line number Diff line change
@@ -1,17 +1,39 @@
<script setup lang="ts">
import { ref } from 'vue';
import { useDark } from '@vueuse/core';
import { useI18n } from 'vue-i18n';
import { Plus } from 'lucide-vue-next';
import { UiSheet, type SheetElement } from '@/shared/ui';
import FormCreation from './FormCreation.vue';
const isDark = useDark();
const { t } = useI18n();
const sheetColumn = ref<SheetElement | null>(null);
const open = () => {
if (sheetColumn.value) {
sheetColumn.value.open();
}
};
</script>

<template>
<div class="text-sm" :class="$style.block">
<div class="text-sm" :class="$style.block" @click="open">
<Plus :size="16" :color="isDark ? 'var(--zinc-300)' : 'var(--zinc-500)'" />
{{ t('kanban.new') }}
</div>
<UiSheet ref="sheetColumn">
<template #header>
<p class="text-lg" style="font-weight: 500">{{ t('kanban.sheet.column.title') }}</p>
<span :class="[$style.desc, 'text-sm']">
{{ t('kanban.sheet.column.description') }}
</span>
</template>
<template #default>
<FormCreation />
</template>
</UiSheet>
</template>

<style module lang="scss">
Expand All @@ -31,10 +53,17 @@ const { t } = useI18n();
font-weight: 500;
}
.desc {
color: var(--zinc-500);
}
:global(html.dark) {
.block {
background-color: rgba(33, 33, 33, 0.6);
color: var(--zinc-200);
}
.desc {
color: var(--zinc-300);
}
}
</style>
65 changes: 65 additions & 0 deletions src/features/kanban/ui/add-column/FormCreation.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<script setup lang="ts">
import { useI18n } from 'vue-i18n';
import { useField, useForm } from 'vee-validate';
import { toTypedSchema } from '@vee-validate/zod';
import { UiButton, UiInput } from '@/shared/ui';
import { validationColumnRules } from '../../config/validation';
const validationSchema = toTypedSchema(validationColumnRules);
const { t } = useI18n();
const { handleSubmit, errors } = useForm({
validationSchema
});
const { value: name } = useField('name');
const createColumn = handleSubmit((values) => {
// create new column
});
</script>
<template>
<form @submit.prevent="createColumn">
<div :class="$style.form_container">
<div v-auto-animate :class="$style.field">
<label class="text-sm" for="name">{{ t('kanban.sheet.column.form.label') }}</label>
<UiInput id="name" v-model="name" :placeholder="t('kanban.sheet.column.form.placeholder')" />
<span v-if="errors.name" class="text-xs">{{ errors.name }}</span>
</div>
<UiButton style="width: 100%" type="submit"> {{ t('kanban.sheet.column.form.submit') }} </UiButton>
</div>
</form>
</template>

<style module lang="scss">
@import '@/app/styles/mixins';
.form_container {
display: grid;
gap: 24px;
.field {
display: grid;
justify-items: flex-start;
gap: 8px;
& label {
color: var(--zinc-950);
font-weight: 500 !important;
}
& span {
color: var(--destructive);
}
}
}
:global(html.dark) {
.form_container {
.field {
& label {
color: var(--zinc-200);
}
}
}
}
</style>
3 changes: 3 additions & 0 deletions src/features/kanban/ui/add-column/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import AddColumn from './AddColumn.vue';

export { AddColumn };
2 changes: 1 addition & 1 deletion src/features/kanban/ui/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import AddColumn from './AddColumn.vue';
import DragCards from './DragCards.vue';
import DragColumns from './DragColumns.vue';
import SettingsSheet from './SettingsSheet.vue';
import SortingItems from './SortingItems.vue';
import { AddColumn } from './add-column';
import RemoveBoard from './RemoveBoard.vue';

export { AddColumn, DragCards, DragColumns, SortingItems, SettingsSheet, RemoveBoard };
11 changes: 11 additions & 0 deletions src/shared/lib/i18n/locales/en-US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,17 @@ export default {
new: 'Add new column',
cards: {
add: 'Add card'
},
sheet: {
column: {
title: 'Add new column',
description: 'When creating a new column, you can create cards and use the kanban board.',
form: {
label: 'Column name',
placeholder: 'Enter the column name',
submit: 'Create column'
}
}
}
}
};
11 changes: 11 additions & 0 deletions src/shared/lib/i18n/locales/ru-RU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,17 @@ export default {
new: 'Добавить новую колонку',
cards: {
add: 'Добавить карточку'
},
sheet: {
column: {
title: 'Добавить новую колонку',
description: 'При создании новой колонки вы можете создавать карточки и использовать доску канбан.',
form: {
label: 'Название колонки',
placeholder: 'Введите название колонки',
submit: 'Создать колонку'
}
}
}
}
};
11 changes: 11 additions & 0 deletions src/shared/lib/i18n/locales/zh-CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,17 @@ export default {
new: '添加新列',
cards: {
add: '添加卡片'
},
sheet: {
column: {
title: '添加新列',
description: '创建新列时,您可以创建卡片并使用看板。',
form: {
label: '列名称',
placeholder: '输入列名称',
submit: '创建列'
}
}
}
}
};
2 changes: 1 addition & 1 deletion src/shared/ui/sheet/UiSheet.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ interface Props {
const props = withDefaults(defineProps<Props>(), {
overlay: true,
maxWidth: 640,
maxWidth: 450,
transitionDuration: 0.35,
overlayClickClose: true
});
Expand Down
7 changes: 6 additions & 1 deletion src/widgets/kanban/ui/InfoPart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { UserAvatar } from '@/entities/user';
import type { Board } from '@/entities/board';
import { UiBadge, UiButton } from '@/shared/ui';
import { Users } from 'lucide-vue-next';
import { toast } from 'vue-sonner';
const props = defineProps<{
board: Board;
Expand All @@ -18,6 +19,10 @@ const extraUsers = computed(() => {
const previewUsers = computed(() => {
return props.board.users.slice(0, 4);
});
const toggleVisible = () => {
toast.info('Now this feature in dev mode')
}
</script>

<template>
Expand All @@ -31,7 +36,7 @@ const previewUsers = computed(() => {
<span class="text-sm">{{ board.status }}</span>
</div>
<div :class="$style.line" />
<div :class="$style.visible">
<div :class="$style.visible" @click="toggleVisible">
<UiButton variant="secondary" size="sm" :class="$style.btn">
<Users :size="16" />
Team Visible
Expand Down

0 comments on commit df3224d

Please sign in to comment.