UNPKG

@wordpress/global-styles-ui

Version:
1 lines • 4.97 kB
{"version":3,"file":"screen-text-shadows.cjs","names":["useSetting","usePresets","getNewIndexFromPresets","sprintf","__","ScreenHeader","ScreenBody","Stack","PresetGroup"],"sources":["../src/screen-text-shadows.tsx"],"sourcesContent":["import { __, sprintf } from '@wordpress/i18n';\nimport { Stack } from '@wordpress/ui';\nimport type { TextShadowPreset } from '@wordpress/global-styles-engine';\nimport { ScreenHeader } from './screen-header';\nimport { ScreenBody } from './screen-body';\nimport PresetGroup from './presets/preset-group';\nimport { usePresets } from './presets/use-presets';\nimport { useSetting } from './hooks';\nimport { getNewIndexFromPresets } from './utils';\n\nexport const DEFAULT_TEXT_SHADOW = '0.05em 0.05em 0.1em rgba(0, 0, 0, 0.3)';\n\nexport default function ScreenTextShadows() {\n\tconst [ defaultEnabled ] = useSetting< boolean >(\n\t\t'typography.defaultTextShadowPresets'\n\t);\n\tconst def = usePresets< TextShadowPreset >(\n\t\t'typography.textShadowPresets',\n\t\t'default'\n\t);\n\tconst theme = usePresets< TextShadowPreset >(\n\t\t'typography.textShadowPresets',\n\t\t'theme'\n\t);\n\tconst custom = usePresets< TextShadowPreset >(\n\t\t'typography.textShadowPresets',\n\t\t'custom'\n\t);\n\n\tconst addCustomTextShadow = () => {\n\t\tconst index = getNewIndexFromPresets( custom.presets, 'text-shadow-' );\n\t\tcustom.setPresets( [\n\t\t\t...custom.presets,\n\t\t\t{\n\t\t\t\t/* translators: %d: is an index for a preset */\n\t\t\t\tname: sprintf( __( 'Text Shadow %d' ), index ),\n\t\t\t\ttextShadow: DEFAULT_TEXT_SHADOW,\n\t\t\t\tslug: `text-shadow-${ index }`,\n\t\t\t},\n\t\t] );\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<ScreenHeader\n\t\t\t\ttitle={ __( 'Text shadows' ) }\n\t\t\t\tdescription={ __(\n\t\t\t\t\t'Manage and create text shadow styles for use across the site.'\n\t\t\t\t) }\n\t\t\t/>\n\t\t\t<ScreenBody>\n\t\t\t\t<Stack\n\t\t\t\t\tdirection=\"column\"\n\t\t\t\t\tclassName=\"global-styles-ui__text-shadows-panel\"\n\t\t\t\t\tgap=\"xl\"\n\t\t\t\t>\n\t\t\t\t\t{ defaultEnabled && (\n\t\t\t\t\t\t<PresetGroup\n\t\t\t\t\t\t\tlabel={ __( 'Default' ) }\n\t\t\t\t\t\t\titems={ def.presets }\n\t\t\t\t\t\t\tgetEditPath={ ( slug ) =>\n\t\t\t\t\t\t\t\t`/typography/text-shadows/edit/default/${ slug }`\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t\t{ theme.presets.length > 0 && (\n\t\t\t\t\t\t<PresetGroup\n\t\t\t\t\t\t\tlabel={ __( 'Theme' ) }\n\t\t\t\t\t\t\titems={ theme.presets }\n\t\t\t\t\t\t\tgetEditPath={ ( slug ) =>\n\t\t\t\t\t\t\t\t`/typography/text-shadows/edit/theme/${ slug }`\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t\t<PresetGroup\n\t\t\t\t\t\tlabel={ __( 'Custom' ) }\n\t\t\t\t\t\titems={ custom.presets }\n\t\t\t\t\t\tgetEditPath={ ( slug ) =>\n\t\t\t\t\t\t\t`/typography/text-shadows/edit/custom/${ slug }`\n\t\t\t\t\t\t}\n\t\t\t\t\t\taddLabel={ __( 'Add text shadow' ) }\n\t\t\t\t\t\tonAdd={ addCustomTextShadow }\n\t\t\t\t\t\tmenuAction={ {\n\t\t\t\t\t\t\tlabel: __( 'Remove all custom text shadows' ),\n\t\t\t\t\t\t\toptionsLabel: __( 'Text shadow options' ),\n\t\t\t\t\t\t\tconfirmText: __(\n\t\t\t\t\t\t\t\t'Are you sure you want to remove all custom text shadows?'\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tconfirmButtonText: __( 'Remove' ),\n\t\t\t\t\t\t\tonConfirm: () => custom.setPresets( [] ),\n\t\t\t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