forked from tari-project/tari
-
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.
* Improve Tabs component and its usage in DashboardContainer * Upgrade Tabs component and fix TS * Fix text style type
- Loading branch information
1 parent
36441a9
commit 01e5179
Showing
30 changed files
with
473 additions
and
90 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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
/* eslint-disable indent */ | ||
import styled from 'styled-components' | ||
|
||
import { ButtonProps } from './types' | ||
|
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
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
34 changes: 34 additions & 0 deletions
34
applications/launchpad_v2/src/components/Tabs/Tabs.test.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { act, render, screen } from '@testing-library/react' | ||
import { ThemeProvider } from 'styled-components' | ||
|
||
import themes from '../../styles/themes' | ||
import Tabs from './' | ||
|
||
const tabs = [ | ||
{ | ||
id: 'first-tab', | ||
content: <span>First tab</span>, | ||
}, | ||
{ | ||
id: 'second-tab', | ||
content: <span>Second tab</span>, | ||
}, | ||
] | ||
|
||
describe('Tabs', () => { | ||
it('should render without crashing', async () => { | ||
const selected = 'second-tab' | ||
const onSelect = jest.fn() | ||
|
||
await act(async () => { | ||
render( | ||
<ThemeProvider theme={themes.light}> | ||
<Tabs tabs={tabs} selected={selected} onSelect={onSelect} /> | ||
</ThemeProvider>, | ||
) | ||
}) | ||
|
||
const firstTabText = screen.queryAllByText('First tab') | ||
expect(firstTabText.length).toBeGreaterThan(0) | ||
}) | ||
}) |
104 changes: 101 additions & 3 deletions
104
applications/launchpad_v2/src/components/Tabs/index.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,61 @@ | ||
import { animated } from 'react-spring' | ||
import styled from 'styled-components' | ||
|
||
export const TabsContainer = styled.div` | ||
display: flex; | ||
align-items: flex-start; | ||
flex-direction: column; | ||
position: relative; | ||
white-space: no-wrap; | ||
` | ||
|
||
export const Tab = styled.div<{ selected?: boolean }>` | ||
export const TabOptions = styled.div` | ||
display: flex; | ||
padding: 12px; | ||
border-bottom: ${({ selected }) => | ||
selected ? '4px solid #9330FF' : '4px solid #fff'}; | ||
align-items: center; | ||
` | ||
|
||
export const TabOptions = styled.div` | ||
export const Tab = styled.button` | ||
display: flex; | ||
padding: 8px 12px; | ||
box-shadow: none; | ||
border-width: 0px; | ||
border-bottom: 4px solid transparent; | ||
background: transparent; | ||
box-sizing: border-box; | ||
margin: 0px; | ||
position: relative; | ||
cursor: pointer; | ||
align-items: center; | ||
` | ||
|
||
export const TabsBorder = styled.div` | ||
export const TabSelectedBorder = styled(animated.div)` | ||
position: absolute; | ||
height: 4px; | ||
background: red; | ||
width: 100%; | ||
border-radius: 2px; | ||
background: ${({ theme }) => theme.accent}; | ||
bottom: 0; | ||
` | ||
|
||
export const TabBorderSelection = styled.div` | ||
height: 100%; | ||
background: blue; | ||
width: 50px; | ||
export const FontWeightCompensation = styled.div` | ||
visibility: hidden; | ||
& > p { | ||
margin: 0; | ||
} | ||
` | ||
|
||
export const TabContent = styled.div<{ selected?: boolean }>` | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
display: flex; | ||
padding: 12px; | ||
width: 100%; | ||
align-items: center; | ||
justify-content: center; | ||
box-sizing: border-box; | ||
& > p { | ||
margin: 0; | ||
} | ||
` |
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 |
---|---|---|
@@ -1,10 +1,12 @@ | ||
import { ReactNode } from 'react' | ||
|
||
export interface TabProp { | ||
id: string | ||
content: ReactNode | ||
} | ||
|
||
export interface TabsProps { | ||
tabs: { | ||
id: string | ||
content: ReactNode | ||
}[] | ||
tabs: TabProp[] | ||
selected: string | ||
onSelect: (id: string) => void | ||
} |
Oops, something went wrong.