Skip to content

Commit b0017e7

Browse files
committed
feat: support change node header color
1 parent 72ed5e1 commit b0017e7

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

src/components/Note/Note.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ type NoteProps = {
2323
saving?: boolean;
2424
saveLabel?: React.ReactNode;
2525
savingLabel?: React.ReactNode;
26+
headerColor?: string;
2627
};
2728

2829
const defaultProps = {
@@ -51,6 +52,7 @@ const Note: FC<NoteProps> = ({
5152
onEdit,
5253
onSave,
5354
onUndelete,
55+
headerColor = 'info',
5456
}) => {
5557
const { deleted, editing, text } = note;
5658

@@ -82,6 +84,7 @@ const Note: FC<NoteProps> = ({
8284
showTimezone={showTimezone}
8385
onDelete={onDelete}
8486
onEdit={onEdit}
87+
color={headerColor}
8588
/>
8689
<CardBody>
8790
<CardText style={{ whiteSpace: 'pre-wrap' }}>{text}</CardText>

src/components/Note/NoteHeader.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,18 @@ type NoteHeaderProps = {
2020
showTimezone?: boolean;
2121
onDelete?: (note: Omit<Note, 'text'>) => void;
2222
onEdit?: (note: Omit<Note, 'text'>) => void;
23+
color?: string;
2324
};
2425

2526
const defaultProps = {
2627
dateFormat: 'ddd MMM DD YYYY HH:mm:ss',
2728
};
2829

29-
const NoteHeader: FC<NoteHeaderProps> = ({ dateFormat = defaultProps.dateFormat, ...props }) => {
30+
const NoteHeader: FC<NoteHeaderProps> = ({
31+
dateFormat = defaultProps.dateFormat,
32+
color = 'info',
33+
...props
34+
}) => {
3035
const { note, onDelete, onEdit, showTimezone } = props;
3136
const { date, edited, from, title } = note;
3237

@@ -37,7 +42,7 @@ const NoteHeader: FC<NoteHeaderProps> = ({ dateFormat = defaultProps.dateFormat,
3742
'justify-content-between',
3843
'py-2',
3944
'pe-2',
40-
'bg-info-subtle'
45+
`bg-${color}-subtle`
4146
);
4247

4348
const anyDataExisting = date || from || title;

src/components/Note/NoteMentions.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ type NoteMentionsProps = {
3030
saving?: boolean;
3131
saveLabel?: React.ReactNode;
3232
savingLabel?: React.ReactNode;
33+
headerColor?: string;
3334
};
3435

3536
const defaultProps = {
@@ -60,6 +61,7 @@ const NoteMentions: FC<NoteMentionsProps> = ({
6061
onEdit,
6162
onSave,
6263
onUndelete,
64+
headerColor = 'info',
6365
}) => {
6466
const { deleted, editing, text } = note;
6567

@@ -106,6 +108,7 @@ const NoteMentions: FC<NoteMentionsProps> = ({
106108
showTimezone={showTimezone}
107109
onDelete={onDelete}
108110
onEdit={onEdit}
111+
color={headerColor}
109112
/>
110113
<CardBody>
111114
<CardText style={{ whiteSpace: 'pre-wrap' }}>

0 commit comments

Comments
 (0)