From 4c0fb8ea535beaa1cfc6fa3ff40b602ea7125d77 Mon Sep 17 00:00:00 2001 From: Nelya Klyusa <77396171+nelyaklyusa@users.noreply.github.com> Date: Thu, 9 May 2024 16:17:44 +0300 Subject: [PATCH] add components (#15) --- package.json | 4 +- src/assets/arrow-left-primary.svg | 5 + src/assets/arrow-right-primary.svg | 5 + src/assets/upload.svg | 5 + .../BaseAccordion/BaseAccordion.vue | 4 +- .../BaseAccordion/BaseAccordionItem.vue | 10 +- src/components/BaseAccordion/index.sass | 4 + .../BaseBreadcrumbs/BaseBreadcrumbs.vue | 68 ++ src/components/BaseBreadcrumbs/index.sass | 2 + src/components/BaseButton/BaseButton.vue | 4 +- .../BaseContentSwitcher.vue | 83 +++ src/components/BaseContentSwitcher/index.sass | 2 + src/components/BaseContentSwitcher/index.ts | 4 + src/components/BaseContentSwitcher/types.ts | 4 + src/components/BaseDropdown/BaseDropdown.vue | 85 +++ .../BaseDropdown/assets/chevron-down.svg | 5 + src/components/BaseDropdown/index.sass | 3 + src/components/BaseFilter/BaseFilter.vue | 184 ++++++ src/components/BaseFilter/filter.svg | 5 + src/components/BaseFilter/index.sass | 2 + src/components/BaseForm/index.sass | 2 + .../BaseFormCheckbox/BaseFormCheckbox.vue | 6 +- .../BaseFormCheckboxGroup.vue | 13 +- .../BaseFormGroup/BaseFormGroup.vue | 108 ++-- src/components/BaseFormGroup/index.sass | 2 + .../BaseFormInput/BaseFormInput.vue | 10 +- .../BaseFormInputSearch.vue | 69 ++ src/components/BaseFormInputSearch/index.sass | 3 + src/components/BaseFormInputSearch/index.ts | 4 + .../BaseFormRadio/BaseFormRadio.vue | 6 +- src/components/BaseFormRadio/index.sass | 6 +- .../BaseFormSelect/BaseFormSelect.vue | 15 +- .../BaseFormTextarea/BaseFormTextarea.vue | 5 +- src/components/BaseFormTextarea/index.sass | 13 +- .../BaseModal/BaseModal.component.ts | 89 +++ src/components/BaseModal/BaseModal.vue | 86 +++ src/components/BaseModal/BaseModalLayout.vue | 309 +++++++++ src/components/BaseModal/blocked-body.ts | 55 ++ src/components/BaseModal/index.sass | 2 + src/components/BaseModal/index.ts | 1 + src/components/BaseModal/useModal.ts | 167 +++++ .../BaseProgressBar/BaseProgressBar.vue | 61 ++ src/components/BaseProgressBar/index.sass | 2 + src/components/BaseSkeleton/BaseSkeleton.vue | 60 +- src/components/BaseSkeleton/index.sass | 2 + src/components/BaseSpinner/BaseSpinner.vue | 3 +- src/components/BaseSpinner/index.sass | 2 + src/components/BaseStepper/BaseStepper.vue | 159 +++++ src/components/BaseStepper/index.sass | 2 + src/components/BaseTable/BaseTable.vue | 32 +- src/components/BaseTable/index.sass | 16 +- src/components/BaseTag/BaseTag.vue | 4 +- src/components/BaseTimeline/BaseTimeline.vue | 40 ++ .../BaseTimeline/BaseTimelineCard.vue | 168 +++++ .../BaseTimeline/BaseTimelineCircle.vue | 88 +++ .../BaseTimeline/BaseTimelineItem.vue | 126 ++++ src/components/BaseTimeline/assets/check.svg | 5 + src/components/BaseTimeline/index.sass | 2 + src/components/BaseTooltip/BaseTooltip.vue | 605 ++++++++---------- src/components/BaseTooltip/index.sass | 2 + src/components/BaseUploader/BaseUploader.vue | 240 +++++++ src/components/BaseUploader/file.svg | 5 + src/components/BaseUploader/index.sass | 2 + src/components/BaseUploader/upload.svg | 5 + .../CardCheckmarked/CardCheckmarked.vue | 94 +++ .../common/CardCheckmarked/assets/check.svg | 5 + .../common/CardCheckmarked/index.sass | 2 + .../common/CardCheckmarked/types.ts | 6 + .../common/SliderSwiper/SliderSwiper.vue | 79 +++ src/components/common/SliderSwiper/index.sass | 2 + .../SliderWithPaginationAutoPlay.vue | 114 ++++ .../SliderWithPaginationAutoPlay/index.sass | 2 + .../WhatOurClientsSay/WhatOurClientsSay.vue | 69 ++ .../WhatOurClientsSaySlider.vue | 112 ++++ .../common/WhatOurClientsSay/index.sass | 2 + .../common/WhatOurClientsSay/utils.ts | 39 ++ src/helpers/blocked-body.ts | 55 ++ src/styles/_fonts.sass | 14 +- src/styles/_global.sass | 7 +- yarn.lock | 82 ++- 80 files changed, 3308 insertions(+), 466 deletions(-) create mode 100644 src/assets/arrow-left-primary.svg create mode 100644 src/assets/arrow-right-primary.svg create mode 100644 src/assets/upload.svg create mode 100644 src/components/BaseBreadcrumbs/BaseBreadcrumbs.vue create mode 100644 src/components/BaseBreadcrumbs/index.sass create mode 100644 src/components/BaseContentSwitcher/BaseContentSwitcher.vue create mode 100644 src/components/BaseContentSwitcher/index.sass create mode 100644 src/components/BaseContentSwitcher/index.ts create mode 100644 src/components/BaseContentSwitcher/types.ts create mode 100644 src/components/BaseDropdown/BaseDropdown.vue create mode 100644 src/components/BaseDropdown/assets/chevron-down.svg create mode 100644 src/components/BaseDropdown/index.sass create mode 100644 src/components/BaseFilter/BaseFilter.vue create mode 100644 src/components/BaseFilter/filter.svg create mode 100644 src/components/BaseFilter/index.sass create mode 100644 src/components/BaseForm/index.sass create mode 100644 src/components/BaseFormGroup/index.sass create mode 100644 src/components/BaseFormInputSearch/BaseFormInputSearch.vue create mode 100644 src/components/BaseFormInputSearch/index.sass create mode 100644 src/components/BaseFormInputSearch/index.ts create mode 100644 src/components/BaseModal/BaseModal.component.ts create mode 100644 src/components/BaseModal/BaseModal.vue create mode 100644 src/components/BaseModal/BaseModalLayout.vue create mode 100644 src/components/BaseModal/blocked-body.ts create mode 100644 src/components/BaseModal/index.sass create mode 100644 src/components/BaseModal/index.ts create mode 100644 src/components/BaseModal/useModal.ts create mode 100644 src/components/BaseProgressBar/BaseProgressBar.vue create mode 100644 src/components/BaseProgressBar/index.sass create mode 100644 src/components/BaseSkeleton/index.sass create mode 100644 src/components/BaseSpinner/index.sass create mode 100644 src/components/BaseStepper/BaseStepper.vue create mode 100644 src/components/BaseStepper/index.sass create mode 100644 src/components/BaseTimeline/BaseTimeline.vue create mode 100644 src/components/BaseTimeline/BaseTimelineCard.vue create mode 100644 src/components/BaseTimeline/BaseTimelineCircle.vue create mode 100644 src/components/BaseTimeline/BaseTimelineItem.vue create mode 100644 src/components/BaseTimeline/assets/check.svg create mode 100644 src/components/BaseTimeline/index.sass create mode 100644 src/components/BaseTooltip/index.sass create mode 100644 src/components/BaseUploader/BaseUploader.vue create mode 100644 src/components/BaseUploader/file.svg create mode 100644 src/components/BaseUploader/index.sass create mode 100644 src/components/BaseUploader/upload.svg create mode 100644 src/components/common/CardCheckmarked/CardCheckmarked.vue create mode 100644 src/components/common/CardCheckmarked/assets/check.svg create mode 100644 src/components/common/CardCheckmarked/index.sass create mode 100644 src/components/common/CardCheckmarked/types.ts create mode 100644 src/components/common/SliderSwiper/SliderSwiper.vue create mode 100644 src/components/common/SliderSwiper/index.sass create mode 100644 src/components/common/SliderWithPaginationAutoPlay/SliderWithPaginationAutoPlay.vue create mode 100644 src/components/common/SliderWithPaginationAutoPlay/index.sass create mode 100644 src/components/common/WhatOurClientsSay/WhatOurClientsSay.vue create mode 100644 src/components/common/WhatOurClientsSay/WhatOurClientsSaySlider.vue create mode 100644 src/components/common/WhatOurClientsSay/index.sass create mode 100644 src/components/common/WhatOurClientsSay/utils.ts create mode 100644 src/helpers/blocked-body.ts diff --git a/package.json b/package.json index e3a0104..925821e 100644 --- a/package.json +++ b/package.json @@ -12,9 +12,11 @@ "build": "storybook build -o dist/" }, "dependencies": { - "@dafcoe/vue-collapsible-panel": "^0.2.0", + "@swoga/vue-collapsible-panel": "^0.3.0", "@vue/compiler-core": "^3.4.19", + "@vueuse/core": "^10.9.0", "sass": "^1.71.1", + "swiper": "^11.1.1", "vite-svg-loader": "^5.1.0", "vue": "^3.4.19", "vue-select": "^4.0.0-beta.6" diff --git a/src/assets/arrow-left-primary.svg b/src/assets/arrow-left-primary.svg new file mode 100644 index 0000000..47e4f0f --- /dev/null +++ b/src/assets/arrow-left-primary.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/src/assets/arrow-right-primary.svg b/src/assets/arrow-right-primary.svg new file mode 100644 index 0000000..7652cfb --- /dev/null +++ b/src/assets/arrow-right-primary.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/src/assets/upload.svg b/src/assets/upload.svg new file mode 100644 index 0000000..94046fb --- /dev/null +++ b/src/assets/upload.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/src/components/BaseAccordion/BaseAccordion.vue b/src/components/BaseAccordion/BaseAccordion.vue index 2057e1e..0a3b78c 100644 --- a/src/components/BaseAccordion/BaseAccordion.vue +++ b/src/components/BaseAccordion/BaseAccordion.vue @@ -1,10 +1,10 @@ diff --git a/src/components/BaseAccordion/BaseAccordionItem.vue b/src/components/BaseAccordion/BaseAccordionItem.vue index f9e291f..7009e9a 100644 --- a/src/components/BaseAccordion/BaseAccordionItem.vue +++ b/src/components/BaseAccordion/BaseAccordionItem.vue @@ -2,10 +2,10 @@ import { withDefaults } from 'vue'; import { VueCollapsiblePanel, -} from '@dafcoe/vue-collapsible-panel'; +} from '@swoga/vue-collapsible-panel'; // IMPORTANT: before using this component you need to install library -// type in the terminal: yarn add @dafcoe/vue-collapsible-panel +// type in the terminal: yarn add @swoga/vue-collapsible-panel withDefaults(defineProps<{ /** @@ -93,6 +93,12 @@ withDefaults(defineProps<{ +mt(.2s) :deep(.vcp__body) height: 0 + background-color: $accordion-item-active-content-background + :deep(.vcp__header) + background-color: $accordion-item-active-header-background + box-shadow: $accordion-item-active-header-box-shadow + z-index: 1 + position: relative &__title-text padding: 12px 16px margin-bottom: 0 diff --git a/src/components/BaseAccordion/index.sass b/src/components/BaseAccordion/index.sass index 3b13150..c8498c2 100644 --- a/src/components/BaseAccordion/index.sass +++ b/src/components/BaseAccordion/index.sass @@ -1,5 +1,6 @@ @import 'UiKit/styles/_colors.sass' @import 'UiKit/styles/_mixins.sass' +@import 'UiKit/styles/_global.sass' $border-color: $gray-30 $border-color-white: $gray-10 @@ -8,3 +9,6 @@ $white-link-color: $gray-10 $link-color: $primary $open-close-icon-fill: $black +$accordion-item-active-header-background: $white +$accordion-item-active-header-box-shadow: $box-shadow-small +$accordion-item-active-content-background: $gray-10 \ No newline at end of file diff --git a/src/components/BaseBreadcrumbs/BaseBreadcrumbs.vue b/src/components/BaseBreadcrumbs/BaseBreadcrumbs.vue new file mode 100644 index 0000000..ecb21da --- /dev/null +++ b/src/components/BaseBreadcrumbs/BaseBreadcrumbs.vue @@ -0,0 +1,68 @@ + + + + + diff --git a/src/components/BaseBreadcrumbs/index.sass b/src/components/BaseBreadcrumbs/index.sass new file mode 100644 index 0000000..6b6f492 --- /dev/null +++ b/src/components/BaseBreadcrumbs/index.sass @@ -0,0 +1,2 @@ +@import 'UiKit/styles/_colors.sass' +@import 'UiKit/styles/_global.sass' diff --git a/src/components/BaseButton/BaseButton.vue b/src/components/BaseButton/BaseButton.vue index f95952d..7452046 100644 --- a/src/components/BaseButton/BaseButton.vue +++ b/src/components/BaseButton/BaseButton.vue @@ -147,7 +147,7 @@ &:hover background-color: $base-button-danger-hover-color &.is--variant-outlined - background-color: transparent + background-color: $white border-style: solid border-width: $base-button-border-width &.is--color-primary @@ -190,7 +190,7 @@ &:hover background-color: rgba($base-button-secondary-color, 0.1) &.is--color-success - color: $base-button-success-color + color: $base-button-success-text-color &:hover background-color: rgba($base-button-success-color, 0.1) &.is--color-warning diff --git a/src/components/BaseContentSwitcher/BaseContentSwitcher.vue b/src/components/BaseContentSwitcher/BaseContentSwitcher.vue new file mode 100644 index 0000000..bb9a0db --- /dev/null +++ b/src/components/BaseContentSwitcher/BaseContentSwitcher.vue @@ -0,0 +1,83 @@ + + + + + diff --git a/src/components/BaseContentSwitcher/index.sass b/src/components/BaseContentSwitcher/index.sass new file mode 100644 index 0000000..f765c89 --- /dev/null +++ b/src/components/BaseContentSwitcher/index.sass @@ -0,0 +1,2 @@ +@import 'UiKit/styles/_colors.sass' +@import 'UiKit/styles/_mixins.sass' diff --git a/src/components/BaseContentSwitcher/index.ts b/src/components/BaseContentSwitcher/index.ts new file mode 100644 index 0000000..eca0c5a --- /dev/null +++ b/src/components/BaseContentSwitcher/index.ts @@ -0,0 +1,4 @@ +import BaseContentSwitcher from './BaseContentSwitcher.vue'; + +export { BaseContentSwitcher }; +export * from './types'; diff --git a/src/components/BaseContentSwitcher/types.ts b/src/components/BaseContentSwitcher/types.ts new file mode 100644 index 0000000..44d3b22 --- /dev/null +++ b/src/components/BaseContentSwitcher/types.ts @@ -0,0 +1,4 @@ +export type Tab = object & { + value: string | number; + label?: string; +}; diff --git a/src/components/BaseDropdown/BaseDropdown.vue b/src/components/BaseDropdown/BaseDropdown.vue new file mode 100644 index 0000000..18d164f --- /dev/null +++ b/src/components/BaseDropdown/BaseDropdown.vue @@ -0,0 +1,85 @@ + + + + + + + diff --git a/src/components/BaseDropdown/assets/chevron-down.svg b/src/components/BaseDropdown/assets/chevron-down.svg new file mode 100644 index 0000000..d0331b6 --- /dev/null +++ b/src/components/BaseDropdown/assets/chevron-down.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/src/components/BaseDropdown/index.sass b/src/components/BaseDropdown/index.sass new file mode 100644 index 0000000..ba26af6 --- /dev/null +++ b/src/components/BaseDropdown/index.sass @@ -0,0 +1,3 @@ +@import 'UiKit/styles/_colors.sass' +@import 'UiKit/styles/_mixins.sass' +@import 'UiKit/styles/_global.sass' diff --git a/src/components/BaseFilter/BaseFilter.vue b/src/components/BaseFilter/BaseFilter.vue new file mode 100644 index 0000000..a330808 --- /dev/null +++ b/src/components/BaseFilter/BaseFilter.vue @@ -0,0 +1,184 @@ + + + + + diff --git a/src/components/BaseFilter/filter.svg b/src/components/BaseFilter/filter.svg new file mode 100644 index 0000000..6ff7a77 --- /dev/null +++ b/src/components/BaseFilter/filter.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/src/components/BaseFilter/index.sass b/src/components/BaseFilter/index.sass new file mode 100644 index 0000000..6b6f492 --- /dev/null +++ b/src/components/BaseFilter/index.sass @@ -0,0 +1,2 @@ +@import 'UiKit/styles/_colors.sass' +@import 'UiKit/styles/_global.sass' diff --git a/src/components/BaseForm/index.sass b/src/components/BaseForm/index.sass new file mode 100644 index 0000000..6b6f492 --- /dev/null +++ b/src/components/BaseForm/index.sass @@ -0,0 +1,2 @@ +@import 'UiKit/styles/_colors.sass' +@import 'UiKit/styles/_global.sass' diff --git a/src/components/BaseFormCheckbox/BaseFormCheckbox.vue b/src/components/BaseFormCheckbox/BaseFormCheckbox.vue index b424af7..122f6f2 100644 --- a/src/components/BaseFormCheckbox/BaseFormCheckbox.vue +++ b/src/components/BaseFormCheckbox/BaseFormCheckbox.vue @@ -102,7 +102,7 @@ function onChange(event: Event) { - diff --git a/src/components/BaseFormGroup/BaseFormGroup.vue b/src/components/BaseFormGroup/BaseFormGroup.vue index 9ba4dec..671b7b1 100644 --- a/src/components/BaseFormGroup/BaseFormGroup.vue +++ b/src/components/BaseFormGroup/BaseFormGroup.vue @@ -4,7 +4,7 @@ import { } from 'vue'; import get from 'lodash/get'; import merge from 'lodash/merge'; -import { resolveRef } from '@/helpers/validation/general'; +import { toRaw } from 'vue'; const props = defineProps<{ label?: string; @@ -14,23 +14,46 @@ const props = defineProps<{ schemaBack?: object; schemaFront?: object; errorText?: string[]; + required?: boolean; }>(); const schema = ref(); -function extractFieldName(path: string): string | null { - const parts = path.split('/'); - if (parts.length > 1) return parts[parts.length - 1]; - if (parts.length === 1) return parts[0]; - return null; +function resolveRef(ref, schema) { + const refPath = ref.replace('#/', '').split('/'); + let currentSchema = schema; + return get(currentSchema, refPath.join('.')); +} + +function isFieldRequiredInSchema(fieldName, schema) { + return schema.required ? schema.required.includes(fieldName) : false; +} + +function getFieldSchema(path, ref, schema) { + if (!path || !ref) return undefined; + const objectFromRefPath = resolveRef(ref, schema); + const pathSegments = path.split('.'); + const firstChild = pathSegments.shift(); + const restSegments = pathSegments.join('.'); + const segment0Property = objectFromRefPath.properties[firstChild]; + if (segment0Property?.$ref) { + return getFieldSchema(restSegments, segment0Property.$ref, schema); + } + return objectFromRefPath; +} + +function isFieldRequiredAtPath(path, schema) { + const parentSchema = getFieldSchema(path, schema.$ref, schema); + if (!parentSchema) return false; + const fieldName = path.split('.').pop(); + return isFieldRequiredInSchema(fieldName, parentSchema); } const required = computed(() => { - if (!props.path) return false; - const fieldName = extractFieldName(props.path); - const schemaObject = resolveRef(schema.value); + if (props.required) return true; + if (!props.path || !schema.value) return false; // eslint-disable-next-line - return schemaObject?.required?.includes(fieldName); + return isFieldRequiredAtPath(props.path, schema.value); }); const errorText = computed(() => { @@ -45,7 +68,9 @@ const errorText = computed(() => { const isError = computed(() => (errorText.value.length > 0)); watch(() => [props.schemaBack, props.schemaFront], () => { - schema.value = merge(props.schemaBack, props.schemaFront); + const schema1 = structuredClone(toRaw(props.schemaBack)) + const schema2 = structuredClone(toRaw(props.schemaFront)) + schema.value = merge(schema1, schema2); }, { immediate: true, deep: true }); @@ -80,37 +105,32 @@ watch(() => [props.schemaBack, props.schemaFront], () => { - diff --git a/src/components/BaseFormGroup/index.sass b/src/components/BaseFormGroup/index.sass new file mode 100644 index 0000000..6b6f492 --- /dev/null +++ b/src/components/BaseFormGroup/index.sass @@ -0,0 +1,2 @@ +@import 'UiKit/styles/_colors.sass' +@import 'UiKit/styles/_global.sass' diff --git a/src/components/BaseFormInput/BaseFormInput.vue b/src/components/BaseFormInput/BaseFormInput.vue index 31fe06f..abbdd02 100644 --- a/src/components/BaseFormInput/BaseFormInput.vue +++ b/src/components/BaseFormInput/BaseFormInput.vue @@ -52,7 +52,10 @@ const moneyFormatOptions = { }, } -const emit = defineEmits<{ (e: 'update:modelValue', value: string): void }>(); +const emit = defineEmits<{ + (e: 'update:modelValue', value: string): void, + (e: 'enter'): void, +}>(); const localValue = ref(''); const focused = ref(false); @@ -131,7 +134,7 @@ function onInput(value: string) { // set filtered value localValue.value = String(value).replace(charsToCheck, ''); if (props.mask) localValue.value = mask.masked(localValue.value); - emit('update:modelValue', returnValue.value); + emit('update:modelValue', returnValue.value.trim()); } function onInputEvent() { @@ -192,6 +195,7 @@ watch(() => props.modelValue, () => onInput(props.modelValue)); @beforeinput="onBeforeInput" @focus="onFocus" @blur="onBlur" + @keypress.enter="emit('enter')" > props.modelValue, () => onInput(props.modelValue)); - diff --git a/src/components/BaseFormInputSearch/index.sass b/src/components/BaseFormInputSearch/index.sass new file mode 100644 index 0000000..825b792 --- /dev/null +++ b/src/components/BaseFormInputSearch/index.sass @@ -0,0 +1,3 @@ +@import 'UiKit/styles/_colors.sass' +@import 'UiKit/styles/_mixins.sass' + diff --git a/src/components/BaseFormInputSearch/index.ts b/src/components/BaseFormInputSearch/index.ts new file mode 100644 index 0000000..06b3c8f --- /dev/null +++ b/src/components/BaseFormInputSearch/index.ts @@ -0,0 +1,4 @@ +import BaseFormInputSearch from './BaseFormInputSearch.vue'; + +export { BaseFormInputSearch }; +export default BaseFormInputSearch; diff --git a/src/components/BaseFormRadio/BaseFormRadio.vue b/src/components/BaseFormRadio/BaseFormRadio.vue index a0e1261..5a33f54 100644 --- a/src/components/BaseFormRadio/BaseFormRadio.vue +++ b/src/components/BaseFormRadio/BaseFormRadio.vue @@ -8,7 +8,7 @@ type FormRadioOption = { }; const props = withDefaults(defineProps<{ - modelValue: string | string[] | number[] + modelValue: string | string[] | number[] | boolean options?: Record | string[] | FormRadioOption[], row?: boolean, disabled?: boolean, @@ -91,7 +91,7 @@ function getLabelValue(option: string | number | FormRadioOption) { tabindex="1" class="base-form-radio__input" v-bind="$attrs" - @change="$emit('update:modelValue', $event.target.value)" + @change="$emit('update:modelValue', selectedOption);" >