forked from samuellawerentz/style-guide
-
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.
Merge pull request #60 from contacto-io/top-banner
Top banner
- Loading branch information
Showing
8 changed files
with
161 additions
and
1 deletion.
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
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 { TopBanner, BannerType } from './' | ||
import { Button } from '../Button' | ||
|
||
export default { | ||
title: 'Components/TopBanner', | ||
component: TopBanner, | ||
argTypes: { | ||
type: { | ||
options: BannerType, | ||
control: { type: 'select' }, | ||
}, | ||
}, | ||
} | ||
|
||
const Template = (args) => <TopBanner {...args} /> | ||
|
||
export const Default = Template.bind({}) | ||
Default.args = { | ||
visible: true, | ||
content: 'This is default type banner.', | ||
} | ||
|
||
export const Success = Template.bind({}) | ||
Success.args = { | ||
visible: true, | ||
content: 'This is success type banner.', | ||
type: 'success', | ||
} | ||
|
||
export const Danger = Template.bind({}) | ||
Danger.args = { | ||
visible: true, | ||
content: 'This is danger type banner.', | ||
type: 'danger', | ||
} | ||
|
||
export const Warning = Template.bind({}) | ||
Warning.args = { | ||
visible: true, | ||
content: 'This is warning type banner.', | ||
type: 'warning', | ||
} | ||
|
||
export const BannerWithButton = Template.bind({}) | ||
BannerWithButton.args = { | ||
visible: true, | ||
content: 'This is banner with action button.', | ||
type: 'default', | ||
buttons: [ | ||
<Button | ||
label="Alert" | ||
key="button" | ||
onClick={() => alert('Banner button clicked!')} | ||
size="small" | ||
type="link" | ||
variant="underline" | ||
/>, | ||
], | ||
} | ||
|
||
export const BannerWithLoading = Template.bind({}) | ||
BannerWithLoading.args = { | ||
visible: true, | ||
content: 'This is banner with action button.', | ||
type: 'danger', | ||
loading: true, | ||
} |
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,36 @@ | ||
import React from 'react' | ||
import { Block } from '../Block/index' | ||
import { Icon } from '../Icon/index' | ||
import { Text } from '../Typography/index' | ||
import './topbanner.scss' | ||
|
||
export const BannerType = ['warning', 'danger', 'success', 'default'] | ||
export const TopBanner = ({ | ||
type = 'default', | ||
content, | ||
buttons, | ||
loading, | ||
visible, | ||
loadingText = 'Loading', | ||
}) => { | ||
return visible ? ( | ||
<Block | ||
className={`top-banner ${type}`} | ||
display="flex" | ||
justifyContent="center" | ||
alignItems="center" | ||
> | ||
{loading && ( | ||
<Block> | ||
<Icon.Loading size={16} trackColor="white" /> | ||
</Block> | ||
)} | ||
<Text color="white">{loading ? loadingText : content}</Text> | ||
{!loading && buttons && ( | ||
<Block display="flex" className="top-banner-buttons-container"> | ||
{buttons.map((button) => button)} | ||
</Block> | ||
)} | ||
</Block> | ||
) : null | ||
} |
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,36 @@ | ||
.top-banner { | ||
height: 36px; | ||
gap: 4px; | ||
|
||
.contacto-typography--body { | ||
text-align: center; | ||
} | ||
|
||
&-buttons-container { | ||
gap: 16px; | ||
|
||
.sg.cnto-btn.contacto-button--small { | ||
color: white; | ||
} | ||
.sg.ant-btn.cnto-btn.contacto-button--link:hover { | ||
color: white; | ||
} | ||
} | ||
|
||
&.default { | ||
background-color: var(--primary-text-color); | ||
} | ||
|
||
&.success { | ||
background-color: var(--success-color); | ||
} | ||
|
||
&.danger { | ||
background-color: var(--danger-color); | ||
} | ||
|
||
&.warning { | ||
background-color: var(--warning-color); | ||
} | ||
} | ||
|
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