From 0436e9ccd02cd775a9f847a8e2b2047d90e5a827 Mon Sep 17 00:00:00 2001 From: Andrew P Maney Date: Thu, 12 Mar 2020 15:04:17 -0700 Subject: [PATCH] Tasks: adds colored radio buttons available as widget, they are being used for priority in Task Edit --- src/components/Tasks/TaskEdit.tsx | 11 ++++++----- src/widgets/ColoredRadio.tsx | 29 +++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 5 deletions(-) create mode 100644 src/widgets/ColoredRadio.tsx diff --git a/src/components/Tasks/TaskEdit.tsx b/src/components/Tasks/TaskEdit.tsx index 30380ac..42d1a22 100644 --- a/src/components/Tasks/TaskEdit.tsx +++ b/src/components/Tasks/TaskEdit.tsx @@ -17,7 +17,6 @@ import InputLabel from '@material-ui/core/InputLabel'; import * as colors from '@material-ui/core/colors'; import FormLabel from '@material-ui/core/FormLabel'; import RadioGroup from '@material-ui/core/RadioGroup'; -import Radio from '@material-ui/core/Radio'; import IconDelete from '@material-ui/icons/Delete'; import IconCancel from '@material-ui/icons/Clear'; @@ -42,6 +41,8 @@ import { TaskType, TaskStatusType, timezoneLoadFromName, TaskPriorityType } from import { History } from 'history'; +import ColoredRadio from '../../widgets/ColoredRadio'; + interface PropsType { collections: EteSync.CollectionInfo[]; initialCollection?: string; @@ -310,10 +311,10 @@ class TaskEdit extends React.PureComponent { value={this.state.priority} onChange={(e) => this.handleChange('priority', Number(e.target.value))} > - } label="None" /> - } label="Low" /> - } label="Medium" /> - } label="High" /> + + + + diff --git a/src/widgets/ColoredRadio.tsx b/src/widgets/ColoredRadio.tsx new file mode 100644 index 0000000..cd047fb --- /dev/null +++ b/src/widgets/ColoredRadio.tsx @@ -0,0 +1,29 @@ +import * as React from 'react'; + +import { makeStyles } from '@material-ui/core/styles'; +import Radio from '@material-ui/core/Radio'; +import { Omit } from '@material-ui/types'; +import FormControlLabel, { FormControlLabelProps } from '@material-ui/core/FormControlLabel'; + +interface Props { + color: string; + label: string; +} + +const useStyles = makeStyles({ + root: { + color: (props: Props) => props.color, + }, +}); + +export default function ColoredRadio(props: Props & Omit) { + const { color, label, value, ...other } = props; + const { root } = useStyles(props); + + return } + {...other} + />; +}