Просмотр исходного кода

Update styles of selected named color swatch

Dominik Prokop 7 лет назад
Родитель
Сommit
3c7a5bdf7b

+ 6 - 3
packages/grafana-ui/src/components/ColorPicker/NamedColorsGroup.tsx

@@ -1,5 +1,5 @@
 import React, { FunctionComponent } from 'react';
 import React, { FunctionComponent } from 'react';
-import { Themeable } from '../../types';
+import { Themeable, GrafanaTheme } from '../../types';
 import { ColorDefinition, getColorForTheme } from '../../utils/colorsPalette';
 import { ColorDefinition, getColorForTheme } from '../../utils/colorsPalette';
 import { Color } from 'csstype';
 import { Color } from 'csstype';
 import { find, upperFirst } from 'lodash';
 import { find, upperFirst } from 'lodash';
@@ -11,7 +11,7 @@ export enum ColorSwatchVariant {
   Large = 'large',
   Large = 'large',
 }
 }
 
 
-interface ColorSwatchProps extends React.DOMAttributes<HTMLDivElement> {
+interface ColorSwatchProps extends Themeable, React.DOMAttributes<HTMLDivElement> {
   color: string;
   color: string;
   label?: string;
   label?: string;
   variant?: ColorSwatchVariant;
   variant?: ColorSwatchVariant;
@@ -23,17 +23,19 @@ const ColorSwatch: FunctionComponent<ColorSwatchProps> = ({
   label,
   label,
   variant = ColorSwatchVariant.Small,
   variant = ColorSwatchVariant.Small,
   isSelected,
   isSelected,
+  theme,
   ...otherProps
   ...otherProps
 }) => {
 }) => {
   const isSmall = variant === ColorSwatchVariant.Small;
   const isSmall = variant === ColorSwatchVariant.Small;
   const swatchSize = isSmall ? '16px' : '32px';
   const swatchSize = isSmall ? '16px' : '32px';
+  const selectedSwatchBorder = theme === GrafanaTheme.Light ? '#ffffff' : '#1A1B1F';
   const swatchStyles = {
   const swatchStyles = {
     width: swatchSize,
     width: swatchSize,
     height: swatchSize,
     height: swatchSize,
     borderRadius: '50%',
     borderRadius: '50%',
     background: `${color}`,
     background: `${color}`,
     marginRight: isSmall ? '0px' : '8px',
     marginRight: isSmall ? '0px' : '8px',
-    boxShadow: isSelected ? `inset 0 0 0 2px ${color}, inset 0 0 0 4px white` : 'none',
+    boxShadow: isSelected ? `inset 0 0 0 2px ${color}, inset 0 0 0 4px ${selectedSwatchBorder}` : 'none',
     cursor: isSelected ? 'default' : 'pointer',
     cursor: isSelected ? 'default' : 'pointer',
   };
   };
 
 
@@ -76,6 +78,7 @@ const NamedColorsGroup: FunctionComponent<NamedColorsGroupProps> = ({
           color={getColorForTheme(primaryColor, theme)}
           color={getColorForTheme(primaryColor, theme)}
           label={upperFirst(primaryColor.hue)}
           label={upperFirst(primaryColor.hue)}
           onClick={() => onColorSelect(primaryColor)}
           onClick={() => onColorSelect(primaryColor)}
+          theme={theme}
         />
         />
       )}
       )}
       <div
       <div

+ 0 - 1
packages/grafana-ui/src/components/ColorPicker/NamedColorsPalette.tsx

@@ -10,7 +10,6 @@ interface NamedColorsPaletteProps extends Themeable {
 
 
 const NamedColorsPalette = ({ color, onChange, theme }: NamedColorsPaletteProps) => {
 const NamedColorsPalette = ({ color, onChange, theme }: NamedColorsPaletteProps) => {
   const swatches: JSX.Element[] = [];
   const swatches: JSX.Element[] = [];
-
   ColorsPalette.forEach((colors, hue) => {
   ColorsPalette.forEach((colors, hue) => {
     swatches.push(
     swatches.push(
       <NamedColorsGroup
       <NamedColorsGroup