-
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
coreui NoteBox component #1276
base: main
Are you sure you want to change the base?
coreui NoteBox component #1276
Changes from all commits
8e04c82
8c7ffcc
f4e7ff3
de3722b
99065db
7b84bdc
8f1e79c
888030e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import { css } from '@emotion/react'; | ||
import React, { ReactNode } from 'react'; | ||
import { error, warning, mutedBlue } from '../../definitions/colors'; | ||
import { Error, Info, Warning } from '@material-ui/icons'; | ||
|
||
export interface Props { | ||
type: 'info' | 'warning' | 'error'; | ||
showIcon?: boolean; | ||
children: ReactNode; | ||
} | ||
|
||
const baseCss = css` | ||
border-left: 0.35em solid var(--note-box-border-color); | ||
border-radius: 0.25em; | ||
padding: 1em 3em; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: have padding change based on |
||
background: var(--note-box-bg-color); | ||
gap: 1em; | ||
margin-bottom: 1em; | ||
position: relative; | ||
`; | ||
|
||
const infoCss = css` | ||
--note-box-bg-color: ${mutedBlue[100]}; | ||
--note-box-border-color: ${mutedBlue[600]}; | ||
${baseCss}; | ||
`; | ||
|
||
const warningCss = css` | ||
--note-box-bg-color: ${warning[100]}; | ||
--note-box-border-color: ${warning[600]}; | ||
font-weight: 500; | ||
${baseCss}; | ||
`; | ||
|
||
const errorCss = css` | ||
--note-box-bg-color: ${error[100]}; | ||
--note-box-border-color: ${error[600]}; | ||
font-weight: 500; | ||
${baseCss}; | ||
`; | ||
|
||
const iconCss = css` | ||
position: absolute; | ||
left: 0.5em; | ||
font-size: 1.5em; | ||
`; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What do you think of adding |
||
|
||
export function NoteBox(props: Props) { | ||
const finalCss = | ||
props.type === 'warning' | ||
? warningCss | ||
: props.type === 'error' | ||
? errorCss | ||
: infoCss; | ||
|
||
const Icon = | ||
props.showIcon === true | ||
? props.type === 'info' | ||
? Info | ||
: props.type === 'warning' | ||
? Warning | ||
: props.type === 'error' | ||
? Error | ||
: null | ||
: null; | ||
return ( | ||
<div css={finalCss}> | ||
{Icon ? <Icon css={iconCss} /> : null} {props.children} | ||
</div> | ||
); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
import React from 'react'; | ||
import { NoteBox, Props } from '../../components/containers/NoteBox'; | ||
import { Story, Meta } from '@storybook/react/types-6-0'; | ||
import { UIThemeProvider } from '../../components/theming'; | ||
import { mutedGreen, mutedMagenta } from '../../definitions/colors'; | ||
|
||
export default { | ||
title: 'Containers/NoteBox', | ||
component: NoteBox, | ||
} as Meta; | ||
|
||
const Template: Story<Props> = function Template(props) { | ||
return ( | ||
<div style={{ fontFamily: 'sans-serif' }}> | ||
<UIThemeProvider | ||
theme={{ | ||
palette: { | ||
primary: { hue: mutedGreen, level: 500 }, | ||
secondary: { hue: mutedMagenta, level: 500 }, | ||
}, | ||
}} | ||
> | ||
<NoteBox {...props} /> | ||
</UIThemeProvider> | ||
</div> | ||
); | ||
}; | ||
|
||
export const InfoWithoutIcon = Object.assign(Template.bind({}), { | ||
args: { | ||
type: 'info', | ||
showIcon: false, | ||
children: ( | ||
<div> | ||
This is some general information about the content that follows on the | ||
page. | ||
</div> | ||
), | ||
}, | ||
}); | ||
|
||
export const WarningWithoutIcon = Object.assign(Template.bind({}), { | ||
args: { | ||
type: 'warning', | ||
showIcon: false, | ||
children: ( | ||
<div>This is a warning about the content that follows on the page.</div> | ||
), | ||
}, | ||
}); | ||
|
||
export const ErrorWithoutIcon = Object.assign(Template.bind({}), { | ||
args: { | ||
type: 'error', | ||
showIcon: false, | ||
children: ( | ||
<div> | ||
This is an error message about the content that follows on the page. | ||
</div> | ||
), | ||
}, | ||
}); | ||
|
||
export const LongContentWithoutIcon = Object.assign(Template.bind({}), { | ||
args: { | ||
type: 'info', | ||
showIcon: false, | ||
children: ( | ||
<div> | ||
Lorem ipsum odor amet, consectetuer adipiscing elit. Faucibus morbi ac | ||
ultrices purus urna tristique mattis consequat. Posuere volutpat | ||
facilisi natoque dictumst dignissim magna dapibus. Taciti vel a etiam | ||
curabitur velit torquent. Fusce interdum dictum vulputate sollicitudin | ||
nulla. Orci placerat congue odio aptent enim mauris. Turpis nec rhoncus | ||
eleifend eleifend eget. Auctor sed nullam vestibulum quisque egestas; | ||
nullam aenean ante. | ||
</div> | ||
), | ||
}, | ||
}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A story using a different type of child (for example, an image or some other non-text element) would be helpful if time allows There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. or an expandable one There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I agree! I will add a couple more, soon. |
||
|
||
export const InfoWithIcon = Object.assign(Template.bind({}), { | ||
args: { | ||
type: 'info', | ||
showIcon: true, | ||
children: ( | ||
<div> | ||
This is some general information about the content that follows on the | ||
page. | ||
</div> | ||
), | ||
}, | ||
}); | ||
|
||
export const WarningWithIcon = Object.assign(Template.bind({}), { | ||
args: { | ||
type: 'warning', | ||
showIcon: true, | ||
children: ( | ||
<div>This is a warning about the content that follows on the page.</div> | ||
), | ||
}, | ||
}); | ||
|
||
export const ErrorWithIcon = Object.assign(Template.bind({}), { | ||
args: { | ||
type: 'error', | ||
showIcon: true, | ||
children: ( | ||
<div> | ||
This is an error message about the content that follows on the page. | ||
</div> | ||
), | ||
}, | ||
}); | ||
|
||
export const LongContentWithIcon = Object.assign(Template.bind({}), { | ||
args: { | ||
type: 'info', | ||
showIcon: true, | ||
children: ( | ||
<div> | ||
Lorem ipsum odor amet, consectetuer adipiscing elit. Faucibus morbi ac | ||
ultrices purus urna tristique mattis consequat. Posuere volutpat | ||
facilisi natoque dictumst dignissim magna dapibus. Taciti vel a etiam | ||
curabitur velit torquent. Fusce interdum dictum vulputate sollicitudin | ||
nulla. Orci placerat congue odio aptent enim mauris. Turpis nec rhoncus | ||
eleifend eleifend eget. Auctor sed nullam vestibulum quisque egestas; | ||
nullam aenean ante. | ||
</div> | ||
), | ||
}, | ||
}); | ||
|
||
export const ExpandableContentWithIcon = Object.assign(Template.bind({}), { | ||
args: { | ||
type: 'info', | ||
showIcon: true, | ||
children: ( | ||
<details> | ||
<summary style={{ cursor: 'pointer' }}> | ||
There are some interesting things about this... | ||
</summary> | ||
<p> | ||
Lorem ipsum odor amet, consectetuer adipiscing elit. Faucibus morbi ac | ||
ultrices purus urna tristique mattis consequat. Posuere volutpat | ||
facilisi natoque dictumst dignissim magna dapibus. Taciti vel a etiam | ||
curabitur velit torquent. Fusce interdum dictum vulputate sollicitudin | ||
nulla. Orci placerat congue odio aptent enim mauris. Turpis nec | ||
rhoncus eleifend eleifend eget. Auctor sed nullam vestibulum quisque | ||
egestas; nullam aenean ante. | ||
</p> | ||
</details> | ||
), | ||
}, | ||
}); |
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.
Perhaps additionally a default font? I believe coreui generally uses Inter or Roboto
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.
For content, I think we should use the same font as the rest of the site, but I will take a look at using one of these other fonts.
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.
I think I'm going to leave the font as-is.