From 605000cd3915fe3cced0b1cba72a99c0a8b74686 Mon Sep 17 00:00:00 2001 From: tal-rofe Date: Tue, 16 Aug 2022 11:57:05 +0300 Subject: [PATCH] =?UTF-8?q?feat:=20=F0=9F=94=A5=20add=20EDSelect?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit add EDSelect --- apps/frontend/src/assets/icons.ts | 8 +- .../ui/EDSelect/EDSelect.module.scss | 78 +++++++------------ .../src/components/ui/EDSelect/EDSelect.tsx | 16 ++-- .../components/ui/EDSelect/EDSelect.view.tsx | 67 +++++++--------- 4 files changed, 68 insertions(+), 101 deletions(-) diff --git a/apps/frontend/src/assets/icons.ts b/apps/frontend/src/assets/icons.ts index d577c893b..cd7099f47 100644 --- a/apps/frontend/src/assets/icons.ts +++ b/apps/frontend/src/assets/icons.ts @@ -24,13 +24,7 @@ const icons = { arrowRight: [ '13 22', ` - - `, - ], - arrowDown: [ - '13 8', - ` - + `, ], }; diff --git a/apps/frontend/src/components/ui/EDSelect/EDSelect.module.scss b/apps/frontend/src/components/ui/EDSelect/EDSelect.module.scss index 2ed25a661..0bd72db6e 100644 --- a/apps/frontend/src/components/ui/EDSelect/EDSelect.module.scss +++ b/apps/frontend/src/components/ui/EDSelect/EDSelect.module.scss @@ -1,81 +1,61 @@ .container { position: relative; - display: flex; - flex-direction: column; - align-items: center; - justify-content: space-between; - border-radius: 10px; - box-shadow: (0 11.4496px 15.6131px #0000000d); - inset-inline-end: 0; + width: 200px; - .selectedOptionsVisible { + .buttonContainer { display: flex; align-items: center; justify-content: space-between; - height: 100%; + width: 100%; padding: 10px 14px; - white-space: nowrap; background-color: #fefefe; + border: 2px solid #e7e7e7; + + &--tooltipIsVisible { + border-start-start-radius: 10px; + border-start-end-radius: 10px; + } + + &--tooltipIsInvisible { + border-radius: 10px; + } &__text { - width: inherit; - overflow: hidden; font-size: 1.5rem; font-weight: 360; color: #4b4a65; - text-overflow: ellipsis; - white-space: no-wrap; } - .moreOptionsButton { - &__arrowDown { - width: 11px; - height: 8px; - fill: transparent; - stroke: #202428; - } - - &__arrowRight { - width: 8px; - height: 11px; - fill: transparent; - stroke: #202428; + &__arrow { + width: auto; + height: 8px; + fill: transparent; + stroke: #202428; + stroke-linecap: round; + stroke-width: 2; + transition: transform 0.3s ease; + + &--tooltipIsVisible { + transform: rotate(90deg); } } } - .selectedOptionsInvisible { - position: absolute; - top: 40px; - z-index: 1; + .optionsContainer { display: flex; flex-direction: column; align-items: flex-start; - justify-content: space-between; padding: 10px 14px; - white-space: nowrap; background-color: #fefefe; - border-radius: 0 0 10px 10px; - - &__divider { - width: 100%; - margin-bottom: 9px; - border: 1px solid #e7e7e7; - } + border: 2px solid #e7e7e7; + border-top: none; + border-end-start-radius: 10px; + border-end-end-radius: 10px; &__option { - width: calc(100% - 20px); - overflow: hidden; font-size: 1.5rem; font-weight: 360; color: #4b4a65; - text-align: left; - text-overflow: ellipsis; - white-space: no-wrap; - } - - &__option:not(:last-child) { - margin-bottom: 5px; } } } diff --git a/apps/frontend/src/components/ui/EDSelect/EDSelect.tsx b/apps/frontend/src/components/ui/EDSelect/EDSelect.tsx index faf71be79..ed9f45484 100644 --- a/apps/frontend/src/components/ui/EDSelect/EDSelect.tsx +++ b/apps/frontend/src/components/ui/EDSelect/EDSelect.tsx @@ -5,11 +5,11 @@ import { useClickOutside } from '@/hooks/click-outside'; import EdSelectView from './EDSelect.view'; interface IProps { - readonly defaultValue?: string; readonly className?: string; + readonly placeholder?: string; + readonly options: string[]; readonly selectedOptionIndex: number | null; - readonly optionsList: string[]; - readonly onSelect: (index: number) => void; + readonly onOptionSelect: (index: number) => void; } const EDSelect: React.FC = (props: React.PropsWithChildren) => { @@ -19,21 +19,21 @@ const EDSelect: React.FC = (props: React.PropsWithChildren) => { toggleVisibility: toggleTooltipVisibility, } = useClickOutside(false); - const onSelect = (index: number) => { - props.onSelect(index); + const onOptionSelect = (index: number) => { + props.onOptionSelect(index); toggleTooltipVisibility(); }; return ( ); }; diff --git a/apps/frontend/src/components/ui/EDSelect/EDSelect.view.tsx b/apps/frontend/src/components/ui/EDSelect/EDSelect.view.tsx index 856c6a357..1714d3eaa 100644 --- a/apps/frontend/src/components/ui/EDSelect/EDSelect.view.tsx +++ b/apps/frontend/src/components/ui/EDSelect/EDSelect.view.tsx @@ -1,62 +1,55 @@ import React from 'react'; -import { concatDiverseClasses } from '@/utils/component'; +import { concatClasses, concatDiverseClasses } from '@/utils/component'; import EDSvg from '@/ui/EDSvg'; import classes from './EDSelect.module.scss'; interface IProps { - readonly defaultValue?: string; readonly className?: string; + readonly placeholder?: string; + readonly options: string[]; readonly selectedOptionIndex: number | null; - readonly optionsList: string[]; readonly tooltopRef: React.RefObject; readonly isTooltipVisible: boolean; readonly toggleTooltipVisibility: () => void; - readonly onSelect: (index: number) => void; + readonly onOptionSelect: (index: number) => void; } const EDSelectView: React.FC = (props: React.PropsWithChildren) => { - const visibleClass = concatDiverseClasses(classes['selectedOptionsVisible'], props.className); - const inVisibleClass = concatDiverseClasses(classes['selectedOptionsInvisible'], props.className); + const containerClasses = concatDiverseClasses(classes['container'], props.className); + + const buttonContainerClasses = concatClasses( + classes, + 'buttonContainer', + props.isTooltipVisible ? 'buttonContainer--tooltipIsVisible' : 'buttonContainer--tooltipIsInvisible', + ); + + const selectArrowIconClasses = concatClasses( + classes, + 'buttonContainer__arrow', + props.isTooltipVisible ? 'buttonContainer__arrow--tooltipIsVisible' : null, + ); + + const selectText = props.selectedOptionIndex + ? props.options[props.selectedOptionIndex] + : props.placeholder ?? props.options[0]; return ( -
-
- - {props.selectedOptionIndex !== null - ? props.optionsList[props.selectedOptionIndex] - : props.defaultValue} - +
+ -
+ + {props.isTooltipVisible && ( -
- {props.optionsList.map((option, index) => ( +
+ {props.options.map((option, index) => (