Skip to content

Commit 8e04c82

Browse files
committed
Add NoteBox component
1 parent 95c2e15 commit 8e04c82

2 files changed

Lines changed: 48 additions & 0 deletions

File tree

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import { css } from '@emotion/react';
2+
import React, { ReactNode } from 'react';
3+
import { error, warning, mutedBlue } from '../../definitions/colors';
4+
5+
export interface Props {
6+
type: 'info' | 'warning' | 'error';
7+
children: ReactNode;
8+
}
9+
10+
const baseCss = css`
11+
border-left: 0.25em solid var(--note-box-border-color);
12+
border-radius: 0.25em;
13+
padding: 0.5em 1em;
14+
background: var(--note-box-bg-color);
15+
gap: 1em;
16+
margin-bottom: 1em;
17+
`;
18+
19+
const infoCss = css`
20+
--note-box-bg-color: ${mutedBlue[100]};
21+
--note-box-border-color: ${mutedBlue[600]};
22+
${baseCss};
23+
`;
24+
25+
const warningCss = css`
26+
--note-box-bg-color: ${warning[100]};
27+
--note-box-border-color: ${warning[600]};
28+
font-weight: 500;
29+
${baseCss};
30+
`;
31+
32+
const errorCss = css`
33+
--note-box-bg-color: ${error[100]};
34+
--note-box-border-color: ${error[600]};
35+
font-weight: 500;
36+
${baseCss};
37+
`;
38+
39+
export function NoteBox(props: Props) {
40+
const finalCss =
41+
props.type === 'warning'
42+
? warningCss
43+
: props.type === 'error'
44+
? errorCss
45+
: infoCss;
46+
return <div css={finalCss}>{props.children}</div>;
47+
}

packages/libs/coreui/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export { default as SelectTree } from './components/inputs/SelectTree/SelectTree
3030
export { default as SearchBox } from './components/inputs/SearchBox/SearchBox';
3131
export { default as CheckboxList } from './components/inputs/checkboxes/CheckboxList';
3232
export { default as CheckboxTree } from './components/inputs/checkboxes/CheckboxTree/CheckboxTree';
33+
export { NoteBox } from './components/containers/NoteBox';
3334

3435
export { default as styles } from './styleDefinitions';
3536
export { default as colors } from './definitions/colors';

0 commit comments

Comments
 (0)