2022-04-19 01:32:19 +03:00
|
|
|
import PropTypes from 'prop-types';
|
2022-09-07 10:00:28 +03:00
|
|
|
import { FC } from 'react';
|
2022-04-19 01:32:19 +03:00
|
|
|
|
2022-09-07 10:00:28 +03:00
|
|
|
export type ColorProps = {
|
|
|
|
color: any; // TODO specify better type
|
|
|
|
};
|
|
|
|
|
|
|
|
export const Color: FC<ColorProps> = ({ color }) => {
|
2022-04-19 01:32:19 +03:00
|
|
|
const resolvedColor = getComputedStyle(document.documentElement).getPropertyValue(`--${color}`);
|
|
|
|
|
|
|
|
const containerStyle = {
|
|
|
|
borderRadius: '20px',
|
|
|
|
width: '12vw',
|
|
|
|
height: '12vw',
|
|
|
|
minWidth: '100px',
|
|
|
|
minHeight: '100px',
|
|
|
|
borderWidth: '1.5px',
|
|
|
|
borderStyle: 'solid',
|
|
|
|
borderColor: 'lightgray',
|
|
|
|
overflow: 'hidden',
|
2022-05-07 09:27:29 +03:00
|
|
|
margin: '0.3vw',
|
2022-04-19 01:32:19 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
const colorBlockStyle = {
|
2022-05-13 07:27:21 +03:00
|
|
|
display: 'flex',
|
|
|
|
justifyContent: 'center',
|
|
|
|
alignItems: 'center',
|
|
|
|
textShadow: '0 0 15px black',
|
2022-04-19 01:32:19 +03:00
|
|
|
height: '70%',
|
|
|
|
width: '100%',
|
|
|
|
backgroundColor: resolvedColor,
|
|
|
|
};
|
|
|
|
|
2022-05-13 07:27:21 +03:00
|
|
|
const colorTextStyle = {
|
|
|
|
color: 'white',
|
|
|
|
alignText: 'center',
|
|
|
|
};
|
|
|
|
|
2022-04-19 01:32:19 +03:00
|
|
|
const colorDescriptionStyle = {
|
|
|
|
margin: '5px',
|
2022-05-07 09:27:29 +03:00
|
|
|
color: 'gray',
|
2022-08-30 09:17:12 +03:00
|
|
|
fontSize: '0.95vw',
|
2022-05-13 07:27:21 +03:00
|
|
|
textAlign: 'center' as 'center',
|
2022-08-30 09:17:12 +03:00
|
|
|
lineHeight: 1.0,
|
2022-04-19 01:32:19 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
return (
|
|
|
|
<figure style={containerStyle}>
|
2022-05-13 07:27:21 +03:00
|
|
|
<div style={colorBlockStyle}>
|
|
|
|
<div style={colorTextStyle}>{resolvedColor}</div>
|
|
|
|
</div>
|
|
|
|
<figcaption style={colorDescriptionStyle}>{color}</figcaption>
|
2022-04-19 01:32:19 +03:00
|
|
|
</figure>
|
|
|
|
);
|
2022-09-07 10:00:28 +03:00
|
|
|
};
|
2022-04-19 01:32:19 +03:00
|
|
|
|
|
|
|
Color.propTypes = {
|
|
|
|
color: PropTypes.string.isRequired,
|
|
|
|
};
|
|
|
|
|
|
|
|
const rowStyle = {
|
|
|
|
display: 'flex',
|
2022-05-12 09:31:31 +03:00
|
|
|
flexDirection: 'row' as 'row',
|
|
|
|
flexWrap: 'wrap' as 'wrap',
|
2022-04-19 01:32:19 +03:00
|
|
|
alignItems: 'center',
|
|
|
|
};
|
|
|
|
|
2022-09-07 10:00:28 +03:00
|
|
|
export const ColorRow = props => {
|
2022-04-19 01:32:19 +03:00
|
|
|
const { colors } = props;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div style={rowStyle}>
|
|
|
|
{colors.map(color => (
|
|
|
|
<Color key={color} color={color} />
|
|
|
|
))}
|
|
|
|
</div>
|
|
|
|
);
|
2022-09-07 10:00:28 +03:00
|
|
|
};
|
2022-04-19 01:32:19 +03:00
|
|
|
|
|
|
|
ColorRow.propTypes = {
|
|
|
|
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
|
|
};
|