From d8b42501ed6337de0bd1132e92d237eed88e00f0 Mon Sep 17 00:00:00 2001 From: Vadim Nicolai Date: Fri, 20 Mar 2020 00:31:07 +0200 Subject: [PATCH 01/21] Small cleanup. --- packages/block-library/src/style.scss | 36 +++++++++---------- packages/components/src/button/style.scss | 8 +---- .../components/header/header-toolbar/index.js | 10 +++++- .../header/header-toolbar/style.scss | 10 ++++++ .../src/components/header/style.scss | 6 ++-- .../src/components/options-modal/index.js | 17 +++++++-- .../components/options-modal/options/base.js | 20 +++++------ .../components/options-modal/options/index.js | 2 ++ .../options-modal/options/show-icon-labels.js | 22 ++++++++++++ .../test/__snapshots__/index.js.snap | 7 ++++ 10 files changed, 94 insertions(+), 44 deletions(-) create mode 100644 packages/edit-post/src/components/options-modal/options/show-icon-labels.js diff --git a/packages/block-library/src/style.scss b/packages/block-library/src/style.scss index 46686a47e63f8..d9c793123c55e 100644 --- a/packages/block-library/src/style.scss +++ b/packages/block-library/src/style.scss @@ -142,75 +142,75 @@ // Our classes uses the same values we set for gradient value attributes, and we can not use spacing because of WP multi site kses rule. /* stylelint-disable function-comma-space-after */ .has-vivid-cyan-blue-to-vivid-purple-gradient-background { - background: linear-gradient(135deg,rgba(6,147,227,1) 0%,rgb(155,81,224) 100%); + background: linear-gradient(135deg, rgba(6, 147, 227, 1) 0%, rgb(155, 81, 224) 100%); } .has-vivid-green-cyan-to-vivid-cyan-blue-gradient-background { - background: linear-gradient(135deg,rgba(0,208,132,1) 0%,rgba(6,147,227,1) 100%); + background: linear-gradient(135deg, rgba(0, 208, 132, 1) 0%, rgba(6, 147, 227, 1) 100%); } .has-light-green-cyan-to-vivid-green-cyan-gradient-background { - background: linear-gradient(135deg,rgb(122,220,180) 0%,rgb(0,208,130) 100%); + background: linear-gradient(135deg, rgb(122, 220, 180) 0%, rgb(0, 208, 130) 100%); } .has-luminous-vivid-amber-to-luminous-vivid-orange-gradient-background { - background: linear-gradient(135deg,rgba(252,185,0,1) 0%,rgba(255,105,0,1) 100%); + background: linear-gradient(135deg, rgba(252, 185, 0, 1) 0%, rgba(255, 105, 0, 1) 100%); } .has-luminous-vivid-orange-to-vivid-red-gradient-background { - background: linear-gradient(135deg,rgba(255,105,0,1) 0%,rgb(207,46,46) 100%); + background: linear-gradient(135deg, rgba(255, 105, 0, 1) 0%, rgb(207, 46, 46) 100%); } .has-very-light-gray-to-cyan-bluish-gray-gradient-background { - background: linear-gradient(135deg,rgb(238,238,238) 0%,rgb(169,184,195) 100%); + background: linear-gradient(135deg, rgb(238, 238, 238) 0%, rgb(169, 184, 195) 100%); } .has-cool-to-warm-spectrum-gradient-background { - background: linear-gradient(135deg,rgb(74,234,220) 0%,rgb(151,120,209) 20%,rgb(207,42,186) 40%,rgb(238,44,130) 60%,rgb(251,105,98) 80%,rgb(254,248,76) 100%); + background: linear-gradient(135deg, rgb(74, 234, 220) 0%, rgb(151, 120, 209) 20%, rgb(207, 42, 186) 40%, rgb(238, 44, 130) 60%, rgb(251, 105, 98) 80%, rgb(254, 248, 76) 100%); } .has-blush-light-purple-gradient-background { - background: linear-gradient(135deg,rgb(255,206,236) 0%,rgb(152,150,240) 100%); + background: linear-gradient(135deg, rgb(255, 206, 236) 0%, rgb(152, 150, 240) 100%); } .has-blush-bordeaux-gradient-background { - background: linear-gradient(135deg,rgb(254,205,165) 0%,rgb(254,45,45) 50%,rgb(107,0,62) 100%); + background: linear-gradient(135deg, rgb(254, 205, 165) 0%, rgb(254, 45, 45) 50%, rgb(107, 0, 62) 100%); } .has-purple-crush-gradient-background { - background: linear-gradient(135deg,rgb(52,226,228) 0%,rgb(71,33,251) 50%,rgb(171,29,254) 100%); + background: linear-gradient(135deg, rgb(52, 226, 228) 0%, rgb(71, 33, 251) 50%, rgb(171, 29, 254) 100%); } .has-luminous-dusk-gradient-background { - background: linear-gradient(135deg,rgb(255,203,112) 0%,rgb(199,81,192) 50%,rgb(65,88,208) 100%); + background: linear-gradient(135deg, rgb(255, 203, 112) 0%, rgb(199, 81, 192) 50%, rgb(65, 88, 208) 100%); } .has-hazy-dawn-gradient-background { - background: linear-gradient(135deg,rgb(250,172,168) 0%,rgb(218,208,236) 100%); + background: linear-gradient(135deg, rgb(250, 172, 168) 0%, rgb(218, 208, 236) 100%); } .has-pale-ocean-gradient-background { - background: linear-gradient(135deg,rgb(255,245,203) 0%,rgb(182,227,212) 50%,rgb(51,167,181) 100%); + background: linear-gradient(135deg, rgb(255, 245, 203) 0%, rgb(182, 227, 212) 50%, rgb(51, 167, 181) 100%); } .has-electric-grass-gradient-background { - background: linear-gradient(135deg,rgb(202,248,128) 0%,rgb(113,206,126) 100%); + background: linear-gradient(135deg, rgb(202, 248, 128) 0%, rgb(113, 206, 126) 100%); } .has-subdued-olive-gradient-background { - background: linear-gradient(135deg,rgb(250,250,225) 0%,rgb(103,166,113) 100%); + background: linear-gradient(135deg, rgb(250, 250, 225) 0%, rgb(103, 166, 113) 100%); } .has-atomic-cream-gradient-background { - background: linear-gradient(135deg,rgb(253,215,154) 0%,rgb(0,74,89) 100%); + background: linear-gradient(135deg, rgb(253, 215, 154) 0%, rgb(0, 74, 89) 100%); } .has-nightshade-gradient-background { - background: linear-gradient(135deg,rgb(51,9,104) 0%,rgb(49,205,207) 100%); + background: linear-gradient(135deg, rgb(51, 9, 104) 0%, rgb(49, 205, 207) 100%); } .has-midnight-gradient-background { - background: linear-gradient(135deg,rgb(2,3,129) 0%,rgb(40,116,252) 100%); + background: linear-gradient(135deg, rgb(2, 3, 129) 0%, rgb(40, 116, 252) 100%); } /* stylelint-enable function-comma-space-after */ } diff --git a/packages/components/src/button/style.scss b/packages/components/src/button/style.scss index 3e4a7b94e78a7..e72519d4f503f 100644 --- a/packages/components/src/button/style.scss +++ b/packages/components/src/button/style.scss @@ -89,13 +89,7 @@ background-size: 100px 100%; // Disable reason: This function call looks nicer when each argument is on its own line. /* stylelint-disable */ - background-image: linear-gradient( - -45deg, - $theme-color 28%, - color($theme-color shade(20%)) 28%, - color($theme-color shade(20%)) 72%, - $theme-color 72% - ); + background-image: linear-gradient(-45deg, $theme-color 28%, color($theme-color shade(20%)) 28%, color($theme-color shade(20%)) 72%, $theme-color 72%); /* stylelint-enable */ border-color: color($theme-color); } diff --git a/packages/edit-post/src/components/header/header-toolbar/index.js b/packages/edit-post/src/components/header/header-toolbar/index.js index 080f9e2c25825..539c3e7afd876 100644 --- a/packages/edit-post/src/components/header/header-toolbar/index.js +++ b/packages/edit-post/src/components/header/header-toolbar/index.js @@ -1,3 +1,8 @@ +/** + * External dependencies + */ +import classnames from 'classnames'; + /** * WordPress dependencies */ @@ -25,6 +30,7 @@ function HeaderToolbar() { showInserter, isTextModeEnabled, previewDeviceType, + showIconLabels, } = useSelect( ( select ) => ( { hasFixedToolbar: select( 'core/edit-post' ).isFeatureActive( @@ -55,7 +61,9 @@ function HeaderToolbar() { return ( +
+ +
); } @@ -112,6 +123,8 @@ export default compose( withDispatch( ( dispatch ) => { return { closeModal: () => dispatch( 'core/edit-post' ).closeModal(), + toggleIconLabels: () => + dispatch( 'core/edit-post' ).toggleFeature( 'showIconLabels' ), }; } ) )( OptionsModal ); diff --git a/packages/edit-post/src/components/options-modal/options/base.js b/packages/edit-post/src/components/options-modal/options/base.js index cef8fe130b268..52f9db7ad4e11 100644 --- a/packages/edit-post/src/components/options-modal/options/base.js +++ b/packages/edit-post/src/components/options-modal/options/base.js @@ -3,17 +3,13 @@ */ import { CheckboxControl } from '@wordpress/components'; -function BaseOption( { label, isChecked, onChange, children } ) { - return ( -
- - { children } -
- ); -} +const BaseOption = ( { label, isChecked, onChange } ) => ( + +); export default BaseOption; diff --git a/packages/edit-post/src/components/options-modal/options/index.js b/packages/edit-post/src/components/options-modal/options/index.js index 6ba7b4c54c7da..403c8ec6c3990 100644 --- a/packages/edit-post/src/components/options-modal/options/index.js +++ b/packages/edit-post/src/components/options-modal/options/index.js @@ -2,3 +2,5 @@ export { default as EnableCustomFieldsOption } from './enable-custom-fields'; export { default as EnablePanelOption } from './enable-panel'; export { default as EnablePluginDocumentSettingPanelOption } from './enable-plugin-document-setting-panel'; export { default as EnablePublishSidebarOption } from './enable-publish-sidebar'; +export { default as EnableTipsOption } from './enable-tips'; +export { default as ShowIconLabels } from './show-icon-labels'; diff --git a/packages/edit-post/src/components/options-modal/options/show-icon-labels.js b/packages/edit-post/src/components/options-modal/options/show-icon-labels.js new file mode 100644 index 0000000000000..e8a87e1b29fec --- /dev/null +++ b/packages/edit-post/src/components/options-modal/options/show-icon-labels.js @@ -0,0 +1,22 @@ +/** + * WordPress dependencies + */ +import { compose } from '@wordpress/compose'; +import { withSelect, withDispatch } from '@wordpress/data'; + +/** + * Internal dependencies + */ +import BaseOption from './base'; + +export default compose( + withSelect( ( select ) => ( { + isChecked: select( 'core/edit-post' ).isFeatureActive( + 'showIconLabels' + ), + } ) ), + withDispatch( ( dispatch ) => ( { + onChange: () => + dispatch( 'core/edit-post' ).toggleFeature( 'showIconLabels' ), + } ) ) +)( BaseOption ); diff --git a/packages/edit-post/src/components/options-modal/test/__snapshots__/index.js.snap b/packages/edit-post/src/components/options-modal/test/__snapshots__/index.js.snap index 438c185faca3e..396b6eadbffbd 100644 --- a/packages/edit-post/src/components/options-modal/test/__snapshots__/index.js.snap +++ b/packages/edit-post/src/components/options-modal/test/__snapshots__/index.js.snap @@ -55,5 +55,12 @@ exports[`OptionsModal should match snapshot when the modal is active 1`] = ` +
+ +
`; From 7aa7f88064dbc480aba0c4d0b2d2b29732989b13 Mon Sep 17 00:00:00 2001 From: Vadim Nicolai Date: Fri, 20 Mar 2020 00:54:38 +0200 Subject: [PATCH 02/21] Updated HeaderToolbar. --- .../edit-post/src/components/header/header-toolbar/index.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/edit-post/src/components/header/header-toolbar/index.js b/packages/edit-post/src/components/header/header-toolbar/index.js index 539c3e7afd876..9d05d63766b17 100644 --- a/packages/edit-post/src/components/header/header-toolbar/index.js +++ b/packages/edit-post/src/components/header/header-toolbar/index.js @@ -27,15 +27,18 @@ const inserterToggleProps = { isPrimary: true }; function HeaderToolbar() { const { hasFixedToolbar, - showInserter, isTextModeEnabled, previewDeviceType, showIconLabels, + showInserter, } = useSelect( ( select ) => ( { hasFixedToolbar: select( 'core/edit-post' ).isFeatureActive( 'fixedToolbar' ), + showIconLabels: select( 'core/edit-post' ).isFeatureActive( + 'showIconLabels' + ), // This setting (richEditingEnabled) should not live in the block editor's setting. showInserter: select( 'core/edit-post' ).getEditorMode() === 'visual' && From 8370fa34dbb3b988707ed02599aa15214e599485 Mon Sep 17 00:00:00 2001 From: Vadim Nicolai Date: Wed, 8 Apr 2020 12:19:40 +0300 Subject: [PATCH 03/21] Conflicts fixed. --- .../edit-post/src/components/header/index.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/packages/edit-post/src/components/header/index.js b/packages/edit-post/src/components/header/index.js index 7dca19d07f57a..190cd760dfe7f 100644 --- a/packages/edit-post/src/components/header/index.js +++ b/packages/edit-post/src/components/header/index.js @@ -1,3 +1,8 @@ +/** + * External dependencies + */ +import classnames from 'classnames'; + /** * WordPress dependencies */ @@ -19,12 +24,13 @@ import PreviewOptions from '../preview-options'; function Header() { const { - shortcut, + getBlockSelectionStart, hasActiveMetaboxes, isEditorSidebarOpened, isPublishSidebarOpened, isSaving, - getBlockSelectionStart, + shortcut, + showIconLabels, } = useSelect( ( select ) => ( { shortcut: select( @@ -87,11 +93,14 @@ function Header() { forceIsSaving={ isSaving } /> -`; - -exports[`ColorPalette Dropdown should render it correctly 1`] = ` - -
- - - -
-
-`; - -exports[`ColorPalette should allow disabling custom color picker 1`] = ` - - - Clear - - - } - options={ - Array [ -