From 643010ccfe02ecd0b9c6260f883c858cdbcce6c4 Mon Sep 17 00:00:00 2001 From: Tal Leibman Date: Fri, 14 Feb 2020 11:11:19 +0200 Subject: [PATCH] JournalsList: show journal color --- src/Journals/JournalsList.tsx | 17 +++++++++++++++-- src/Journals/JournalsListImport.tsx | 17 +++++++++++++++-- src/widgets/ColorBox.tsx | 15 +++++++++++++++ 3 files changed, 45 insertions(+), 4 deletions(-) create mode 100644 src/widgets/ColorBox.tsx diff --git a/src/Journals/JournalsList.tsx b/src/Journals/JournalsList.tsx index 1587c0f..2dc0b26 100644 --- a/src/Journals/JournalsList.tsx +++ b/src/Journals/JournalsList.tsx @@ -14,6 +14,8 @@ import Container from '../widgets/Container'; import { routeResolver } from '../App'; import { JournalsData, UserInfoData, CredentialsData } from '../store'; +import ColorBox from '../widgets/ColorBox'; +import { colorIntToHtml } from '../journal-processors'; interface PropsType { etesync: CredentialsData; @@ -35,16 +37,27 @@ export default function JournalsList(props: PropsType) { const keyPair = userInfo.getKeyPair(userInfo.getCryptoManager(derived)); const cryptoManager = journal.getCryptoManager(derived, keyPair); const info = journal.getInfo(cryptoManager); + let colorBox: React.ReactNode; + switch (info.type) { + case 'CALENDAR': + case 'TASKS': + colorBox = ( + + ); + break; + } ret[info.type] = ret[info.type] || []; ret[info.type].push( - journalClicked(journal.uid)}> + journalClicked(journal.uid)}> {info.displayName} ({journal.uid.slice(0, 5)}) ); return ret; }, - { CALENDAR: [], + { + CALENDAR: [], ADDRESS_BOOK: [], TASKS: [], }); diff --git a/src/Journals/JournalsListImport.tsx b/src/Journals/JournalsListImport.tsx index d1e9f72..8de2877 100644 --- a/src/Journals/JournalsListImport.tsx +++ b/src/Journals/JournalsListImport.tsx @@ -8,6 +8,8 @@ import Container from '../widgets/Container'; import { JournalsData, UserInfoData, CredentialsData } from '../store'; import ImportDialog from './ImportDialog'; import { SyncInfo, SyncInfoJournal } from '../SyncGate'; +import { colorIntToHtml } from '../journal-processors'; +import ColorBox from '../widgets/ColorBox'; interface PropsType { etesync: CredentialsData; @@ -26,16 +28,27 @@ export default function JournalsList(props: PropsType) { const keyPair = userInfo.getKeyPair(userInfo.getCryptoManager(derived)); const cryptoManager = journal.getCryptoManager(derived, keyPair); const info = journal.getInfo(cryptoManager); + let colorBox: React.ReactNode; + switch (info.type) { + case 'CALENDAR': + case 'TASKS': + colorBox = ( + + ); + break; + } ret[info.type] = ret[info.type] || []; ret[info.type].push( - setSelectedJournal(props.syncInfo.get(journal.uid))}> + setSelectedJournal(props.syncInfo.get(journal.uid))}> {info.displayName} ({journal.uid.slice(0, 5)}) ); return ret; }, - { CALENDAR: [], + { + CALENDAR: [], ADDRESS_BOOK: [], TASKS: [], }); diff --git a/src/widgets/ColorBox.tsx b/src/widgets/ColorBox.tsx new file mode 100644 index 0000000..1539cf6 --- /dev/null +++ b/src/widgets/ColorBox.tsx @@ -0,0 +1,15 @@ +import * as React from 'react'; + +interface PropsType { + color: string; + size?: number | string; + style?: React.CSSProperties; +} + +export default function ColorBox(props: PropsType) { + const size = props.size ?? 64; + const style = { ...props.style, backgroundColor: props.color, width: size, height: size }; + return ( +
+ ); +} \ No newline at end of file