import React from 'react'; import PropTypes from 'prop-types'; import colorList from './colors.css'; // ---------------------------------------------------------- // // HELPER FUNCTIONS // // ---------------------------------------------------------- // // Transform colorList from an object to an array of objects const transformedColorList = Object.keys(colorList).map(colorName => ({ label: colorName.replace('--', ''), value: colorList[colorName] })); // Get the background and text color values of each palette item const getPaletteItemStyle = color => { const itemTextColor = color.label.substring(color.label.length - 2); return { backgroundColor: color.value, // Extract the scale from the color label. // If the scale is greater or equal to 50, use white text for the label; otherwise, use dark text. color: parseInt(itemTextColor, 10) >= 50 ? '#ffffff' : '#0a0a23' }; }; const getPaletteByColorName = name => transformedColorList.filter(color => color.label.includes(name)); // ---------------------------------------------------------- // // COMPONENTS // // ---------------------------------------------------------- // const Palette = ({ colors }) => { return (
{colors.map(color => (
{color.label}
))}
); }; Palette.propTypes = { colors: PropTypes.arrayOf( PropTypes.shape({ label: PropTypes.string, value: PropTypes.string }) ) }; export const AllPalettes = () => { return ( <> ); };