-
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.
- Loading branch information
1 parent
6bbbd7a
commit 6622ccd
Showing
6 changed files
with
234 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
.doubleTabSwitcherWrapper { | ||
overflow-x: auto; | ||
width: 100%; | ||
scrollbar-width: 0; | ||
} | ||
.secDoubleTabSwitcher { | ||
display: flex; | ||
align-items: center; | ||
flex-wrap: nowrap; | ||
width: max-content; | ||
} | ||
|
||
.doubleTabSwitcher { | ||
display: flex; | ||
gap: 6px; | ||
align-items: center; | ||
user-select: none; | ||
width: max-content; | ||
flex-wrap: nowrap; | ||
} | ||
|
||
.tab { | ||
height: 34px; | ||
border-radius: 5px; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
cursor: pointer; | ||
padding: 5px 12px; | ||
transition: background-color ease 300ms; | ||
font-size: 14px; | ||
color: rgba(0, 0, 0, 0.8); | ||
line-height: 16px; | ||
letter-spacing: 0.02em; | ||
flex-grow: 1; | ||
} | ||
|
||
.tab:hover { | ||
background-color: rgba(249, 249, 249, 1); | ||
} | ||
.tabActive { | ||
font-size: 14px; | ||
color: rgba(255, 255, 255, 1); | ||
background-color: rgba(89, 127, 255, 1); | ||
} | ||
|
||
.tabActive:hover { | ||
background-color: rgba(89, 127, 255, 0.8); | ||
} | ||
|
||
.ActiveDisabled { | ||
font-size: 14px; | ||
color: rgba(255, 255, 255, 1); | ||
background-color: rgba(89, 127, 255, 0.3); | ||
} | ||
|
||
.ActiveDisabled:hover { | ||
color: rgba(255, 255, 255, 1); | ||
} | ||
|
||
.DisabledNotSelected { | ||
font-size: 14px; | ||
color: rgba(0, 0, 0, 0.3); | ||
} | ||
.DisabledNotSelected:hover { | ||
color: rgba(0, 0, 0, 0.3); | ||
background-color: rgba(255, 255, 255, 1); | ||
} |
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 @@ | ||
export { default as TabSwitcher } from './tabSwitcher'; |
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,47 @@ | ||
import React, { useEffect, useState } from 'react'; | ||
import classNames from 'classnames'; | ||
|
||
import styles from './index.module.css'; | ||
import { TabSwitcherOptions } from '../../../comman/types'; | ||
|
||
type TabSwitcher = { | ||
initialValue?: string; | ||
options: TabSwitcherOptions; | ||
onClick: (value: string) => void; | ||
disabled?: boolean; | ||
}; | ||
|
||
const TabSwitcher = ({ initialValue, options, onClick, disabled }: TabSwitcher): JSX.Element => { | ||
const [current, setCurrent] = useState(initialValue); | ||
|
||
useEffect(() => { | ||
setCurrent(!initialValue ? options[0].value : initialValue); | ||
}, [initialValue]); | ||
|
||
const clickOption = (val) => { | ||
setCurrent(val); | ||
onClick(val); | ||
}; | ||
|
||
return ( | ||
<div className={classNames(styles.doubleTabSwitcherWrapper, 't-inter-medium')}> | ||
<div className={styles.doubleTabSwitcher}> | ||
{options.map((elem) => ( | ||
<div | ||
key={elem.value} | ||
className={classNames(styles.tab, { | ||
[styles.tabActive]: current === elem.value && !disabled, | ||
[styles.tabActiveDisabled]: current === elem.value && disabled, | ||
[styles.tabDisabledNotSelected]: current !== elem.value && disabled, | ||
})} | ||
onClick={() => (disabled ? null : clickOption(elem.value))} | ||
> | ||
{elem.text} | ||
</div> | ||
))} | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default TabSwitcher; |
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