Skip to content

Commit

Permalink
Revert "Style Book: Add color tab (WordPress#65692)"
Browse files Browse the repository at this point in the history
This reverts commit 5437114.
  • Loading branch information
benazeer-ben committed Oct 25, 2024
1 parent 519f7b7 commit 4184b4b
Show file tree
Hide file tree
Showing 10 changed files with 85 additions and 455 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ export default function useMultipleOriginColorsAndGradients() {
'Theme',
'Indicates this palette comes from the theme.'
),
slug: 'theme',
colors: themeColors,
} );
}
Expand All @@ -69,17 +68,15 @@ export default function useMultipleOriginColorsAndGradients() {
'Default',
'Indicates this palette comes from WordPress.'
),
slug: 'default',
colors: defaultColors,
} );
}
if ( customColors && customColors.length ) {
result.push( {
name: _x(
'Custom',
'Indicates this palette is created by the user.'
'Indicates this palette comes from the theme.'
),
slug: 'custom',
colors: customColors,
} );
}
Expand All @@ -99,7 +96,6 @@ export default function useMultipleOriginColorsAndGradients() {
'Theme',
'Indicates this palette comes from the theme.'
),
slug: 'theme',
gradients: themeGradients,
} );
}
Expand All @@ -113,7 +109,6 @@ export default function useMultipleOriginColorsAndGradients() {
'Default',
'Indicates this palette comes from WordPress.'
),
slug: 'default',
gradients: defaultGradients,
} );
}
Expand All @@ -123,7 +118,6 @@ export default function useMultipleOriginColorsAndGradients() {
'Custom',
'Indicates this palette is created by the user.'
),
slug: 'custom',
gradients: customGradients,
} );
}
Expand Down
11 changes: 0 additions & 11 deletions packages/edit-site/src/components/global-styles/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ import ScreenCSS from './screen-css';
import ScreenRevisions from './screen-revisions';
import { unlock } from '../../lock-unlock';
import { store as editSiteStore } from '../../store';
import { STYLE_BOOK_COLOR_GROUPS } from '../style-book/constants';

const SLOT_FILL_NAME = 'GlobalStylesMenu';
const { useGlobalStylesReset } = unlock( blockEditorPrivateApis );
Expand Down Expand Up @@ -192,16 +191,6 @@ function GlobalStylesStyleBook() {
)
}
onSelect={ ( blockName ) => {
if (
STYLE_BOOK_COLOR_GROUPS.find(
( group ) => group.slug === blockName
)
) {
// Go to color palettes Global Styles.
navigator.goTo( '/colors/palette' );
return;
}

// Now go to the selected block.
navigator.goTo( '/blocks/' + encodeURIComponent( blockName ) );
} }
Expand Down
44 changes: 0 additions & 44 deletions packages/edit-site/src/components/style-book/color-examples.tsx

This file was deleted.

80 changes: 5 additions & 75 deletions packages/edit-site/src/components/style-book/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,52 +6,7 @@ import { __ } from '@wordpress/i18n';
/**
* Internal dependencies
*/
import type { StyleBookCategory, StyleBookColorGroup } from './types';

export const STYLE_BOOK_COLOR_GROUPS: StyleBookColorGroup[] = [
{
slug: 'theme-colors',
title: __( 'Theme Colors' ),
origin: 'theme',
type: 'colors',
},
{
slug: 'theme-gradients',
title: __( 'Theme Gradients' ),
origin: 'theme',
type: 'gradients',
},
{
slug: 'custom-colors',
title: __( 'Custom Colors' ),
origin: 'custom',
type: 'colors',
},
{
slug: 'custom-gradients',
title: __( 'Custom Gradients' ),
origin: 'custom', // User.
type: 'gradients',
},
{
slug: 'duotones',
title: __( 'Duotones' ),
origin: 'theme',
type: 'duotones',
},
{
slug: 'default-colors',
title: __( 'Default Colors' ),
origin: 'default',
type: 'colors',
},
{
slug: 'default-gradients',
title: __( 'Default Gradients' ),
origin: 'default',
type: 'gradients',
},
];
import type { StyleBookCategory } from './types';

export const STYLE_BOOK_THEME_SUBCATEGORIES: Omit<
StyleBookCategory,
Expand Down Expand Up @@ -119,7 +74,7 @@ export const STYLE_BOOK_CATEGORIES: StyleBookCategory[] = [
{
slug: 'colors',
title: __( 'Colors' ),
blocks: [],
blocks: [ 'custom/colors' ],
},
{
slug: 'theme',
Expand Down Expand Up @@ -156,7 +111,7 @@ export const STYLE_BOOK_IFRAME_STYLES = `
.is-root-container {
display: flow-root;
}
body {
position: relative;
padding: 32px !important;
Expand Down Expand Up @@ -186,40 +141,15 @@ export const STYLE_BOOK_IFRAME_STYLES = `
box-shadow: 0 0 0 1px var(--wp-components-color-accent, var(--wp-admin-theme-color, #007cba));
}
.edit-site-style-book__example.is-disabled-example {
pointer-events: none;
}
.edit-site-style-book__example:focus:not(:disabled) {
box-shadow: 0 0 0 var(--wp-admin-border-width-focus) var(--wp-components-color-accent, var(--wp-admin-theme-color, #007cba));
outline: 3px solid transparent;
}
.edit-site-style-book__duotone-example > div:first-child {
display: flex;
aspect-ratio: 16 / 9;
grid-row: span 1;
grid-column: span 2;
}
.edit-site-style-book__duotone-example img {
width: 100%;
height: 100%;
object-fit: cover;
}
.edit-site-style-book__duotone-example > div:not(:first-child) {
height: 20px;
border: 1px solid #ddd;
}
.edit-site-style-book__color-example {
height: 52px;
border: 1px solid #ddd;
}
.edit-site-style-book__examples.is-wide .edit-site-style-book__example {
flex-direction: row;
}
.edit-site-style-book__subcategory-title,
.edit-site-style-book__example-title {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
Expand All @@ -230,7 +160,7 @@ export const STYLE_BOOK_IFRAME_STYLES = `
text-align: left;
text-transform: uppercase;
}
.edit-site-style-book__subcategory-title {
font-size: 16px;
margin-bottom: 40px;
Expand Down
53 changes: 0 additions & 53 deletions packages/edit-site/src/components/style-book/duotone-examples.tsx

This file was deleted.

63 changes: 63 additions & 0 deletions packages/edit-site/src/components/style-book/examples.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/**
* WordPress dependencies
*/
import { __, sprintf } from '@wordpress/i18n';
import {
getBlockType,
getBlockTypes,
getBlockFromExample,
createBlock,
} from '@wordpress/blocks';

/**
* Internal dependencies
*/
import type { BlockExample } from './types';

/**
* Returns a list of examples for registered block types.
*
* @return {BlockExample[]} An array of block examples.
*/
export function getExamples(): BlockExample[] {
const nonHeadingBlockExamples = getBlockTypes()
.filter( ( blockType ) => {
const { name, example, supports } = blockType;
return (
name !== 'core/heading' &&
!! example &&
supports.inserter !== false
);
} )
.map( ( blockType ) => ( {
name: blockType.name,
title: blockType.title,
category: blockType.category,
blocks: getBlockFromExample( blockType.name, blockType.example ),
} ) );
const isHeadingBlockRegistered = !! getBlockType( 'core/heading' );

if ( ! isHeadingBlockRegistered ) {
return nonHeadingBlockExamples;
}

// Use our own example for the Heading block so that we can show multiple
// heading levels.
const headingsExample = {
name: 'core/heading',
title: __( 'Headings' ),
category: 'text',
blocks: [ 1, 2, 3, 4, 5, 6 ].map( ( level ) => {
return createBlock( 'core/heading', {
content: sprintf(
// translators: %d: heading level e.g: "1", "2", "3"
__( 'Heading %d' ),
level
),
level,
} );
} ),
};

return [ headingsExample, ...nonHeadingBlockExamples ];
}
Loading

0 comments on commit 4184b4b

Please sign in to comment.