This repository was archived by the owner on Apr 4, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Create / Stylize Explorer-UserDetails Tab component #561
Merged
Merged
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
54d9a12
Adding tab Storybook stories
henrypalacios 2b7936a
Add ExplorerTabs Component to Explorer App
henrypalacios b0a11a0
Add variants of the Tabs indicator thickness
henrypalacios cb2a976
Add tabBarExtraContent to Tabs Component
henrypalacios 979847f
fix extra-content width
alongoni a1eb980
add mobile basic css
alongoni fff2798
move extra-content css
alongoni 2861b46
Remove unnoticed console.log
henrypalacios 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
71 changes: 71 additions & 0 deletions
71
src/apps/explorer/components/common/ExplorerTabs/ExplorerTab.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,71 @@ | ||
import React from 'react' | ||
import styled from 'styled-components' | ||
|
||
import Tabs, { getTabTheme, Props as TabsProps, IndicatorTabSize } from 'components/common/Tabs/Tabs' | ||
import { DARK_COLOURS } from 'theme' | ||
import { MEDIA } from 'const' | ||
|
||
const StyledTabs = styled.div` | ||
display: flex; | ||
width: 100%; | ||
padding: 0; | ||
border: ${({ theme }): string => `1px solid ${theme.borderPrimary}`}; | ||
border-radius: 4px; | ||
|
||
> div > div.tablist { | ||
justify-content: flex-start; | ||
border-bottom: ${({ theme }): string => `1px solid ${theme.borderPrimary}`}; | ||
box-sizing: border-box; | ||
} | ||
|
||
> div > div.tablist > button { | ||
flex: 0 0 auto; | ||
min-width: 96px; | ||
padding: 12px 0.8rem; | ||
line-height: 2; | ||
height: auto; | ||
font-family: var(--font-default); | ||
} | ||
|
||
> div > div:last-of-type { | ||
height: 100%; | ||
} | ||
|
||
> div > div.tab-content { | ||
padding: 20px 16px; | ||
} | ||
|
||
.tab-extra-content { | ||
width: 100%; | ||
|
||
@media ${MEDIA.mobile} { | ||
display: none; /* for now we can hide the extra-content on mobiles */ | ||
} | ||
} | ||
` | ||
const tabCustomThemeConfig = getTabTheme({ | ||
activeBg: 'var(--color-transparent)', | ||
activeBgAlt: 'initial', | ||
inactiveBg: 'var(--color-transparent)', | ||
activeText: DARK_COLOURS.textPrimary1, | ||
inactiveText: 'var(--color-text-secondary2)', | ||
activeBorder: DARK_COLOURS.orange, | ||
inactiveBorder: 'none', | ||
fontSize: 'var(--font-size-large)', | ||
fontWeight: 'var(--font-weight-bold)', | ||
letterSpacing: 'initial', | ||
borderRadius: false, | ||
indicatorTabSize: IndicatorTabSize.big, | ||
}) | ||
|
||
type ExplorerTabsProps = Omit<TabsProps, 'tabTheme'> | ||
|
||
const ExplorerTabs: React.FC<ExplorerTabsProps> = (props) => { | ||
return ( | ||
<StyledTabs> | ||
<Tabs tabTheme={tabCustomThemeConfig} {...props} /> | ||
</StyledTabs> | ||
) | ||
} | ||
|
||
export default ExplorerTabs |
75 changes: 75 additions & 0 deletions
75
src/apps/explorer/components/common/ExplorerTabs/ExplorerTabs.stories.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,75 @@ | ||
import React from 'react' | ||
import styled from 'styled-components' | ||
|
||
// also exported from '@storybook/react' if you can deal with breaking changes in 6.1 | ||
import { Meta, Story } from '@storybook/react/types-6-0' | ||
import { GlobalStyles, ThemeToggler } from 'storybook/decorators' | ||
|
||
import StyledTabs from './ExplorerTab' | ||
import { Props as TabsProps } from '../../../../../components/common/Tabs/Tabs' | ||
|
||
export default { | ||
title: 'ExplorerApp/ExplorerTabs', | ||
component: StyledTabs, | ||
decorators: [GlobalStyles, ThemeToggler], | ||
} as Meta | ||
|
||
const tabItems = [ | ||
{ | ||
id: 1, | ||
tab: 'Orders', | ||
content: ( | ||
<div> | ||
<h2>Orders Content</h2> | ||
<p> | ||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. In libero mauris, dictum a orci ac, congue commodo | ||
quam. Fusce ac accumsan diam. Nulla facilisi. Pellentesque ullamcorper ullamcorper metus, at viverra turpis | ||
tristique vulputate. Ut dictum ac elit sit amet ultricies. Aliquam ultricies ante arcu, maximus malesuada leo | ||
dignissim vitae. Nulla facilisi. Quisque sit amet arcu sed nulla hendrerit euismod. Donec gravida sollicitudin | ||
libero, a auctor tortor convallis non. Nullam malesuada enim eu sollicitudin sodales. Nullam accumsan, nunc | ||
sed ultrices elementum, lorem diam vulputate turpis, a ultrices tortor mauris id mauris. Pellentesque a | ||
commodo libero, et convallis leo. Aenean facilisis arcu id magna scelerisque feugiat. Sed accumsan arcu vel | ||
consequat lobortis. Proin gravida lacinia massa eu fringilla. Nulla venenatis sodales tempus. Nam convallis | ||
justo vitae sollicitudin iaculis. Ut vehicula enim vel interdum varius. Aliquam erat volutpat. Pellentesque | ||
sed tellus in dui pulvinar blandit et et elit. Quisque nec metus fringilla, laoreet orci id, scelerisque | ||
velit. | ||
</p> | ||
</div> | ||
), | ||
}, | ||
{ | ||
id: 2, | ||
tab: 'Trades', | ||
content: ( | ||
<> | ||
<h2>Trades Content</h2> | ||
</> | ||
), | ||
}, | ||
] | ||
|
||
const Wrapper = styled.div` | ||
padding: 16px; | ||
display: flex; | ||
align-items: center; | ||
justify-content: space-between; | ||
` | ||
|
||
interface SProps { | ||
text: string | ||
} | ||
const SimpleComponent: React.FC<SProps> = (props) => { | ||
return <h2>{props.text}</h2> | ||
} | ||
|
||
const ExtraComponentNode: React.ReactNode = ( | ||
<Wrapper> | ||
<SimpleComponent text="ExtraComponent_1" /> | ||
<SimpleComponent text="ExtraComponent_2" /> | ||
</Wrapper> | ||
) | ||
|
||
const Template: Story<TabsProps> = (args) => <StyledTabs {...args} /> | ||
|
||
export const DefaultTabs = Template.bind({}) | ||
DefaultTabs.args = { tabItems, extra: ExtraComponentNode } |
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 @@ | ||
import React from 'react' | ||
|
||
import { Meta, Story } from '@storybook/react/types-6-0' | ||
import { GlobalStyles, ThemeToggler } from 'storybook/decorators' | ||
|
||
import Tabs, { getTabTheme, Props as TabsProps } from './Tabs' | ||
import { DARK_COLOURS } from 'theme' | ||
|
||
export default { | ||
title: 'Common/Tabs', | ||
component: Tabs, | ||
decorators: [GlobalStyles, ThemeToggler], | ||
} as Meta | ||
|
||
const tabItems = [ | ||
{ | ||
id: 1, | ||
tab: 'Tab one', | ||
content: <h3>Tab One</h3>, | ||
}, | ||
{ | ||
id: 2, | ||
tab: 'Tab two', | ||
content: <h3>Tab Two</h3>, | ||
}, | ||
{ | ||
id: 3, | ||
tab: 'Tab three', | ||
content: <h3>Tab Three</h3>, | ||
}, | ||
] | ||
|
||
const tabDefaultThemeConfig = getTabTheme() | ||
|
||
const Template: Story<TabsProps> = (args) => <Tabs {...args} /> | ||
|
||
export const DefaultTabs = Template.bind({}) | ||
DefaultTabs.args = { tabItems, tabTheme: tabDefaultThemeConfig } | ||
|
||
const tabItemsWithoutChild = [ | ||
{ | ||
id: 1, | ||
tab: 'Orders', | ||
content: null, | ||
}, | ||
{ | ||
id: 2, | ||
tab: 'Trades', | ||
content: null, | ||
}, | ||
] | ||
|
||
const tabCustomThemeConfig = getTabTheme({ | ||
activeBg: 'var(--color-transparent)', | ||
activeBgAlt: 'initial', | ||
inactiveBg: 'var(--color-transparent)', | ||
activeText: DARK_COLOURS.textPrimary1, | ||
inactiveText: 'var(--color-text-secondary2)', | ||
activeBorder: DARK_COLOURS.orange, | ||
inactiveBorder: 'none', | ||
fontSize: 'var(--font-size-large)', | ||
fontWeight: 'var(--font-weight-bold)', | ||
letterSpacing: 'initial', | ||
borderRadius: false, | ||
}) | ||
|
||
export const CustomizedThemeTabs = Template.bind({}) | ||
CustomizedThemeTabs.args = { tabItems: tabItemsWithoutChild, tabTheme: tabCustomThemeConfig } |
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
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.
We should work on this in a new PR