Skip to content
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

Top banner #60

Merged
merged 9 commits into from
Sep 14, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"registry": "https://npm.pkg.github.com"
},
"repository": "git://github.com/contacto-io/contacto-console",
"version": "0.5.10",
"version": "0.5.13",
"main": "build/index.js",
"module": "build/index.es.js",
"files": [
Expand Down
7 changes: 7 additions & 0 deletions src/components/Button/Button.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,10 @@ LinkDanger.args = {
label: 'Button without border',
type: 'link-danger',
}

export const LinkUnderline = Template.bind({})
LinkUnderline.args = {
label: 'Button without border',
type: 'link',
variant: 'underline',
}
7 changes: 7 additions & 0 deletions src/components/Button/button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,13 @@
}
}

&--underline {
text-decoration: underline;
height: 24px;
padding: 0;
Copy link
Collaborator

@samuellawerentz samuellawerentz Aug 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any hover style required?

min-width: 0;
}

.contacto-icon {
margin-right: 8px
}
Expand Down
5 changes: 5 additions & 0 deletions src/components/Button/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export const getButtonClassName = (
onlyIcon,
fullWidth,
align,
variant,
) => {
return [
'sg',
Expand All @@ -34,6 +35,7 @@ export const getButtonClassName = (
fullWidth ? 'contacto-button--full-width' : '',
align ? `contacto-button--${align}` : '',
className,
variant ? `contacto-button--${variant}` : '',
].join(' ')
}
/**
Expand All @@ -48,6 +50,7 @@ export const Button = ({
align,
className,
children,
variant,
...props
}) => {
return (
Expand All @@ -60,6 +63,7 @@ export const Button = ({
!(label || children) && icon,
fullWidth,
align,
variant,
)}
icon={icon ? <Icon name={icon} className={size} /> : null}
{...props}
Expand Down Expand Up @@ -101,6 +105,7 @@ Button.propTypes = {
*/
align: PropTypes.oneOf(['left', 'right', 'center']),
children: PropTypes.any,
variant: PropTypes.string,
}

Button.defaultProps = {
Expand Down
68 changes: 68 additions & 0 deletions src/components/TopBanner/TopBanner.stories.js
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,
}
36 changes: 36 additions & 0 deletions src/components/TopBanner/index.js
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
}
32 changes: 32 additions & 0 deletions src/components/TopBanner/topbanner.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
.top-banner {
height: 36px;
gap: 4px;
&-buttons-container {
gap: 16px;
// margin-left: 4px;

.sg.cnto-btn.contacto-button--small {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we move this style to Button.scss file?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be add a new button type

<Button type="link" variant="underline" color="white" />

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);
}
}

1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ export * from './components/GroupAndSearchDropdown/index'
export * from './components/Cascader/index'
export * from './components/DatePicker/index'
export * from './components/KeyValueEditor/index'
export * from './components/TopBanner/index'