UNPKG

@wordpress/components

Version:
1 lines • 1.41 kB
{"version":3,"file":"custom-duotone-bar.mjs","names":[],"sources":["../../src/duotone-picker/custom-duotone-bar.tsx"],"sourcesContent":["import CustomGradientBar from '../custom-gradient-picker/gradient-bar';\nimport {\n\tgetColorStopsFromColors,\n\tgetGradientFromCSSColors,\n\tgetColorsFromColorStops,\n} from './utils';\n\nconst PLACEHOLDER_VALUES = [ '#333', '#CCC' ];\n\nexport default function CustomDuotoneBar( {\n\tvalue,\n\tonChange,\n}: {\n\tvalue?: string[];\n\tonChange: ( value?: string[] ) => void;\n} ) {\n\tconst hasGradient = !! value;\n\tconst values = hasGradient ? value : PLACEHOLDER_VALUES;\n\tconst background = getGradientFromCSSColors( values );\n\tconst controlPoints = getColorStopsFromColors( values );\n\treturn (\n\t\t<CustomGradientBar\n\t\t\tdisableInserter\n\t\t\tdisablePositioning\n\t\t\tbackground={ background }\n\t\t\thasGradient={ hasGradient }\n\t\t\tvalue={ controlPoints }\n\t\t\tonChange={ ( newColorStops ) => {\n\t\t\t\tconst newValue = getColorsFromColorStops( newColorStops );\n\t\t\t\tonChange( newValue );\n\t\t\t} }\n\t\t/>\n\t);\n}\n"],"mappings":";;;;AAOA,MAAM,qBAAqB,CAAE,QAAQ,MAAO;AAE5C,SAAwB,iBAAkB,EACzC,OACA,YAIG;CACH,MAAM,cAAc,CAAC,CAAE;CACvB,MAAM,SAAS,cAAc,QAAQ;CACrC,MAAM,aAAa,yBAA0B,MAAO;CACpD,MAAM,gBAAgB,wBAAyB,MAAO;CACtD,OACC,oBAAC,mBAAD;EACC,iBAAA;EACA,oBAAA;EACa;EACC;EACd,OAAQ;EACR,WAAa,kBAAmB;GAE/B,SADiB,wBAAyB,aACzB,CAAE;EACpB;CACA,CAAA;AAEH"}