forked from binary-com/deriv-app
-
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
6f946bd
commit ab0ab57
Showing
14 changed files
with
214 additions
and
14 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
20 changes: 20 additions & 0 deletions
20
packages/wallets/src/components/AccountsList/AccountsList.tsx
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
.wallets-tabs { | ||
&-list { | ||
display: grid; | ||
grid-auto-columns: 1fr; | ||
position: relative; | ||
background-color: #f2f3f4; | ||
height: 5rem; | ||
margin: 2rem; | ||
border-radius: 7px; | ||
|
||
&-item { | ||
grid-row: 1; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
cursor: pointer; | ||
|
||
&--active { | ||
font-weight: var(--text-weight-bold); | ||
background-color: var(--general-main-1); | ||
margin: 0.6rem; | ||
border-radius: 5px; | ||
} | ||
|
||
&--disabled { | ||
color: var(--text-disabled); | ||
} | ||
} | ||
} | ||
} |
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,31 @@ | ||
import React from 'react'; | ||
import { useTabs } from './Tabs'; | ||
import './TabList.scss'; | ||
|
||
type TTabListProps = { | ||
list: string[]; | ||
text_size: string; | ||
}; | ||
|
||
export const TabList = ({ list, text_size = 's' }: TTabListProps) => { | ||
const { active_tab_index, setActiveTabIndex } = useTabs(); | ||
|
||
return ( | ||
<div className='wallets-tabs-list' data-list-count={list.length}> | ||
{list.map((tab, i) => ( | ||
<div | ||
className={`wallets-tabs-list-item wallets-tabs-list-item--${ | ||
i === active_tab_index ? 'active' : 'disabled' | ||
}`} | ||
key={i} | ||
onClick={() => setActiveTabIndex(i)} | ||
style={{ | ||
fontSize: `var(--text-size-${text_size})`, | ||
}} | ||
> | ||
{tab} | ||
</div> | ||
))} | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import React from 'react'; | ||
|
||
const TabPanel = ({ children }: React.PropsWithChildren<unknown>) => { | ||
return <div>{children}</div>; | ||
}; | ||
|
||
export default TabPanel; |
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,18 @@ | ||
import React from 'react'; | ||
import { useTabs } from './Tabs'; | ||
|
||
const TabPanels = ({ children }: React.PropsWithChildren<unknown>) => { | ||
const { active_tab_index } = useTabs(); | ||
|
||
return ( | ||
<div> | ||
{React.Children.map(children, (child, index) => { | ||
if (index !== active_tab_index) return undefined; | ||
|
||
return child; | ||
})} | ||
</div> | ||
); | ||
}; | ||
|
||
export default TabPanels; |
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,35 @@ | ||
import React from 'react'; | ||
// import classNames from 'classnames'; | ||
|
||
type TTabContext = { | ||
active_tab_index: number; | ||
setActiveTabIndex: React.Dispatch<React.SetStateAction<number>>; | ||
}; | ||
|
||
const TabsContext = React.createContext<TTabContext | null>(null); | ||
|
||
export const useTabs = () => { | ||
const context = React.useContext(TabsContext); | ||
|
||
if (!context) { | ||
throw new Error('Seems you forgot to wrap the components in "<Tabs />"'); | ||
} | ||
|
||
return context; | ||
}; | ||
|
||
type TTabsProps = { | ||
className?: string; | ||
}; | ||
|
||
export const Tabs = ({ children, className }: React.PropsWithChildren<TTabsProps>) => { | ||
const [active_tab_index, setActiveTabIndex] = React.useState(0); | ||
|
||
return ( | ||
<TabsContext.Provider value={{ active_tab_index, setActiveTabIndex }}> | ||
<div className={className}>{children}</div> | ||
</TabsContext.Provider> | ||
); | ||
}; | ||
|
||
export default Tabs; |
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,6 @@ | ||
import { TabList } from './TabList'; | ||
import TabPanel from './TabPanel'; | ||
import TabPanels from './TabPanels'; | ||
import Tabs from './Tabs'; | ||
|
||
export { TabList, TabPanel, TabPanels, Tabs }; |
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