owncast/web/stories/Color.tsx

78 lines
1.6 KiB
TypeScript
Raw Normal View History

2022-04-19 00:32:19 +02:00
import PropTypes from 'prop-types';
export function Color(props) {
const { color } = props;
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 08:27:29 +02:00
margin: '0.3vw',
2022-04-19 00:32:19 +02:00
};
const colorBlockStyle = {
2022-05-13 06:27:21 +02:00
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
textShadow: '0 0 15px black',
2022-04-19 00:32:19 +02:00
height: '70%',
width: '100%',
backgroundColor: resolvedColor,
};
2022-05-13 06:27:21 +02:00
const colorTextStyle = {
color: 'white',
alignText: 'center',
};
2022-04-19 00:32:19 +02:00
const colorDescriptionStyle = {
margin: '5px',
2022-05-07 08:27:29 +02:00
color: 'gray',
2022-05-13 06:27:21 +02:00
fontSize: '0.9vw',
textAlign: 'center' as 'center',
2022-04-19 00:32:19 +02:00
};
return (
<figure style={containerStyle}>
2022-05-13 06:27:21 +02:00
<div style={colorBlockStyle}>
<div style={colorTextStyle}>{resolvedColor}</div>
</div>
<figcaption style={colorDescriptionStyle}>{color}</figcaption>
2022-04-19 00:32:19 +02:00
</figure>
);
}
Color.propTypes = {
color: PropTypes.string.isRequired,
};
const rowStyle = {
display: 'flex',
2022-05-12 08:31:31 +02:00
flexDirection: 'row' as 'row',
flexWrap: 'wrap' as 'wrap',
2022-04-19 00:32:19 +02:00
alignItems: 'center',
};
export function ColorRow(props) {
const { colors } = props;
return (
<div style={rowStyle}>
{colors.map(color => (
<Color key={color} color={color} />
))}
</div>
);
}
ColorRow.propTypes = {
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
};