-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
) Co-authored-by: Ilya Bondar <[email protected]>
- Loading branch information
1 parent
ba3892a
commit a528357
Showing
18 changed files
with
1,010 additions
and
41 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,4 +12,4 @@ dist | |
|
||
.github | ||
helm | ||
__tests__ | ||
__tests__ |
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 |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import { IconChevronDown } from '@tabler/icons-react'; | ||
import { MouseEvent, useState } from 'react'; | ||
|
||
import { useTranslation } from 'next-i18next'; | ||
|
||
import classNames from 'classnames'; | ||
|
||
import { FiltersTypes } from '@/src/types/share'; | ||
import { Translation } from '@/src/types/translation'; | ||
|
||
import { Menu, MenuItem } from '../../Common/DropdownMenu'; | ||
|
||
interface FilterTypeProps { | ||
id: string; | ||
filterTypes: string[]; | ||
selectedType: string; | ||
onChangeFilterType: (filterType: FiltersTypes) => void; | ||
} | ||
|
||
export function FilterTypeSelect({ | ||
id, | ||
filterTypes, | ||
selectedType, | ||
onChangeFilterType, | ||
}: FilterTypeProps) { | ||
const [isOpen, setIsOpen] = useState(false); | ||
|
||
const { t } = useTranslation(Translation.SideBar); | ||
|
||
const onChangeHandler = (e: MouseEvent<HTMLButtonElement>) => { | ||
onChangeFilterType(e.currentTarget.value as FiltersTypes); | ||
setIsOpen(false); | ||
}; | ||
|
||
return ( | ||
<div | ||
data-qa={`filter-selector-${id}`} | ||
className="h-[38px] w-full max-w-[140px] grow rounded border border-primary focus-within:border-accent-primary focus:border-accent-primary" | ||
> | ||
<Menu | ||
className="w-full px-3" | ||
onOpenChange={setIsOpen} | ||
trigger={ | ||
<div className="flex items-center justify-between gap-2"> | ||
{selectedType} | ||
<IconChevronDown | ||
data-qa={`open-filter-dropdown-${id}`} | ||
className={classNames( | ||
'shrink-0 text-primary transition-all', | ||
isOpen && 'rotate-180', | ||
)} | ||
width={18} | ||
height={18} | ||
/> | ||
</div> | ||
} | ||
> | ||
<div className="bg-layer-3"> | ||
{filterTypes.map((filterType) => ( | ||
<MenuItem | ||
key={filterType} | ||
className="max-w-[350px] hover:bg-accent-primary-alpha" | ||
item={t(filterType)} | ||
value={filterType} | ||
onClick={onChangeHandler} | ||
/> | ||
))} | ||
</div> | ||
</Menu> | ||
</div> | ||
); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { ChangeEvent, useCallback } from 'react'; | ||
|
||
interface RegexParamInputProps { | ||
regEx: string; | ||
onRegExChange: (regExp: string) => void; | ||
} | ||
|
||
export function RegexParamInput({ | ||
regEx, | ||
onRegExChange, | ||
}: RegexParamInputProps) { | ||
const handleRegExChange = useCallback( | ||
(e: ChangeEvent<HTMLInputElement>) => { | ||
onRegExChange(e.target.value); | ||
}, | ||
[onRegExChange], | ||
); | ||
|
||
return ( | ||
<div className="flex w-full flex-wrap rounded border border-primary p-1 focus-within:border-accent-primary"> | ||
<input | ||
className="w-full bg-transparent py-1 pl-2 outline-none placeholder:text-secondary" | ||
type="text" | ||
placeholder={'Enter regular expression...'} | ||
value={regEx} | ||
onChange={handleRegExChange} | ||
/> | ||
</div> | ||
); | ||
} |
Oops, something went wrong.