forked from tari-project/tari
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: tabs and ts issue #94
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is
selected
prop being used anywhere?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right! I'm going to merge this PR and add new one fixing this.