From 8e04c823077ee6a3c843f1e80d8a9f7f89211b35 Mon Sep 17 00:00:00 2001 From: Dave Falke Date: Fri, 15 Nov 2024 14:49:54 -0500 Subject: [PATCH] Add NoteBox component --- .../src/components/containers/NoteBox.tsx | 47 +++++++++++++++++++ packages/libs/coreui/src/index.ts | 1 + 2 files changed, 48 insertions(+) create mode 100644 packages/libs/coreui/src/components/containers/NoteBox.tsx diff --git a/packages/libs/coreui/src/components/containers/NoteBox.tsx b/packages/libs/coreui/src/components/containers/NoteBox.tsx new file mode 100644 index 0000000000..1d2aaedf18 --- /dev/null +++ b/packages/libs/coreui/src/components/containers/NoteBox.tsx @@ -0,0 +1,47 @@ +import { css } from '@emotion/react'; +import React, { ReactNode } from 'react'; +import { error, warning, mutedBlue } from '../../definitions/colors'; + +export interface Props { + type: 'info' | 'warning' | 'error'; + children: ReactNode; +} + +const baseCss = css` + border-left: 0.25em solid var(--note-box-border-color); + border-radius: 0.25em; + padding: 0.5em 1em; + background: var(--note-box-bg-color); + gap: 1em; + margin-bottom: 1em; +`; + +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}; +`; + +export function NoteBox(props: Props) { + const finalCss = + props.type === 'warning' + ? warningCss + : props.type === 'error' + ? errorCss + : infoCss; + return
{props.children}
; +} diff --git a/packages/libs/coreui/src/index.ts b/packages/libs/coreui/src/index.ts index 3dca9af1b5..a4cb9293e9 100644 --- a/packages/libs/coreui/src/index.ts +++ b/packages/libs/coreui/src/index.ts @@ -30,6 +30,7 @@ export { default as SelectTree } from './components/inputs/SelectTree/SelectTree export { default as SearchBox } from './components/inputs/SearchBox/SearchBox'; export { default as CheckboxList } from './components/inputs/checkboxes/CheckboxList'; export { default as CheckboxTree } from './components/inputs/checkboxes/CheckboxTree/CheckboxTree'; +export { NoteBox } from './components/containers/NoteBox'; export { default as styles } from './styleDefinitions'; export { default as colors } from './definitions/colors';