import PropTypes from 'prop-types'; import React from 'react'; import {FormattedMessage} from 'react-intl'; import styles from './custom-procedures.css'; // Scratch block category colors const SCRATCH_COLORS = [ { name: 'Motion', color: '#4C97FF' }, { name: 'Looks', color: '#9966FF' }, { name: 'Sound', color: '#CF63CF' }, { name: 'Events', color: '#FFBF00' }, { name: 'Control', color: '#FFAB19' }, { name: 'Sensing', color: '#5CB1D6' }, { name: 'Operators', color: '#59C059' }, { name: 'Variables', color: '#FF8C1A' }, { name: 'Lists', color: '#FF661A' }, { name: 'My Blocks', color: '#FF6680' }, { name: 'Pen', color: '#0fBD8C' } ]; const ColorPicker = props => { const handlePresetColorClick = (presetColor) => { // Create a synthetic event to match the expected interface const syntheticEvent = { target: { value: presetColor } }; props.onColorChange(syntheticEvent); }; return (
{/* Color Grid */}
{SCRATCH_COLORS.map((colorInfo, index) => (
handlePresetColorClick(colorInfo.color)} title={colorInfo.name} role="button" tabIndex="0" onKeyDown={(e) => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); handlePresetColorClick(colorInfo.color); } }} /> ))}
{/* Custom Color Input */}
{props.color}
); }; ColorPicker.propTypes = { color: PropTypes.string.isRequired, onColorChange: PropTypes.func.isRequired }; export default ColorPicker;