From fa4fddf7b595bf3a5830da318182b32fcc3811a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Tue, 11 Dec 2018 22:17:32 +0100 Subject: [PATCH] React-select refactorings --- .../core/components/Picker/PickerOption.tsx | 35 +++++++++++++++---- .../core/components/Picker/SimplePicker.tsx | 2 ++ .../app/core/components/Picker/TeamPicker.tsx | 2 +- .../app/core/components/Picker/UserPicker.tsx | 2 +- .../dashboard/dashgrid/DataSourcePicker.tsx | 13 ++++--- public/sass/_grafana.scss | 2 -- .../sass/components/_description-picker.scss | 35 ------------------- public/sass/components/_form_select_box.scss | 32 +++++++++++++++++ public/sass/components/_user-picker.scss | 12 ------- 9 files changed, 73 insertions(+), 62 deletions(-) delete mode 100644 public/sass/components/_description-picker.scss delete mode 100644 public/sass/components/_user-picker.scss diff --git a/public/app/core/components/Picker/PickerOption.tsx b/public/app/core/components/Picker/PickerOption.tsx index 98bb5dc566e..0ace067efc6 100644 --- a/public/app/core/components/Picker/PickerOption.tsx +++ b/public/app/core/components/Picker/PickerOption.tsx @@ -4,19 +4,40 @@ import { OptionProps } from 'react-select/lib/components/Option'; // https://github.com/JedWatson/react-select/issues/3038 interface ExtendedOptionProps extends OptionProps { - data: any; + data: { + description?: string; + imgUrl?: string; + }; } -export const PickerOption = (props: ExtendedOptionProps) => { - const { children, data, className } = props; +export const Option = (props: ExtendedOptionProps) => { + const { children, isSelected, data } = props; + return ( -
- {data.avatarUrl && {data.label}} - {children} +
+ {data.imgUrl && } +
+
{children}
+ {data.description &&
{data.description}
} +
+ {isSelected &&