Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | 1x 12x 1x 12x 1x 12x | import { css } from '@emotion/css';
import getCorrectTextColor from './getCorrectTextColor';
interface ColorCardProps {
color: string;
children: React.ReactNode;
}
const cssClassName = css`
width: 70px;
height: 70px;
display: inline-block;
font-size: 12px;
display: flex;
align-items: center;
justify-content: center;
text-align: center;
`;
const getCssClassNameForColor = ({ color }: any): string => css`
background-color: ${color};
color: ${getCorrectTextColor(color)};
`;
const getStyledClassNames = (props: any): string =>
[cssClassName, getCssClassNameForColor(props)].join(' ');
const ColorCard = ({ color, children }: ColorCardProps) => (
<span className={getStyledClassNames({ color })}>{children}</span>
);
export default ColorCard;
|