@wordpress/block-editor 8.0.17 → 8.1.2-next.f435e9e01b.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/LICENSE.md +1 -1
- package/README.md +19 -6
- package/build/components/block-caption/index.native.js +14 -3
- package/build/components/block-caption/index.native.js.map +1 -1
- package/build/components/block-edit/index.js +9 -0
- package/build/components/block-edit/index.js.map +1 -1
- package/build/components/block-inspector/index.js +14 -19
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-list-appender/index.js +3 -11
- package/build/components/block-list-appender/index.js.map +1 -1
- package/build/components/block-media-update-progress/index.native.js +2 -1
- package/build/components/block-media-update-progress/index.native.js.map +1 -1
- package/build/components/block-preview/auto.js +10 -2
- package/build/components/block-preview/auto.js.map +1 -1
- package/build/components/block-settings/container.native.js +2 -1
- package/build/components/block-settings/container.native.js.map +1 -1
- package/build/components/block-styles/index.js +110 -134
- package/build/components/block-styles/index.js.map +1 -1
- package/build/components/block-styles/menu-items.js +63 -0
- package/build/components/block-styles/menu-items.js.map +1 -0
- package/build/components/block-styles/preview-panel.js +45 -0
- package/build/components/block-styles/preview-panel.js.map +1 -0
- package/build/components/block-styles/preview.native.js +2 -2
- package/build/components/block-styles/preview.native.js.map +1 -1
- package/build/components/block-styles/use-styles-for-block.js +119 -0
- package/build/components/block-styles/use-styles-for-block.js.map +1 -0
- package/build/components/block-styles/utils.js +39 -0
- package/build/components/block-styles/utils.js.map +1 -1
- package/build/components/block-switcher/block-styles-menu.js +3 -23
- package/build/components/block-switcher/block-styles-menu.js.map +1 -1
- package/build/components/block-tools/back-compat.js +2 -1
- package/build/components/block-tools/back-compat.js.map +1 -1
- package/build/components/block-tools/block-selection-button.js +5 -1
- package/build/components/block-tools/block-selection-button.js.map +1 -1
- package/build/components/block-tools/insertion-point.js +11 -1
- package/build/components/block-tools/insertion-point.js.map +1 -1
- package/build/components/block-types-list/index.native.js +2 -2
- package/build/components/block-types-list/index.native.js.map +1 -1
- package/build/components/button-block-appender/index.js +2 -1
- package/build/components/button-block-appender/index.js.map +1 -1
- package/build/components/colors-gradients/dropdown.js +1 -1
- package/build/components/colors-gradients/dropdown.js.map +1 -1
- package/build/components/colors-gradients/panel-color-gradient-settings.native.js +6 -3
- package/build/components/colors-gradients/panel-color-gradient-settings.native.js.map +1 -1
- package/build/components/colors-gradients/tools-panel-color-dropdown.js +89 -0
- package/build/components/colors-gradients/tools-panel-color-dropdown.js.map +1 -0
- package/build/components/contrast-checker/index.js +80 -44
- package/build/components/contrast-checker/index.js.map +1 -1
- package/build/components/contrast-checker/index.native.js +108 -0
- package/build/components/contrast-checker/index.native.js.map +1 -0
- package/build/components/default-block-appender/index.js +16 -19
- package/build/components/default-block-appender/index.js.map +1 -1
- package/build/components/default-style-picker/index.js +18 -3
- package/build/components/default-style-picker/index.js.map +1 -1
- package/build/components/iframe/index.js +4 -5
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/index.js +18 -18
- package/build/components/index.js.map +1 -1
- package/build/components/index.native.js +18 -0
- package/build/components/index.native.js.map +1 -1
- package/build/components/inner-blocks/default-block-appender.js +2 -4
- package/build/components/inner-blocks/default-block-appender.js.map +1 -1
- package/build/components/inner-blocks/use-nested-settings-update.js +16 -14
- package/build/components/inner-blocks/use-nested-settings-update.js.map +1 -1
- package/build/components/inserter/index.js +61 -3
- package/build/components/inserter/index.js.map +1 -1
- package/build/components/inserter/index.native.js +1 -1
- package/build/components/inserter/index.native.js.map +1 -1
- package/build/components/inserter/library.js +5 -3
- package/build/components/inserter/library.js.map +1 -1
- package/build/components/inserter/menu.js +11 -3
- package/build/components/inserter/menu.js.map +1 -1
- package/build/components/inserter/search-items.js +3 -1
- package/build/components/inserter/search-items.js.map +1 -1
- package/build/components/inserter/tabs.native.js +7 -4
- package/build/components/inserter/tabs.native.js.map +1 -1
- package/build/components/inspector-controls/block-support-slot-container.js +2 -1
- package/build/components/inspector-controls/block-support-slot-container.js.map +1 -1
- package/build/components/inspector-controls/block-support-tools-panel.js +14 -44
- package/build/components/inspector-controls/block-support-tools-panel.js.map +1 -1
- package/build/components/inspector-controls/fill.native.js +3 -5
- package/build/components/inspector-controls/fill.native.js.map +1 -1
- package/build/components/inspector-controls/groups.js +4 -0
- package/build/components/inspector-controls/groups.js.map +1 -1
- package/build/components/inspector-controls/slot.js +1 -3
- package/build/components/inspector-controls/slot.js.map +1 -1
- package/build/components/letter-spacing-control/index.js +6 -6
- package/build/components/letter-spacing-control/index.js.map +1 -1
- package/build/components/line-height-control/index.native.js +3 -2
- package/build/components/line-height-control/index.native.js.map +1 -1
- package/build/components/link-control/link-preview.js +1 -1
- package/build/components/link-control/link-preview.js.map +1 -1
- package/build/components/link-control/search-item.js +11 -1
- package/build/components/link-control/search-item.js.map +1 -1
- package/build/components/link-control/search-results.js +2 -1
- package/build/components/link-control/search-results.js.map +1 -1
- package/build/components/link-control/use-search-handler.js +18 -5
- package/build/components/link-control/use-search-handler.js.map +1 -1
- package/build/components/list-view/block-contents.js +3 -1
- package/build/components/list-view/block-contents.js.map +1 -1
- package/build/components/list-view/block-select-button.js +26 -4
- package/build/components/list-view/block-select-button.js.map +1 -1
- package/build/components/list-view/block.js +10 -1
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/media-placeholder/index.js +3 -11
- package/build/components/media-placeholder/index.js.map +1 -1
- package/build/components/media-replace-flow/index.js +32 -6
- package/build/components/media-replace-flow/index.js.map +1 -1
- package/build/components/media-replace-flow/index.native.js +13 -0
- package/build/components/media-replace-flow/index.native.js.map +1 -0
- package/build/components/media-upload-progress/index.native.js +2 -1
- package/build/components/media-upload-progress/index.native.js.map +1 -1
- package/build/components/panel-color-settings/index.js +7 -3
- package/build/components/panel-color-settings/index.js.map +1 -1
- package/build/components/provider/block-refs-provider.js +4 -1
- package/build/components/provider/block-refs-provider.js.map +1 -1
- package/build/components/rich-text/file-paste-handler.js +1 -1
- package/build/components/rich-text/file-paste-handler.js.map +1 -1
- package/build/components/rich-text/index.js +2 -1
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/index.native.js +2 -1
- package/build/components/rich-text/index.native.js.map +1 -1
- package/build/components/rich-text/prevent-event-discovery.js +33 -0
- package/build/components/rich-text/prevent-event-discovery.js.map +1 -0
- package/build/components/rich-text/use-input-rules.js +3 -1
- package/build/components/rich-text/use-input-rules.js.map +1 -1
- package/build/components/rich-text/use-paste-handler.js +14 -5
- package/build/components/rich-text/use-paste-handler.js.map +1 -1
- package/build/components/rich-text/utils.js +2 -1
- package/build/components/rich-text/utils.js.map +1 -1
- package/build/components/selection-scroll-into-view/index.js +2 -1
- package/build/components/selection-scroll-into-view/index.js.map +1 -1
- package/build/components/use-display-block-controls/index.native.js +45 -0
- package/build/components/use-display-block-controls/index.native.js.map +1 -0
- package/build/components/use-on-block-drop/index.js +7 -3
- package/build/components/use-on-block-drop/index.js.map +1 -1
- package/build/components/writing-flow/use-multi-selection.js +3 -1
- package/build/components/writing-flow/use-multi-selection.js.map +1 -1
- package/build/hooks/border-color.js +63 -5
- package/build/hooks/border-color.js.map +1 -1
- package/build/hooks/border-radius.js +47 -0
- package/build/hooks/border-radius.js.map +1 -1
- package/build/hooks/border-style.js +41 -0
- package/build/hooks/border-style.js.map +1 -1
- package/build/hooks/border-width.js +70 -31
- package/build/hooks/border-width.js.map +1 -1
- package/build/hooks/border.js +81 -11
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/color-panel.js +25 -16
- package/build/hooks/color-panel.js.map +1 -1
- package/build/hooks/color-panel.native.js +77 -0
- package/build/hooks/color-panel.native.js.map +1 -0
- package/build/hooks/color.js +179 -12
- package/build/hooks/color.js.map +1 -1
- package/build/hooks/font-size.js +14 -0
- package/build/hooks/font-size.js.map +1 -1
- package/build/hooks/index.native.js +2 -0
- package/build/hooks/index.native.js.map +1 -1
- package/build/hooks/layout.native.js +20 -0
- package/build/hooks/layout.native.js.map +1 -0
- package/build/hooks/letter-spacing.js +1 -1
- package/build/hooks/letter-spacing.js.map +1 -1
- package/build/hooks/typography.js +1 -1
- package/build/hooks/typography.js.map +1 -1
- package/build/hooks/typography.native.js +2 -4
- package/build/hooks/typography.native.js.map +1 -1
- package/build/hooks/utils.js +55 -0
- package/build/hooks/utils.js.map +1 -1
- package/build/store/actions.js +1 -2
- package/build/store/actions.js.map +1 -1
- package/build/store/defaults.js +5 -2
- package/build/store/defaults.js.map +1 -1
- package/build/store/defaults.native.js +2 -6
- package/build/store/defaults.native.js.map +1 -1
- package/build/store/selectors.js +10 -5
- package/build/store/selectors.js.map +1 -1
- package/build/utils/get-paste-event-data.js +1 -1
- package/build/utils/get-paste-event-data.js.map +1 -1
- package/build/utils/parse-css-unit-to-px.js +1 -1
- package/build/utils/parse-css-unit-to-px.js.map +1 -1
- package/build-module/components/block-caption/index.native.js +13 -3
- package/build-module/components/block-caption/index.native.js.map +1 -1
- package/build-module/components/block-edit/index.js +9 -0
- package/build-module/components/block-edit/index.js.map +1 -1
- package/build-module/components/block-inspector/index.js +14 -19
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-list-appender/index.js +3 -10
- package/build-module/components/block-list-appender/index.js.map +1 -1
- package/build-module/components/block-media-update-progress/index.native.js +2 -1
- package/build-module/components/block-media-update-progress/index.native.js.map +1 -1
- package/build-module/components/block-preview/auto.js +10 -2
- package/build-module/components/block-preview/auto.js.map +1 -1
- package/build-module/components/block-settings/container.native.js +2 -1
- package/build-module/components/block-settings/container.native.js.map +1 -1
- package/build-module/components/block-styles/index.js +112 -133
- package/build-module/components/block-styles/index.js.map +1 -1
- package/build-module/components/block-styles/menu-items.js +50 -0
- package/build-module/components/block-styles/menu-items.js.map +1 -0
- package/build-module/components/block-styles/preview-panel.js +35 -0
- package/build-module/components/block-styles/preview-panel.js.map +1 -0
- package/build-module/components/block-styles/preview.native.js +2 -2
- package/build-module/components/block-styles/preview.native.js.map +1 -1
- package/build-module/components/block-styles/use-styles-for-block.js +107 -0
- package/build-module/components/block-styles/use-styles-for-block.js.map +1 -0
- package/build-module/components/block-styles/utils.js +34 -0
- package/build-module/components/block-styles/utils.js.map +1 -1
- package/build-module/components/block-switcher/block-styles-menu.js +3 -21
- package/build-module/components/block-switcher/block-styles-menu.js.map +1 -1
- package/build-module/components/block-tools/back-compat.js +2 -1
- package/build-module/components/block-tools/back-compat.js.map +1 -1
- package/build-module/components/block-tools/block-selection-button.js +5 -1
- package/build-module/components/block-tools/block-selection-button.js.map +1 -1
- package/build-module/components/block-tools/insertion-point.js +11 -1
- package/build-module/components/block-tools/insertion-point.js.map +1 -1
- package/build-module/components/block-types-list/index.native.js +2 -2
- package/build-module/components/block-types-list/index.native.js.map +1 -1
- package/build-module/components/button-block-appender/index.js +2 -1
- package/build-module/components/button-block-appender/index.js.map +1 -1
- package/build-module/components/colors-gradients/dropdown.js +1 -1
- package/build-module/components/colors-gradients/dropdown.js.map +1 -1
- package/build-module/components/colors-gradients/panel-color-gradient-settings.native.js +7 -4
- package/build-module/components/colors-gradients/panel-color-gradient-settings.native.js.map +1 -1
- package/build-module/components/colors-gradients/tools-panel-color-dropdown.js +75 -0
- package/build-module/components/colors-gradients/tools-panel-color-dropdown.js.map +1 -0
- package/build-module/components/contrast-checker/index.js +80 -45
- package/build-module/components/contrast-checker/index.js.map +1 -1
- package/build-module/components/contrast-checker/index.native.js +90 -0
- package/build-module/components/contrast-checker/index.native.js.map +1 -0
- package/build-module/components/default-block-appender/index.js +15 -18
- package/build-module/components/default-block-appender/index.js.map +1 -1
- package/build-module/components/default-style-picker/index.js +17 -3
- package/build-module/components/default-style-picker/index.js.map +1 -1
- package/build-module/components/iframe/index.js +4 -5
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/index.js +2 -2
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/index.native.js +2 -0
- package/build-module/components/index.native.js.map +1 -1
- package/build-module/components/inner-blocks/default-block-appender.js +2 -4
- package/build-module/components/inner-blocks/default-block-appender.js.map +1 -1
- package/build-module/components/inner-blocks/use-nested-settings-update.js +16 -14
- package/build-module/components/inner-blocks/use-nested-settings-update.js.map +1 -1
- package/build-module/components/inserter/index.js +61 -3
- package/build-module/components/inserter/index.js.map +1 -1
- package/build-module/components/inserter/index.native.js +2 -2
- package/build-module/components/inserter/index.native.js.map +1 -1
- package/build-module/components/inserter/library.js +5 -3
- package/build-module/components/inserter/library.js.map +1 -1
- package/build-module/components/inserter/menu.js +11 -4
- package/build-module/components/inserter/menu.js.map +1 -1
- package/build-module/components/inserter/search-items.js +3 -1
- package/build-module/components/inserter/search-items.js.map +1 -1
- package/build-module/components/inserter/tabs.native.js +7 -4
- package/build-module/components/inserter/tabs.native.js.map +1 -1
- package/build-module/components/inspector-controls/block-support-slot-container.js +2 -1
- package/build-module/components/inspector-controls/block-support-slot-container.js.map +1 -1
- package/build-module/components/inspector-controls/block-support-tools-panel.js +15 -44
- package/build-module/components/inspector-controls/block-support-tools-panel.js.map +1 -1
- package/build-module/components/inspector-controls/fill.native.js +3 -5
- package/build-module/components/inspector-controls/fill.native.js.map +1 -1
- package/build-module/components/inspector-controls/groups.js +4 -0
- package/build-module/components/inspector-controls/groups.js.map +1 -1
- package/build-module/components/inspector-controls/slot.js +1 -3
- package/build-module/components/inspector-controls/slot.js.map +1 -1
- package/build-module/components/letter-spacing-control/index.js +6 -6
- package/build-module/components/letter-spacing-control/index.js.map +1 -1
- package/build-module/components/line-height-control/index.native.js +3 -2
- package/build-module/components/line-height-control/index.native.js.map +1 -1
- package/build-module/components/link-control/link-preview.js +1 -1
- package/build-module/components/link-control/link-preview.js.map +1 -1
- package/build-module/components/link-control/search-item.js +11 -1
- package/build-module/components/link-control/search-item.js.map +1 -1
- package/build-module/components/link-control/search-results.js +2 -1
- package/build-module/components/link-control/search-results.js.map +1 -1
- package/build-module/components/link-control/use-search-handler.js +18 -5
- package/build-module/components/link-control/use-search-handler.js.map +1 -1
- package/build-module/components/list-view/block-contents.js +3 -1
- package/build-module/components/list-view/block-contents.js.map +1 -1
- package/build-module/components/list-view/block-select-button.js +25 -4
- package/build-module/components/list-view/block-select-button.js.map +1 -1
- package/build-module/components/list-view/block.js +8 -1
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/media-placeholder/index.js +3 -10
- package/build-module/components/media-placeholder/index.js.map +1 -1
- package/build-module/components/media-replace-flow/index.js +32 -6
- package/build-module/components/media-replace-flow/index.js.map +1 -1
- package/build-module/components/media-replace-flow/index.native.js +4 -0
- package/build-module/components/media-replace-flow/index.native.js.map +1 -0
- package/build-module/components/media-upload-progress/index.native.js +2 -1
- package/build-module/components/media-upload-progress/index.native.js.map +1 -1
- package/build-module/components/panel-color-settings/index.js +7 -3
- package/build-module/components/panel-color-settings/index.js.map +1 -1
- package/build-module/components/provider/block-refs-provider.js +4 -1
- package/build-module/components/provider/block-refs-provider.js.map +1 -1
- package/build-module/components/rich-text/file-paste-handler.js +1 -1
- package/build-module/components/rich-text/file-paste-handler.js.map +1 -1
- package/build-module/components/rich-text/index.js +2 -1
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/index.native.js +2 -1
- package/build-module/components/rich-text/index.native.js.map +1 -1
- package/build-module/components/rich-text/prevent-event-discovery.js +25 -0
- package/build-module/components/rich-text/prevent-event-discovery.js.map +1 -0
- package/build-module/components/rich-text/use-input-rules.js +2 -1
- package/build-module/components/rich-text/use-input-rules.js.map +1 -1
- package/build-module/components/rich-text/use-paste-handler.js +14 -5
- package/build-module/components/rich-text/use-paste-handler.js.map +1 -1
- package/build-module/components/rich-text/utils.js +2 -1
- package/build-module/components/rich-text/utils.js.map +1 -1
- package/build-module/components/selection-scroll-into-view/index.js +2 -1
- package/build-module/components/selection-scroll-into-view/index.js.map +1 -1
- package/build-module/components/use-display-block-controls/index.native.js +34 -0
- package/build-module/components/use-display-block-controls/index.native.js.map +1 -0
- package/build-module/components/use-on-block-drop/index.js +7 -3
- package/build-module/components/use-on-block-drop/index.js.map +1 -1
- package/build-module/components/writing-flow/use-multi-selection.js +3 -4
- package/build-module/components/writing-flow/use-multi-selection.js.map +1 -1
- package/build-module/hooks/border-color.js +61 -7
- package/build-module/hooks/border-color.js.map +1 -1
- package/build-module/hooks/border-radius.js +42 -0
- package/build-module/hooks/border-radius.js.map +1 -1
- package/build-module/hooks/border-style.js +36 -0
- package/build-module/hooks/border-style.js.map +1 -1
- package/build-module/hooks/border-width.js +66 -32
- package/build-module/hooks/border-width.js.map +1 -1
- package/build-module/hooks/border.js +80 -12
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/color-panel.js +24 -14
- package/build-module/hooks/color-panel.js.map +1 -1
- package/build-module/hooks/color-panel.native.js +62 -0
- package/build-module/hooks/color-panel.native.js.map +1 -0
- package/build-module/hooks/color.js +177 -13
- package/build-module/hooks/color.js.map +1 -1
- package/build-module/hooks/font-size.js +12 -1
- package/build-module/hooks/font-size.js.map +1 -1
- package/build-module/hooks/index.native.js +1 -0
- package/build-module/hooks/index.native.js.map +1 -1
- package/build-module/hooks/layout.native.js +16 -0
- package/build-module/hooks/layout.native.js.map +1 -0
- package/build-module/hooks/letter-spacing.js +1 -1
- package/build-module/hooks/letter-spacing.js.map +1 -1
- package/build-module/hooks/typography.js +1 -1
- package/build-module/hooks/typography.js.map +1 -1
- package/build-module/hooks/typography.native.js +2 -4
- package/build-module/hooks/typography.native.js.map +1 -1
- package/build-module/hooks/utils.js +52 -1
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/store/actions.js +1 -2
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/defaults.js +5 -2
- package/build-module/store/defaults.js.map +1 -1
- package/build-module/store/defaults.native.js +2 -5
- package/build-module/store/defaults.native.js.map +1 -1
- package/build-module/store/selectors.js +10 -5
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/get-paste-event-data.js +1 -1
- package/build-module/utils/get-paste-event-data.js.map +1 -1
- package/build-module/utils/parse-css-unit-to-px.js +1 -1
- package/build-module/utils/parse-css-unit-to-px.js.map +1 -1
- package/build-style/style-rtl.css +256 -191
- package/build-style/style.css +256 -191
- package/package.json +30 -30
- package/src/components/block-caption/index.native.js +22 -4
- package/src/components/block-card/README.md +1 -1
- package/src/components/block-edit/index.js +8 -0
- package/src/components/block-edit/test/edit.native.js +10 -9
- package/src/components/block-inspector/index.js +18 -16
- package/src/components/block-list-appender/index.js +5 -21
- package/src/components/block-media-update-progress/index.native.js +1 -1
- package/src/components/block-media-update-progress/test/index.native.js +136 -93
- package/src/components/block-mover/test/__snapshots__/index.native.js.snap +108 -47
- package/src/components/block-mover/test/index.native.js +5 -5
- package/src/components/block-preview/README.md +14 -26
- package/src/components/block-preview/auto.js +7 -2
- package/src/components/block-preview/test/index.js +2 -0
- package/src/components/block-settings/container.native.js +1 -0
- package/src/components/block-styles/index.js +125 -145
- package/src/components/block-styles/menu-items.js +49 -0
- package/src/components/block-styles/preview-panel.js +36 -0
- package/src/components/block-styles/preview.native.js +5 -2
- package/src/components/block-styles/style.scss +59 -51
- package/src/components/block-styles/test/{index.js → utils.js} +60 -1
- package/src/components/block-styles/use-styles-for-block.js +99 -0
- package/src/components/block-styles/utils.js +39 -0
- package/src/components/block-switcher/block-styles-menu.js +3 -38
- package/src/components/block-tools/back-compat.js +1 -0
- package/src/components/block-tools/block-selection-button.js +7 -1
- package/src/components/block-tools/insertion-point.js +10 -1
- package/src/components/block-types-list/index.native.js +5 -2
- package/src/components/border-radius-control/style.scss +1 -1
- package/src/components/border-style-control/style.scss +0 -1
- package/src/components/button-block-appender/index.js +1 -0
- package/src/components/color-palette/test/__snapshots__/control.js.snap +9 -5
- package/src/components/colors-gradients/dropdown.js +48 -43
- package/src/components/colors-gradients/panel-color-gradient-settings.native.js +13 -2
- package/src/components/colors-gradients/style.scss +10 -5
- package/src/components/colors-gradients/tools-panel-color-dropdown.js +85 -0
- package/src/components/contrast-checker/README.md +3 -1
- package/src/components/contrast-checker/index.js +107 -64
- package/src/components/contrast-checker/index.native.js +113 -0
- package/src/components/contrast-checker/style.native.scss +26 -0
- package/src/components/contrast-checker/test/index.js +236 -2
- package/src/components/default-block-appender/index.js +17 -24
- package/src/components/default-block-appender/style.scss +4 -0
- package/src/components/default-block-appender/test/__snapshots__/index.js.snap +12 -24
- package/src/components/default-block-appender/test/index.js +4 -14
- package/src/components/default-style-picker/index.js +18 -6
- package/src/components/iframe/index.js +7 -3
- package/src/components/index.js +2 -2
- package/src/components/index.native.js +2 -0
- package/src/components/inner-blocks/README.md +2 -0
- package/src/components/inner-blocks/default-block-appender.js +2 -7
- package/src/components/inner-blocks/use-nested-settings-update.js +16 -14
- package/src/components/inserter/index.js +77 -5
- package/src/components/inserter/index.native.js +2 -2
- package/src/components/inserter/library.js +17 -12
- package/src/components/inserter/menu.js +31 -13
- package/src/components/inserter/search-items.js +3 -1
- package/src/components/inserter/tabs.native.js +5 -4
- package/src/components/inserter/test/block-types-tab.native.js +9 -10
- package/src/components/inserter/test/index.native.js +3 -7
- package/src/components/inserter/test/reusable-blocks-tab.native.js +8 -10
- package/src/components/inspector-controls/block-support-slot-container.js +3 -1
- package/src/components/inspector-controls/block-support-tools-panel.js +41 -58
- package/src/components/inspector-controls/fill.native.js +4 -3
- package/src/components/inspector-controls/groups.js +4 -0
- package/src/components/inspector-controls/slot.js +2 -7
- package/src/components/letter-spacing-control/index.js +6 -6
- package/src/components/line-height-control/index.native.js +2 -1
- package/src/components/link-control/README.md +1 -1
- package/src/components/link-control/link-preview.js +1 -1
- package/src/components/link-control/search-item.js +11 -2
- package/src/components/link-control/search-results.js +1 -0
- package/src/components/link-control/style.scss +5 -10
- package/src/components/link-control/test/index.js +4 -0
- package/src/components/link-control/use-search-handler.js +25 -4
- package/src/components/list-view/block-contents.js +2 -0
- package/src/components/list-view/block-select-button.js +22 -1
- package/src/components/list-view/block.js +11 -0
- package/src/components/media-placeholder/index.js +3 -10
- package/src/components/media-replace-flow/index.js +35 -5
- package/src/components/media-replace-flow/index.native.js +3 -0
- package/src/components/media-upload/test/index.native.js +28 -47
- package/src/components/media-upload-progress/index.native.js +1 -0
- package/src/components/media-upload-progress/test/index.native.js +60 -47
- package/src/components/panel-color-settings/index.js +8 -4
- package/src/components/provider/block-refs-provider.js +4 -1
- package/src/components/rich-text/file-paste-handler.js +3 -1
- package/src/components/rich-text/index.js +1 -0
- package/src/components/rich-text/index.native.js +1 -0
- package/src/components/rich-text/prevent-event-discovery.js +23 -0
- package/src/components/rich-text/use-input-rules.js +2 -1
- package/src/components/rich-text/use-paste-handler.js +16 -3
- package/src/components/rich-text/utils.js +1 -0
- package/src/components/selection-scroll-into-view/index.js +1 -0
- package/src/components/url-input/README.md +5 -0
- package/src/components/use-display-block-controls/index.native.js +38 -0
- package/src/components/use-on-block-drop/index.js +7 -3
- package/src/components/writing-flow/test/use-multi-selection.js +36 -0
- package/src/components/writing-flow/use-multi-selection.js +12 -9
- package/src/hooks/border-color.js +55 -3
- package/src/hooks/border-radius.js +32 -0
- package/src/hooks/border-style.js +26 -0
- package/src/hooks/border-width.js +56 -32
- package/src/hooks/border.js +115 -20
- package/src/hooks/border.scss +3 -17
- package/src/hooks/color-panel.js +25 -19
- package/src/hooks/color-panel.native.js +63 -0
- package/src/hooks/color.js +182 -12
- package/src/hooks/color.scss +85 -0
- package/src/hooks/font-size.js +29 -1
- package/src/hooks/index.native.js +1 -0
- package/src/hooks/layout.native.js +23 -0
- package/src/hooks/letter-spacing.js +1 -1
- package/src/hooks/typography.js +1 -1
- package/src/hooks/typography.native.js +1 -3
- package/src/hooks/utils.js +69 -1
- package/src/store/actions.js +1 -2
- package/src/store/defaults.js +2 -1
- package/src/store/defaults.native.js +2 -6
- package/src/store/selectors.js +10 -5
- package/src/style.scss +4 -3
- package/src/utils/get-paste-event-data.js +1 -1
- package/src/utils/parse-css-unit-to-px.js +1 -1
- package/src/utils/test/parse-css-unit-to-px.js +3 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/build/components/preserve-scroll-in-reorder/index.js +0 -22
- package/build/components/preserve-scroll-in-reorder/index.js.map +0 -1
- package/build/components/use-canvas-click-redirect/index.js +0 -66
- package/build/components/use-canvas-click-redirect/index.js.map +0 -1
- package/build-module/components/preserve-scroll-in-reorder/index.js +0 -12
- package/build-module/components/preserve-scroll-in-reorder/index.js.map +0 -1
- package/build-module/components/use-canvas-click-redirect/index.js +0 -54
- package/build-module/components/use-canvas-click-redirect/index.js.map +0 -1
- package/src/components/preserve-scroll-in-reorder/index.js +0 -12
- package/src/components/use-canvas-click-redirect/index.js +0 -57
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# ContrastChecker
|
|
2
2
|
|
|
3
|
-
ContrastChecker component determines if contrast for text styles is sufficient (WCAG 2.0 AA) when used with a given background color.
|
|
3
|
+
ContrastChecker component determines if contrast for text styles is sufficient (WCAG 2.0 AA) when used with a given background color.
|
|
4
|
+
|
|
5
|
+
ContrastChecker also accounts for font sizes.
|
|
4
6
|
|
|
5
7
|
A notice will be rendered if the color combination of text and background colors are low.
|
|
6
8
|
|
|
@@ -1,42 +1,129 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { colord, extend } from 'colord';
|
|
5
|
-
import namesPlugin from 'colord/plugins/names';
|
|
6
4
|
import a11yPlugin from 'colord/plugins/a11y';
|
|
5
|
+
import namesPlugin from 'colord/plugins/names';
|
|
6
|
+
import { colord, extend } from 'colord';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* WordPress dependencies
|
|
10
10
|
*/
|
|
11
|
-
import {
|
|
12
|
-
import { __ } from '@wordpress/i18n';
|
|
11
|
+
import { __, sprintf } from '@wordpress/i18n';
|
|
13
12
|
import { Notice } from '@wordpress/components';
|
|
14
|
-
import {
|
|
13
|
+
import { speak } from '@wordpress/a11y';
|
|
15
14
|
|
|
16
15
|
extend( [ namesPlugin, a11yPlugin ] );
|
|
17
16
|
|
|
18
|
-
function
|
|
19
|
-
colordBackgroundColor,
|
|
20
|
-
colordTextColor,
|
|
17
|
+
function ContrastChecker( {
|
|
21
18
|
backgroundColor,
|
|
19
|
+
fallbackBackgroundColor,
|
|
20
|
+
fallbackTextColor,
|
|
21
|
+
fallbackLinkColor,
|
|
22
|
+
fontSize, // font size value in pixels
|
|
23
|
+
isLargeText,
|
|
22
24
|
textColor,
|
|
25
|
+
linkColor,
|
|
26
|
+
enableAlphaChecker = false,
|
|
23
27
|
} ) {
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
const currentBackgroundColor = backgroundColor || fallbackBackgroundColor;
|
|
29
|
+
|
|
30
|
+
// Must have a background color.
|
|
31
|
+
if ( ! currentBackgroundColor ) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const currentTextColor = textColor || fallbackTextColor;
|
|
36
|
+
const currentLinkColor = linkColor || fallbackLinkColor;
|
|
37
|
+
|
|
38
|
+
// Must have at least one text color.
|
|
39
|
+
if ( ! currentTextColor && ! currentLinkColor ) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const textColors = [
|
|
44
|
+
{
|
|
45
|
+
color: currentTextColor,
|
|
46
|
+
description: __( 'text color' ),
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
color: currentLinkColor,
|
|
50
|
+
description: __( 'link color' ),
|
|
51
|
+
},
|
|
52
|
+
];
|
|
53
|
+
const colordBackgroundColor = colord( currentBackgroundColor );
|
|
54
|
+
const backgroundColorHasTransparency = colordBackgroundColor.alpha() < 1;
|
|
55
|
+
const backgroundColorBrightness = colordBackgroundColor.brightness();
|
|
56
|
+
const isReadableOptions = {
|
|
57
|
+
level: 'AA',
|
|
58
|
+
size:
|
|
59
|
+
isLargeText || ( isLargeText !== false && fontSize >= 24 )
|
|
60
|
+
? 'large'
|
|
61
|
+
: 'small',
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
let message = '';
|
|
65
|
+
let speakMessage = '';
|
|
66
|
+
for ( const item of textColors ) {
|
|
67
|
+
// If there is no color, go no further.
|
|
68
|
+
if ( ! item.color ) {
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
const colordTextColor = colord( item.color );
|
|
72
|
+
const isColordTextReadable = colordTextColor.isReadable(
|
|
73
|
+
colordBackgroundColor,
|
|
74
|
+
isReadableOptions
|
|
75
|
+
);
|
|
76
|
+
const textHasTransparency = colordTextColor.alpha() < 1;
|
|
77
|
+
|
|
78
|
+
// If the contrast is not readable.
|
|
79
|
+
if ( ! isColordTextReadable ) {
|
|
80
|
+
// Don't show the message if the background or text is transparent.
|
|
81
|
+
if ( backgroundColorHasTransparency || textHasTransparency ) {
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
message =
|
|
85
|
+
backgroundColorBrightness < colordTextColor.brightness()
|
|
86
|
+
? sprintf(
|
|
87
|
+
// translators: %s is a type of text color, e.g., "text color" or "link color"
|
|
88
|
+
__(
|
|
89
|
+
'This color combination may be hard for people to read. Try using a darker background color and/or a brighter %s.'
|
|
90
|
+
),
|
|
91
|
+
item.description
|
|
92
|
+
)
|
|
93
|
+
: sprintf(
|
|
94
|
+
// translators: %s is a type of text color, e.g., "text color" or "link color"
|
|
95
|
+
__(
|
|
96
|
+
'This color combination may be hard for people to read. Try using a brighter background color and/or a darker %s.'
|
|
97
|
+
),
|
|
98
|
+
item.description
|
|
99
|
+
);
|
|
100
|
+
speakMessage = __(
|
|
101
|
+
'This color combination may be hard for people to read.'
|
|
102
|
+
);
|
|
103
|
+
// Break from the loop when we have a contrast warning.
|
|
104
|
+
// These messages take priority over the transparency warning.
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// If there is no contrast warning and the text is transparent,
|
|
109
|
+
// show the transparent warning if alpha check is enabled.
|
|
110
|
+
if ( textHasTransparency && enableAlphaChecker ) {
|
|
111
|
+
message = __( 'Transparent text may be hard for people to read.' );
|
|
112
|
+
speakMessage = __(
|
|
113
|
+
'Transparent text may be hard for people to read.'
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if ( ! message ) {
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
32
121
|
|
|
33
122
|
// Note: The `Notice` component can speak messages via its `spokenMessage`
|
|
34
123
|
// prop, but the contrast checker requires granular control over when the
|
|
35
124
|
// announcements are made. Notably, the message will be re-announced if a
|
|
36
125
|
// new color combination is selected and the contrast is still insufficient.
|
|
37
|
-
|
|
38
|
-
speak( __( 'This color combination may be hard for people to read.' ) );
|
|
39
|
-
}, [ backgroundColor, textColor ] );
|
|
126
|
+
speak( speakMessage );
|
|
40
127
|
|
|
41
128
|
return (
|
|
42
129
|
<div className="block-editor-contrast-checker">
|
|
@@ -45,54 +132,10 @@ function ContrastCheckerMessage( {
|
|
|
45
132
|
status="warning"
|
|
46
133
|
isDismissible={ false }
|
|
47
134
|
>
|
|
48
|
-
{
|
|
135
|
+
{ message }
|
|
49
136
|
</Notice>
|
|
50
137
|
</div>
|
|
51
138
|
);
|
|
52
139
|
}
|
|
53
140
|
|
|
54
|
-
function ContrastChecker( {
|
|
55
|
-
backgroundColor,
|
|
56
|
-
fallbackBackgroundColor,
|
|
57
|
-
fallbackTextColor,
|
|
58
|
-
fontSize, // font size value in pixels
|
|
59
|
-
isLargeText,
|
|
60
|
-
textColor,
|
|
61
|
-
} ) {
|
|
62
|
-
if (
|
|
63
|
-
! ( backgroundColor || fallbackBackgroundColor ) ||
|
|
64
|
-
! ( textColor || fallbackTextColor )
|
|
65
|
-
) {
|
|
66
|
-
return null;
|
|
67
|
-
}
|
|
68
|
-
const colordBackgroundColor = colord(
|
|
69
|
-
backgroundColor || fallbackBackgroundColor
|
|
70
|
-
);
|
|
71
|
-
const colordTextColor = colord( textColor || fallbackTextColor );
|
|
72
|
-
const hasTransparency =
|
|
73
|
-
colordBackgroundColor.alpha() !== 1 || colordTextColor.alpha() !== 1;
|
|
74
|
-
|
|
75
|
-
if (
|
|
76
|
-
hasTransparency ||
|
|
77
|
-
colordTextColor.isReadable( colordBackgroundColor, {
|
|
78
|
-
level: 'AA',
|
|
79
|
-
size:
|
|
80
|
-
isLargeText || ( isLargeText !== false && fontSize >= 24 )
|
|
81
|
-
? 'large'
|
|
82
|
-
: 'small',
|
|
83
|
-
} )
|
|
84
|
-
) {
|
|
85
|
-
return null;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
return (
|
|
89
|
-
<ContrastCheckerMessage
|
|
90
|
-
backgroundColor={ backgroundColor }
|
|
91
|
-
textColor={ textColor }
|
|
92
|
-
colordBackgroundColor={ colordBackgroundColor }
|
|
93
|
-
colordTextColor={ colordTextColor }
|
|
94
|
-
/>
|
|
95
|
-
);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
141
|
export default ContrastChecker;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { Text, View } from 'react-native';
|
|
5
|
+
import { colord, extend } from 'colord';
|
|
6
|
+
import namesPlugin from 'colord/plugins/names';
|
|
7
|
+
import a11yPlugin from 'colord/plugins/a11y';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* WordPress dependencies
|
|
11
|
+
*/
|
|
12
|
+
import { speak } from '@wordpress/a11y';
|
|
13
|
+
import { __ } from '@wordpress/i18n';
|
|
14
|
+
import { useEffect } from '@wordpress/element';
|
|
15
|
+
import { usePreferredColorSchemeStyle } from '@wordpress/compose';
|
|
16
|
+
import { Icon, warning } from '@wordpress/icons';
|
|
17
|
+
/**
|
|
18
|
+
* Internal dependencies
|
|
19
|
+
*/
|
|
20
|
+
import styles from './style.scss';
|
|
21
|
+
|
|
22
|
+
extend( [ namesPlugin, a11yPlugin ] );
|
|
23
|
+
|
|
24
|
+
function ContrastCheckerMessage( {
|
|
25
|
+
colordBackgroundColor,
|
|
26
|
+
colordTextColor,
|
|
27
|
+
backgroundColor,
|
|
28
|
+
textColor,
|
|
29
|
+
msgStyle,
|
|
30
|
+
} ) {
|
|
31
|
+
const msg =
|
|
32
|
+
colordBackgroundColor.brightness() < colordTextColor.brightness()
|
|
33
|
+
? __(
|
|
34
|
+
'This color combination may be hard for people to read. Try using a darker background color and/or a brighter text color.'
|
|
35
|
+
)
|
|
36
|
+
: __(
|
|
37
|
+
'This color combination may be hard for people to read. Try using a brighter background color and/or a darker text color.'
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
// Note: The `Notice` component can speak messages via its `spokenMessage`
|
|
41
|
+
// prop, but the contrast checker requires granular control over when the
|
|
42
|
+
// announcements are made. Notably, the message will be re-announced if a
|
|
43
|
+
// new color combination is selected and the contrast is still insufficient.
|
|
44
|
+
useEffect( () => {
|
|
45
|
+
speak( __( 'This color combination may be hard for people to read.' ) );
|
|
46
|
+
}, [ backgroundColor, textColor ] );
|
|
47
|
+
|
|
48
|
+
const iconStyle = usePreferredColorSchemeStyle(
|
|
49
|
+
styles[ 'block-editor-contrast-checker__icon' ],
|
|
50
|
+
styles[ 'block-editor-contrast-checker__icon-dark' ]
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<View style={ styles[ 'block-editor-contrast-checker' ] }>
|
|
55
|
+
<Icon style={ iconStyle } icon={ warning } />
|
|
56
|
+
<Text style={ msgStyle }>{ msg }</Text>
|
|
57
|
+
</View>
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function ContrastChecker( {
|
|
62
|
+
backgroundColor,
|
|
63
|
+
fallbackBackgroundColor,
|
|
64
|
+
fallbackTextColor,
|
|
65
|
+
fontSize, // font size value in pixels
|
|
66
|
+
isLargeText,
|
|
67
|
+
textColor,
|
|
68
|
+
} ) {
|
|
69
|
+
const msgStyle = usePreferredColorSchemeStyle(
|
|
70
|
+
styles[ 'block-editor-contrast-checker__notice' ],
|
|
71
|
+
styles[ 'block-editor-contrast-checker__notice-dark' ]
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
if (
|
|
75
|
+
! ( backgroundColor || fallbackBackgroundColor ) ||
|
|
76
|
+
! ( textColor || fallbackTextColor )
|
|
77
|
+
) {
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const colordBackgroundColor = colord(
|
|
82
|
+
backgroundColor || fallbackBackgroundColor
|
|
83
|
+
);
|
|
84
|
+
const colordTextColor = colord( textColor || fallbackTextColor );
|
|
85
|
+
|
|
86
|
+
const hasTransparency =
|
|
87
|
+
colordBackgroundColor.alpha() !== 1 || colordTextColor.alpha() !== 1;
|
|
88
|
+
|
|
89
|
+
if (
|
|
90
|
+
hasTransparency ||
|
|
91
|
+
colordTextColor.isReadable( colordBackgroundColor, {
|
|
92
|
+
level: 'AA',
|
|
93
|
+
size:
|
|
94
|
+
isLargeText || ( isLargeText !== false && fontSize >= 24 )
|
|
95
|
+
? 'large'
|
|
96
|
+
: 'small',
|
|
97
|
+
} )
|
|
98
|
+
) {
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return (
|
|
103
|
+
<ContrastCheckerMessage
|
|
104
|
+
backgroundColor={ backgroundColor }
|
|
105
|
+
textColor={ textColor }
|
|
106
|
+
colordBackgroundColor={ colordBackgroundColor }
|
|
107
|
+
colordTextColor={ colordTextColor }
|
|
108
|
+
msgStyle={ msgStyle }
|
|
109
|
+
/>
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export default ContrastChecker;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
.block-editor-contrast-checker {
|
|
2
|
+
flex-direction: row;
|
|
3
|
+
align-items: center;
|
|
4
|
+
padding: 8px 0;
|
|
5
|
+
justify-content: space-between;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.block-editor-contrast-checker__notice {
|
|
9
|
+
font-size: 11px;
|
|
10
|
+
font-weight: 500;
|
|
11
|
+
color: $yellow-50;
|
|
12
|
+
flex: 1;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.block-editor-contrast-checker__notice-dark {
|
|
16
|
+
color: $yellow-30;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.block-editor-contrast-checker__icon {
|
|
20
|
+
color: $yellow-50;
|
|
21
|
+
margin-right: 5px;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.block-editor-contrast-checker__icon-dark {
|
|
25
|
+
color: $yellow-30;
|
|
26
|
+
}
|
|
@@ -21,11 +21,12 @@ jest.mock( '@wordpress/a11y', () => ( { speak: jest.fn() } ) );
|
|
|
21
21
|
describe( 'ContrastChecker', () => {
|
|
22
22
|
const backgroundColor = '#ffffff';
|
|
23
23
|
const textColor = '#000000';
|
|
24
|
+
const linkColor = '#0040ff';
|
|
24
25
|
const isLargeText = true;
|
|
25
26
|
const fallbackBackgroundColor = '#fff';
|
|
26
27
|
const fallbackTextColor = '#000';
|
|
27
28
|
const sameShade = '#666';
|
|
28
|
-
const colorWithTransparency = 'rgba(102,102,102,0.5)';
|
|
29
|
+
const colorWithTransparency = 'rgba(102,102,102,0.5)'; // #666 with opacity.
|
|
29
30
|
|
|
30
31
|
beforeEach( () => {
|
|
31
32
|
speak.mockReset();
|
|
@@ -35,11 +36,25 @@ describe( 'ContrastChecker', () => {
|
|
|
35
36
|
expect( mount( <ContrastChecker /> ).html() ).toBeNull();
|
|
36
37
|
} );
|
|
37
38
|
|
|
39
|
+
test( 'should render null when no background or fallback background color is provided', () => {
|
|
40
|
+
const wrapper = mount(
|
|
41
|
+
<ContrastChecker
|
|
42
|
+
textColor={ textColor }
|
|
43
|
+
linkColor={ linkColor }
|
|
44
|
+
isLargeText={ isLargeText }
|
|
45
|
+
/>
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
expect( speak ).not.toHaveBeenCalled();
|
|
49
|
+
expect( wrapper.html() ).toBeNull();
|
|
50
|
+
} );
|
|
51
|
+
|
|
38
52
|
test( 'should render null when the colors meet AA WCAG guidelines.', () => {
|
|
39
53
|
const wrapper = mount(
|
|
40
54
|
<ContrastChecker
|
|
41
55
|
backgroundColor={ backgroundColor }
|
|
42
56
|
textColor={ textColor }
|
|
57
|
+
linkColor={ linkColor }
|
|
43
58
|
isLargeText={ isLargeText }
|
|
44
59
|
fallbackBackgroundColor={ fallbackBackgroundColor }
|
|
45
60
|
fallbackTextColor={ fallbackTextColor }
|
|
@@ -50,11 +65,51 @@ describe( 'ContrastChecker', () => {
|
|
|
50
65
|
expect( wrapper.html() ).toBeNull();
|
|
51
66
|
} );
|
|
52
67
|
|
|
53
|
-
test( 'should render component when the colors do not meet AA WCAG guidelines.', () => {
|
|
68
|
+
test( 'should render component when the text and background colors do not meet AA WCAG guidelines.', () => {
|
|
69
|
+
const wrapper = mount(
|
|
70
|
+
<ContrastChecker
|
|
71
|
+
backgroundColor={ sameShade }
|
|
72
|
+
textColor={ sameShade }
|
|
73
|
+
isLargeText={ isLargeText }
|
|
74
|
+
fallbackBackgroundColor={ fallbackBackgroundColor }
|
|
75
|
+
fallbackTextColor={ fallbackTextColor }
|
|
76
|
+
/>
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
expect( speak ).toHaveBeenCalledWith(
|
|
80
|
+
'This color combination may be hard for people to read.'
|
|
81
|
+
);
|
|
82
|
+
expect( wrapper.find( Notice ).children().text() ).toBe(
|
|
83
|
+
'This color combination may be hard for people to read. Try using a brighter background color and/or a darker text color.'
|
|
84
|
+
);
|
|
85
|
+
} );
|
|
86
|
+
|
|
87
|
+
test( 'should render component when the link and background colors do not meet AA WCAG guidelines.', () => {
|
|
88
|
+
const wrapper = mount(
|
|
89
|
+
<ContrastChecker
|
|
90
|
+
backgroundColor={ sameShade }
|
|
91
|
+
textColor={ textColor }
|
|
92
|
+
linkColor={ sameShade }
|
|
93
|
+
isLargeText={ isLargeText }
|
|
94
|
+
fallbackBackgroundColor={ fallbackBackgroundColor }
|
|
95
|
+
fallbackTextColor={ fallbackTextColor }
|
|
96
|
+
/>
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
expect( speak ).toHaveBeenCalledWith(
|
|
100
|
+
'This color combination may be hard for people to read.'
|
|
101
|
+
);
|
|
102
|
+
expect( wrapper.find( Notice ).children().text() ).toBe(
|
|
103
|
+
'This color combination may be hard for people to read. Try using a brighter background color and/or a darker link color.'
|
|
104
|
+
);
|
|
105
|
+
} );
|
|
106
|
+
|
|
107
|
+
test( 'should render component when the link and text and background colors do not meet AA WCAG guidelines.', () => {
|
|
54
108
|
const wrapper = mount(
|
|
55
109
|
<ContrastChecker
|
|
56
110
|
backgroundColor={ sameShade }
|
|
57
111
|
textColor={ sameShade }
|
|
112
|
+
linkColor={ sameShade }
|
|
58
113
|
isLargeText={ isLargeText }
|
|
59
114
|
fallbackBackgroundColor={ fallbackBackgroundColor }
|
|
60
115
|
fallbackTextColor={ fallbackTextColor }
|
|
@@ -74,6 +129,7 @@ describe( 'ContrastChecker', () => {
|
|
|
74
129
|
<ContrastChecker
|
|
75
130
|
backgroundColor={ colorWithTransparency }
|
|
76
131
|
textColor={ sameShade }
|
|
132
|
+
linkColor={ sameShade }
|
|
77
133
|
isLargeText={ isLargeText }
|
|
78
134
|
fallbackBackgroundColor={ fallbackBackgroundColor }
|
|
79
135
|
fallbackTextColor={ fallbackTextColor }
|
|
@@ -99,6 +155,22 @@ describe( 'ContrastChecker', () => {
|
|
|
99
155
|
expect( wrapper.html() ).toBeNull();
|
|
100
156
|
} );
|
|
101
157
|
|
|
158
|
+
test( 'should render render null if link color contains a transparency', () => {
|
|
159
|
+
const wrapper = mount(
|
|
160
|
+
<ContrastChecker
|
|
161
|
+
backgroundColor={ backgroundColor }
|
|
162
|
+
textColor={ textColor }
|
|
163
|
+
linkColor={ colorWithTransparency }
|
|
164
|
+
isLargeText={ isLargeText }
|
|
165
|
+
fallbackBackgroundColor={ fallbackBackgroundColor }
|
|
166
|
+
fallbackTextColor={ fallbackTextColor }
|
|
167
|
+
/>
|
|
168
|
+
);
|
|
169
|
+
|
|
170
|
+
expect( speak ).not.toHaveBeenCalled();
|
|
171
|
+
expect( wrapper.html() ).toBeNull();
|
|
172
|
+
} );
|
|
173
|
+
|
|
102
174
|
test( 'should render different message matching snapshot when background color has less brightness than text color.', () => {
|
|
103
175
|
const darkerShade = '#555';
|
|
104
176
|
|
|
@@ -233,6 +305,22 @@ describe( 'ContrastChecker', () => {
|
|
|
233
305
|
);
|
|
234
306
|
} );
|
|
235
307
|
|
|
308
|
+
test( 'should render messages when the linkColor is valid, but the fallback backgroundColor conflicts.', () => {
|
|
309
|
+
const wrapper = mount(
|
|
310
|
+
<ContrastChecker
|
|
311
|
+
linkColor={ linkColor }
|
|
312
|
+
fallbackBackgroundColor={ linkColor }
|
|
313
|
+
/>
|
|
314
|
+
);
|
|
315
|
+
|
|
316
|
+
expect( speak ).toHaveBeenCalledWith(
|
|
317
|
+
'This color combination may be hard for people to read.'
|
|
318
|
+
);
|
|
319
|
+
expect( wrapper.find( Notice ).children().text() ).toBe(
|
|
320
|
+
'This color combination may be hard for people to read. Try using a brighter background color and/or a darker link color.'
|
|
321
|
+
);
|
|
322
|
+
} );
|
|
323
|
+
|
|
236
324
|
test( 'should re-announce if colors change, but still insufficient contrast', () => {
|
|
237
325
|
const appRoot = document.createElement( 'div' );
|
|
238
326
|
|
|
@@ -258,4 +346,150 @@ describe( 'ContrastChecker', () => {
|
|
|
258
346
|
|
|
259
347
|
expect( speak ).toHaveBeenCalledTimes( 2 );
|
|
260
348
|
} );
|
|
349
|
+
|
|
350
|
+
// enableAlphaChecker tests
|
|
351
|
+
test( 'should render null when the colors meet AA WCAG guidelines and alpha checker enabled.', () => {
|
|
352
|
+
const wrapper = mount(
|
|
353
|
+
<ContrastChecker
|
|
354
|
+
backgroundColor={ backgroundColor }
|
|
355
|
+
textColor={ textColor }
|
|
356
|
+
isLargeText={ isLargeText }
|
|
357
|
+
enableAlphaChecker={ true }
|
|
358
|
+
/>
|
|
359
|
+
);
|
|
360
|
+
|
|
361
|
+
expect( speak ).not.toHaveBeenCalled();
|
|
362
|
+
expect( wrapper.html() ).toBeNull();
|
|
363
|
+
} );
|
|
364
|
+
|
|
365
|
+
test( 'should render component when the colors meet AA WCAG guidelines but the text color only has alpha transparency with alpha checker enabled.', () => {
|
|
366
|
+
const wrapper = mount(
|
|
367
|
+
<ContrastChecker
|
|
368
|
+
backgroundColor={ backgroundColor }
|
|
369
|
+
textColor={ 'rgba(0,0,0,0.9)' }
|
|
370
|
+
linkColor={ linkColor }
|
|
371
|
+
isLargeText={ isLargeText }
|
|
372
|
+
enableAlphaChecker={ true }
|
|
373
|
+
/>
|
|
374
|
+
);
|
|
375
|
+
|
|
376
|
+
expect( speak ).toHaveBeenCalledWith(
|
|
377
|
+
'Transparent text may be hard for people to read.'
|
|
378
|
+
);
|
|
379
|
+
expect( wrapper.find( Notice ).children().text() ).toBe(
|
|
380
|
+
'Transparent text may be hard for people to read.'
|
|
381
|
+
);
|
|
382
|
+
} );
|
|
383
|
+
|
|
384
|
+
test( 'should render component when the colors meet AA WCAG guidelines but the link color only has alpha transparency with alpha checker enabled.', () => {
|
|
385
|
+
const wrapper = mount(
|
|
386
|
+
<ContrastChecker
|
|
387
|
+
backgroundColor={ backgroundColor }
|
|
388
|
+
linkColor={ 'rgba(0,0,0,0.9)' }
|
|
389
|
+
textColor={ textColor }
|
|
390
|
+
isLargeText={ isLargeText }
|
|
391
|
+
enableAlphaChecker={ true }
|
|
392
|
+
/>
|
|
393
|
+
);
|
|
394
|
+
|
|
395
|
+
expect( speak ).toHaveBeenCalledWith(
|
|
396
|
+
'Transparent text may be hard for people to read.'
|
|
397
|
+
);
|
|
398
|
+
expect( wrapper.find( Notice ).children().text() ).toBe(
|
|
399
|
+
'Transparent text may be hard for people to read.'
|
|
400
|
+
);
|
|
401
|
+
} );
|
|
402
|
+
|
|
403
|
+
test( 'should render null when the colors meet AA WCAG guidelines but the background color only has alpha transparency with alpha checker enabled.', () => {
|
|
404
|
+
const wrapper = mount(
|
|
405
|
+
<ContrastChecker
|
|
406
|
+
backgroundColor={ 'rgba(255,255,255,0.7)' }
|
|
407
|
+
textColor={ textColor }
|
|
408
|
+
linkColor={ linkColor }
|
|
409
|
+
isLargeText={ isLargeText }
|
|
410
|
+
enableAlphaChecker={ true }
|
|
411
|
+
/>
|
|
412
|
+
);
|
|
413
|
+
|
|
414
|
+
expect( speak ).not.toHaveBeenCalled();
|
|
415
|
+
expect( wrapper.html() ).toBeNull();
|
|
416
|
+
} );
|
|
417
|
+
|
|
418
|
+
test( 'should render null if background color contains a transparency with alpha checker enabled.', () => {
|
|
419
|
+
const wrapper = mount(
|
|
420
|
+
<ContrastChecker
|
|
421
|
+
backgroundColor={ colorWithTransparency }
|
|
422
|
+
textColor={ sameShade }
|
|
423
|
+
linkColor={ sameShade }
|
|
424
|
+
isLargeText={ isLargeText }
|
|
425
|
+
fallbackBackgroundColor={ fallbackBackgroundColor }
|
|
426
|
+
fallbackTextColor={ fallbackTextColor }
|
|
427
|
+
enableAlphaChecker={ true }
|
|
428
|
+
/>
|
|
429
|
+
);
|
|
430
|
+
|
|
431
|
+
expect( speak ).not.toHaveBeenCalled();
|
|
432
|
+
expect( wrapper.html() ).toBeNull();
|
|
433
|
+
} );
|
|
434
|
+
|
|
435
|
+
test( 'should render transparency warning only if one text is not readable but the other is transparent and the background color contains a transparency with alpha checker enabled.', () => {
|
|
436
|
+
const wrapper = mount(
|
|
437
|
+
<ContrastChecker
|
|
438
|
+
backgroundColor={ colorWithTransparency }
|
|
439
|
+
textColor={ sameShade }
|
|
440
|
+
linkColor={ 'rgba(0,0,0,0.9)' }
|
|
441
|
+
isLargeText={ isLargeText }
|
|
442
|
+
fallbackBackgroundColor={ fallbackBackgroundColor }
|
|
443
|
+
fallbackTextColor={ fallbackTextColor }
|
|
444
|
+
enableAlphaChecker={ true }
|
|
445
|
+
/>
|
|
446
|
+
);
|
|
447
|
+
|
|
448
|
+
expect( speak ).toHaveBeenCalledWith(
|
|
449
|
+
'Transparent text may be hard for people to read.'
|
|
450
|
+
);
|
|
451
|
+
expect( wrapper.find( Notice ).children().text() ).toBe(
|
|
452
|
+
'Transparent text may be hard for people to read.'
|
|
453
|
+
);
|
|
454
|
+
} );
|
|
455
|
+
|
|
456
|
+
test( 'should render component and prioritize contrast warning when the colors do no meet AA WCAG guidelines and text has alpha transparency with the alpha checker enabled.', () => {
|
|
457
|
+
const wrapper = mount(
|
|
458
|
+
<ContrastChecker
|
|
459
|
+
backgroundColor={ sameShade }
|
|
460
|
+
textColor={ 'rgba(0,0,0,0.9)' }
|
|
461
|
+
linkColor={ sameShade }
|
|
462
|
+
isLargeText={ isLargeText }
|
|
463
|
+
fallbackBackgroundColor={ fallbackBackgroundColor }
|
|
464
|
+
fallbackTextColor={ fallbackTextColor }
|
|
465
|
+
enableAlphaChecker={ true }
|
|
466
|
+
/>
|
|
467
|
+
);
|
|
468
|
+
|
|
469
|
+
expect( speak ).toHaveBeenCalledWith(
|
|
470
|
+
'This color combination may be hard for people to read.'
|
|
471
|
+
);
|
|
472
|
+
expect( wrapper.find( Notice ).children().text() ).toBe(
|
|
473
|
+
'This color combination may be hard for people to read. Try using a brighter background color and/or a darker link color.'
|
|
474
|
+
);
|
|
475
|
+
} );
|
|
476
|
+
|
|
477
|
+
test( 'should render component when the colors meet AA WCAG guidelines but all colors have alpha transparency with alpha checker enabled.', () => {
|
|
478
|
+
const wrapper = mount(
|
|
479
|
+
<ContrastChecker
|
|
480
|
+
backgroundColor={ 'rgba(255,255,255,0.7)' }
|
|
481
|
+
linkColor={ 'rgba(0,0,0,0.7)' }
|
|
482
|
+
textColor={ 'rgba(0,0,0,0.7)' }
|
|
483
|
+
isLargeText={ isLargeText }
|
|
484
|
+
enableAlphaChecker={ true }
|
|
485
|
+
/>
|
|
486
|
+
);
|
|
487
|
+
|
|
488
|
+
expect( speak ).toHaveBeenCalledWith(
|
|
489
|
+
'Transparent text may be hard for people to read.'
|
|
490
|
+
);
|
|
491
|
+
expect( wrapper.find( Notice ).children().text() ).toBe(
|
|
492
|
+
'Transparent text may be hard for people to read.'
|
|
493
|
+
);
|
|
494
|
+
} );
|
|
261
495
|
} );
|