UNPKG

@wordpress/block-library

Version:
8 lines (7 loc) 2.06 kB
{ "version": 3, "sources": ["../../src/tabs-menu-item/save.js"], "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useBlockProps } from '@wordpress/block-editor';\n\nexport default function save( { attributes } ) {\n\t// Build CSS custom properties for active/hover colors\n\tconst customColorStyles = {};\n\n\t// Active/hover colors from custom attributes\n\tif ( attributes.customActiveBackgroundColor ) {\n\t\tcustomColorStyles[ '--custom-tab-active-color' ] =\n\t\t\tattributes.customActiveBackgroundColor;\n\t}\n\tif ( attributes.customActiveTextColor ) {\n\t\tcustomColorStyles[ '--custom-tab-active-text-color' ] =\n\t\t\tattributes.customActiveTextColor;\n\t}\n\tif ( attributes.customHoverBackgroundColor ) {\n\t\tcustomColorStyles[ '--custom-tab-hover-color' ] =\n\t\t\tattributes.customHoverBackgroundColor;\n\t}\n\tif ( attributes.customHoverTextColor ) {\n\t\tcustomColorStyles[ '--custom-tab-hover-text-color' ] =\n\t\t\tattributes.customHoverTextColor;\n\t}\n\n\t// useBlockProps.save includes all core style engine classes and styles\n\t// We add our custom classes and the hidden attribute for PHP template extraction\n\tconst blockProps = useBlockProps.save( {\n\t\tclassName: 'wp-block-tabs-menu-item__template',\n\t\tstyle: customColorStyles,\n\t\thidden: true,\n\t} );\n\n\treturn (\n\t\t<a { ...blockProps }>\n\t\t\t<span className=\"screen-reader-text\">\n\t\t\t\t{ __( 'Tab menu item' ) }\n\t\t\t</span>\n\t\t</a>\n\t);\n}\n"], "mappings": ";AAGA,SAAS,UAAU;AACnB,SAAS,qBAAqB;AAkC3B;AAhCY,SAAR,KAAuB,EAAE,WAAW,GAAI;AAE9C,QAAM,oBAAoB,CAAC;AAG3B,MAAK,WAAW,6BAA8B;AAC7C,sBAAmB,2BAA4B,IAC9C,WAAW;AAAA,EACb;AACA,MAAK,WAAW,uBAAwB;AACvC,sBAAmB,gCAAiC,IACnD,WAAW;AAAA,EACb;AACA,MAAK,WAAW,4BAA6B;AAC5C,sBAAmB,0BAA2B,IAC7C,WAAW;AAAA,EACb;AACA,MAAK,WAAW,sBAAuB;AACtC,sBAAmB,+BAAgC,IAClD,WAAW;AAAA,EACb;AAIA,QAAM,aAAa,cAAc,KAAM;AAAA,IACtC,WAAW;AAAA,IACX,OAAO;AAAA,IACP,QAAQ;AAAA,EACT,CAAE;AAEF,SACC,oBAAC,OAAI,GAAG,YACP,8BAAC,UAAK,WAAU,sBACb,aAAI,eAAgB,GACvB,GACD;AAEF;", "names": [] }