@wordpress/block-library
Version:
Block library for the WordPress editor.
1 lines • 1.82 kB
Source Map (JSON)
{"version":3,"file":"save.mjs","names":["getColorClassesAndStyles"],"sources":["../../src/separator/save.jsx"],"sourcesContent":["import clsx from 'clsx';\nimport {\n\tgetColorClassName,\n\tuseBlockProps,\n\t__experimentalGetColorClassesAndStyles as getColorClassesAndStyles,\n} from '@wordpress/block-editor';\n\nexport default function separatorSave( { attributes } ) {\n\tconst { backgroundColor, style, opacity, tagName: Tag } = attributes;\n\tconst customColor = style?.color?.background;\n\tconst colorProps = getColorClassesAndStyles( attributes );\n\t// The hr support changing color using border-color, since border-color\n\t// is not yet supported in the color palette, we use background-color.\n\n\t// The dots styles uses text for the dots, to change those dots color is\n\t// using color, not backgroundColor.\n\tconst colorClass = getColorClassName( 'color', backgroundColor );\n\n\tconst className = clsx(\n\t\t{\n\t\t\t'has-text-color': backgroundColor || customColor,\n\t\t\t[ colorClass ]: colorClass,\n\t\t\t'has-css-opacity': opacity === 'css',\n\t\t\t'has-alpha-channel-opacity': opacity === 'alpha-channel',\n\t\t},\n\t\tcolorProps.className\n\t);\n\n\tconst styles = {\n\t\tbackgroundColor: colorProps?.style?.backgroundColor,\n\t\tcolor: colorClass ? undefined : customColor,\n\t};\n\treturn <Tag { ...useBlockProps.save( { className, style: styles } ) } />;\n}\n"],"mappings":";;;;AAOA,SAAwB,cAAe,EAAE,cAAe;CACvD,MAAM,EAAE,iBAAiB,OAAO,SAAS,SAAS,QAAQ;CAC1D,MAAM,cAAc,OAAO,OAAO;CAClC,MAAM,aAAaA,uCAA0B,UAAW;CAMxD,MAAM,aAAa,kBAAmB,SAAS,eAAgB;CAE/D,MAAM,YAAY,KACjB;EACC,kBAAkB,mBAAmB;GACnC,aAAc;EAChB,mBAAmB,YAAY;EAC/B,6BAA6B,YAAY;CAC1C,GACA,WAAW,SACZ;CAEA,MAAM,SAAS;EACd,iBAAiB,YAAY,OAAO;EACpC,OAAO,aAAa,KAAA,IAAY;CACjC;CACA,OAAO,oBAAC,KAAD,EAAK,GAAK,cAAc,KAAM;EAAE;EAAW,OAAO;CAAO,CAAE,EAAK,CAAA;AACxE"}