import React from 'react'; import { css, cx, Label, spacing, palette, } from '@mongodb-js/compass-components'; import { CONNECTION_COLOR_CODES, legacyColorsToColorCode, useConnectionColor, } from '../hooks/use-connection-color'; /** * Default colors. */ const colorOptionStyles = css({ outline: 'none', margin: 0, padding: 0, marginRight: spacing[2], borderRadius: '50%', verticalAlign: 'middle', width: spacing[5] + spacing[1], height: spacing[5] + spacing[1], border: '1px solid transparent', boxShadow: `0 0 0 0 ${palette.blue.light1}`, transition: 'box-shadow .16s ease-in', position: 'relative', overflow: 'hidden', '&:hover': { cursor: 'pointer', }, }); const activeColorOptionStyles = css({ boxShadow: `0 0 0 3px ${palette.blue.light1}`, transitionTimingFunction: 'ease-out', }); const inActiveColorOptionStyles = css({ '&:focus, &:hover': { boxShadow: `0 0 0 3px ${palette.gray.light1}`, }, }); const noColorRedBarStyles = css({ width: 40, borderTop: `3px solid ${palette.red.base}`, transform: 'rotate(-45deg)', position: 'absolute', left: -5, }); const selectedColorCheckmarkStyles = css({ margin: 0, padding: 0, }); function ColorOption({ isSelected, onClick, code, hex, }: { isSelected: boolean; onClick: () => void; code: string; hex: string; }): React.ReactElement { return ( ); } export function FavoriteColorPicker({ colorCode, onChange, }: { colorCode?: string; onChange: (newColor?: string) => void; }): React.ReactElement { const selectedColorCode = legacyColorsToColorCode(colorCode); const { connectionColorToHex: colorCodeToHex } = useConnectionColor(); const selectedColorHex = colorCodeToHex(selectedColorCode); return ( <>
{CONNECTION_COLOR_CODES.map((colorCode) => { const hex = colorCodeToHex(colorCode) || ''; return ( { onChange(colorCode); }} isSelected={colorCode === selectedColorCode} hex={hex} code={colorCode} key={colorCode} /> ); })}
); }