-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into dbaric99/mobile-navigation-and-router
# Conflicts: # apps/app/package.json # apps/app/src/App.tsx
- Loading branch information
Showing
57 changed files
with
1,644 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -80,4 +80,4 @@ | |
"breakpoints": true | ||
} | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
.wrapper { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: flex-start; | ||
gap: 4px; | ||
position: relative; | ||
|
||
.label { | ||
@include paragraph-14; | ||
color: $black-50; | ||
} | ||
|
||
.mainButton { | ||
@include paragraph-16; | ||
background-color: $black-10; | ||
outline: none; | ||
border: none; | ||
cursor: pointer; | ||
width: 100%; | ||
|
||
box-sizing: border-box; | ||
padding: 16px; | ||
border-radius: 4px; | ||
|
||
display: flex; | ||
justify-content: space-between; | ||
align-items: center; | ||
gap: 8px; | ||
|
||
transition: box-shadow 200ms; | ||
|
||
.arrow { | ||
transition: 200ms; | ||
} | ||
|
||
&.isOpen { | ||
box-shadow: inset 0 0 0 1px $black-30; | ||
|
||
.arrow { | ||
rotate: 180deg; | ||
} | ||
} | ||
|
||
&.isError { | ||
box-shadow: inset 0 0 0 1px $error-light; | ||
} | ||
} | ||
|
||
.errorLabel { | ||
@include paragraph-14; | ||
color: $error-light; | ||
} | ||
|
||
.optionsWrapper { | ||
box-sizing: border-box; | ||
padding: 16px; | ||
box-shadow: 0px 4px 16px 0px rgba(0, 0, 0, 0.12); | ||
background-color: white; | ||
border-radius: 4px; | ||
position: absolute; | ||
top: 86px; | ||
width: 100%; | ||
z-index: 100; | ||
|
||
.innerContainer { | ||
display: block; | ||
width: 100%; | ||
box-sizing: border-box; | ||
|
||
max-height: 310px; | ||
overflow-y: auto; | ||
|
||
&::-webkit-scrollbar { | ||
width: 4px; | ||
border-radius: 100px; | ||
} | ||
|
||
&::-webkit-scrollbar-track { | ||
background: $black-10; | ||
border-radius: 100px; | ||
} | ||
|
||
&::-webkit-scrollbar-thumb { | ||
background: $primary-black; | ||
border-radius: 100px; | ||
} | ||
|
||
&::-webkit-scrollbar-thumb:hover { | ||
background: $primary-black; | ||
} | ||
|
||
.divider { | ||
@include dottedBreak(rgba(23, 22, 21, 0.65)); | ||
height: 4px; | ||
margin-bottom: 16px; | ||
margin-top: 8px; | ||
} | ||
|
||
.option { | ||
background: none; | ||
outline: none; | ||
border: none; | ||
@include paragraph-16; | ||
margin: 0; | ||
padding: 0; | ||
text-align: left; | ||
cursor: pointer; | ||
width: 100%; | ||
|
||
&.selected { | ||
color: $black-30; | ||
cursor: default; | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
import { useRef, useState } from 'react'; | ||
import React from 'react'; | ||
import c from './Dropdown.module.scss'; | ||
import { DropdownOption } from './DropdownOption'; | ||
import ArrowIcon from '../../assets/icons/arrow-down-1.svg'; | ||
import clsx from 'clsx'; | ||
import { useClickOutside } from '../../hooks/useClickOutside'; | ||
|
||
type DropdownProps = { | ||
label: string; | ||
placeholder: string; | ||
options: DropdownOption[]; | ||
setOption: (option: DropdownOption) => void; | ||
selectedOption: DropdownOption | undefined; | ||
errorLabel?: string; | ||
showError?: boolean; | ||
width?: string; | ||
hasError?: boolean; | ||
}; | ||
|
||
const Dropdown = ({ | ||
label, | ||
placeholder, | ||
options, | ||
setOption, | ||
selectedOption, | ||
errorLabel, | ||
width = 'auto', | ||
hasError = false, | ||
}: DropdownProps) => { | ||
const [isOpen, setIsOpen] = useState(false); | ||
const dropdownRef = useRef(null); | ||
|
||
const toggle = () => { | ||
setIsOpen(!isOpen); | ||
}; | ||
|
||
function handleOptionSelected(option: DropdownOption) { | ||
setOption(option); | ||
setIsOpen(false); | ||
} | ||
|
||
useClickOutside(dropdownRef, () => setIsOpen(false)); | ||
|
||
const widthStyle = { width: width }; | ||
const showError = (hasError || !selectedOption?.value) && !isOpen; | ||
|
||
return ( | ||
<div className={c.wrapper} style={widthStyle} ref={dropdownRef}> | ||
{label && <label className={c.label}>{label}</label>} | ||
|
||
<button | ||
className={clsx({ | ||
[c.mainButton]: true, | ||
[c.isOpen]: isOpen, | ||
[c.isError]: showError, | ||
})} | ||
onClick={toggle}> | ||
{selectedOption?.label || placeholder} | ||
<img className={c.arrow} src={ArrowIcon} alt='arrow' /> | ||
</button> | ||
|
||
{showError && <div className={c.errorLabel}>{errorLabel}</div>} | ||
|
||
{isOpen && ( | ||
<div className={c.optionsWrapper}> | ||
<div className={c.innerContainer}> | ||
{options.map((option, i) => ( | ||
<React.Fragment key={option.value}> | ||
{i !== 0 && <div className={c.divider} key={i}></div>} | ||
<button | ||
disabled={option.value === selectedOption?.value} | ||
className={clsx({ | ||
[c.option]: true, | ||
[c.selected]: option.value === selectedOption?.value, | ||
})} | ||
key={option.value} | ||
onClick={() => handleOptionSelected(option)}> | ||
{option.label} | ||
</button> | ||
</React.Fragment> | ||
))} | ||
</div> | ||
</div> | ||
)} | ||
</div> | ||
); | ||
}; | ||
|
||
export default Dropdown; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export type DropdownOption = { | ||
value: string; | ||
label: string; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import Dropdown from './Dropdown'; | ||
|
||
export default Dropdown; |
Oops, something went wrong.