-
Notifications
You must be signed in to change notification settings - Fork 11
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
Showing
8 changed files
with
121 additions
and
0 deletions.
There are no files selected for viewing
Binary file added
BIN
+16.3 KB
...ests__/__image_snapshots__/top-bar-test-js-components-top-bar-common-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,10 @@ | ||
import { baisy } from '../setup/TestSuiter'; | ||
|
||
const SUITES = [ | ||
baisy.suite('Components/TopBar', 'common'), | ||
]; | ||
|
||
SUITES.map(suite => { | ||
it(suite.getTestName(), suite.testStory, 20000); | ||
}); | ||
|
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,39 @@ | ||
// @flow | ||
|
||
import React from 'react'; | ||
import { theme, TopBarTag, TopBarCloseTag } from './TopBar.theme'; | ||
|
||
import { Row } from '../FlexLayout'; | ||
import { Icon } from '../Icon'; | ||
|
||
type TopBarProps = { | ||
isOpen?: boolean, | ||
onClose?: Function, | ||
children: React$Node, | ||
color: string, | ||
}; | ||
|
||
const TopBar = ({ children, isOpen, onClose, ...rest }: TopBarProps) => { | ||
let rendered = null; | ||
|
||
if (isOpen) { | ||
rendered = ( | ||
<TopBarTag tagName={ Row } alignItems="center" justifyContent="center" gap="lg" { ...rest }> | ||
<If condition={ typeof onClose === 'function' }> | ||
<TopBarCloseTag onClick={ onClose }> | ||
<Icon name="Delete" color="WHITE" /> | ||
</TopBarCloseTag> | ||
</If> | ||
{ children } | ||
</TopBarTag> | ||
); | ||
} | ||
|
||
return rendered; | ||
}; | ||
|
||
TopBar.defaultProps = { | ||
isOpen: true, | ||
}; | ||
|
||
export { TopBar, theme }; |
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 @@ | ||
/* eslint-disable no-alert */ | ||
|
||
import React, { useState } from 'react'; | ||
|
||
export default (asStory) => { | ||
asStory('Components/TopBar', module, (story, { TopBar, Column, Icon, Text, Button }) => { | ||
|
||
const TopBarWithState = (props) => { | ||
const [isOpen, setIsOpen] = useState(true); | ||
|
||
return <TopBar isOpen={ isOpen } onClose={ () => setIsOpen(false) } { ...props } />; | ||
}; | ||
|
||
story | ||
.add('common', () => ( | ||
<Column gap="lg"> | ||
<TopBar color="DSM_HOME_SELECTED"> | ||
<Text color="WHITE" weight="semibold">You have 7 days until your FREE TRIAL ends.</Text> | ||
<Button color="white" variant="ghost" size="sm">Update</Button> | ||
</TopBar> | ||
<TopBarWithState color="RED"> | ||
<Icon color="YELLOW" name="Alert" /> | ||
<Text color="WHITE" weight="semibold">Oh no! Your FREE TRIAL has ended, please update your payment details.</Text> | ||
<Button color="white" variant="ghost" size="sm">Update</Button> | ||
</TopBarWithState> | ||
<TopBar color="RED"> | ||
<Icon color="YELLOW" name="Alert" /> | ||
<Text color="WHITE" weight="semibold">Oh no! Your FREE TRIAL has ended, please update your payment details.</Text> | ||
<Button color="white" variant="ghost" size="sm">Update</Button> | ||
</TopBar> | ||
</Column> | ||
)); | ||
}); | ||
}; |
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 @@ | ||
//@flow | ||
|
||
import { createThemeTag } from '../../theme/createThemeTag'; | ||
|
||
const name = 'topBar'; | ||
|
||
const [TopBarTag, themeTopBar] = createThemeTag(name, ({ COLORS }: *) => ({ | ||
root: (props) => ({ | ||
width: '100%', | ||
height: '52px', | ||
backgroundColor: COLORS[props.color], | ||
position: 'relative', | ||
}), | ||
})); | ||
|
||
const [TopBarCloseTag, themeTopBarClose] = createThemeTag(`${name}Close`, () => ({ | ||
root: { | ||
position: 'absolute', | ||
right: 24, | ||
height: '100%', | ||
display: 'flex', | ||
alignItems: 'center', | ||
cursor: 'pointer', | ||
marginRight: '0 !important', | ||
}, | ||
})); | ||
|
||
const theme = { | ||
...themeTopBar, | ||
...themeTopBarClose, | ||
}; | ||
|
||
export { theme, TopBarTag, TopBarCloseTag }; | ||
|
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 * from './TopBar'; |
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