owncast/web/components/Color.tsx

79 lines
1.6 KiB
TypeScript
Raw Normal View History

2022-04-19 01:32:19 +03: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 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',
fontSize: '0.95vw',
2022-05-13 07:27:21 +03:00
textAlign: 'center' as 'center',
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>
);
}
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',
};
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,
};