Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify color control #220

Merged
merged 3 commits into from
Oct 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 16 additions & 22 deletions src/controls/color-control.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,28 +76,22 @@ export default function ColorControl( {
{ __( 'Reset', 'flexible-table-block' ) }
</Button>
</div>
<div className="ftb-color-control__controls">
<div className="ftb-color-control__controls-inner">
<div className="ftb-color-control__controls-row">
<ColorIndicatorButton
label={ __( 'All', 'flexible-table-block' ) }
value={ value }
onClick={ handleOnPickerOpen }
isNone={ ! value }
isTransparent={ value === 'transparent' }
/>
{ isPickerOpen && (
<Popover className="ftb-color-control__popover" onClose={ handleOnPickerClose }>
<ColorPalette
colors={ [ ...colors, ...colorsProp ] }
value={ value || '' }
onChange={ handleOnChange }
/>
</Popover>
) }
</div>
</div>
</div>
<ColorIndicatorButton
label={ __( 'Color', 'flexible-table-block' ) }
value={ value }
onClick={ handleOnPickerOpen }
isNone={ ! value }
isTransparent={ value === 'transparent' }
/>
{ isPickerOpen && (
<Popover className="ftb-color-control__popover" onClose={ handleOnPickerClose }>
<ColorPalette
colors={ [ ...colors, ...colorsProp ] }
value={ value || '' }
onChange={ handleOnChange }
/>
</Popover>
) }
</div>
{ /* @ts-ignore Slot is not currently typed on Popover */ }
<Popover.Slot />
Expand Down
2 changes: 0 additions & 2 deletions src/controls/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@

// Controls styles.
.ftb-border-color-control__controls,
.ftb-color-control__controls,
.ftb-border-spacing-control__controls {
display: flex;
align-items: flex-start;
Expand All @@ -213,7 +212,6 @@

// Controls row styles.
.ftb-border-color-control__controls-row,
.ftb-color-control__controls-row,
.ftb-border-spacing-control__controls-row {
display: flex;
align-items: center;
Expand Down
6 changes: 3 additions & 3 deletions test/e2e/specs/global-setting.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ test.describe( 'Global Setting', () => {
for ( let i = 0; i < tableColors.length; i++ ) {
await page
.getByRole( 'dialog', { name: 'Flexible Table Block Global setting' } )
.getByRole( 'button', { name: 'All' } )
.getByRole( 'button', { name: 'Color' } )
.nth( i )
.click();
await pageUtils.pressKeys( 'Enter' );
Expand All @@ -69,7 +69,7 @@ test.describe( 'Global Setting', () => {
for ( let i = 0; i < cellColors.length; i++ ) {
await page
.getByRole( 'dialog', { name: 'Flexible Table Block Global setting' } )
.getByRole( 'button', { name: 'All' } )
.getByRole( 'button', { name: 'Color' } )
.nth( i )
.click();
await pageUtils.pressKeys( 'Enter' );
Expand All @@ -82,7 +82,7 @@ test.describe( 'Global Setting', () => {
await page.getByRole( 'spinbutton', { name: 'Right' } ).fill( '2' );
await page.getByRole( 'spinbutton', { name: 'Bottom' } ).fill( '3' );
await page.getByRole( 'spinbutton', { name: 'Left' } ).fill( '4' );
// Change cell border with.
// Change cell border width.
await page.getByRole( 'spinbutton', { name: 'All' } ).fill( '2' );
// Change cell border style.
await page.getByRole( 'button', { name: 'Dotted' } ).click();
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/specs/table-style.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ async function applyCellStyles( page, pageUtils ) {
const cellTextColorId = await page.getByText( 'Cell text color' ).getAttribute( 'id' );
await page
.locator( `[aria-labelledby="${ cellTextColorId }"]` )
.getByRole( 'button', { name: 'All' } )
.getByRole( 'button', { name: 'Color' } )
.click();
await pageUtils.pressKeys( 'Enter' );
await page.getByRole( 'textbox', { name: 'Hex color' } ).fill( '111111' );
Expand All @@ -34,7 +34,7 @@ async function applyCellStyles( page, pageUtils ) {
.getAttribute( 'id' );
await page
.locator( `[aria-labelledby="${ cellBackgroundColorId }"]` )
.getByRole( 'button', { name: 'All' } )
.getByRole( 'button', { name: 'Color' } )
.click();
await pageUtils.pressKeys( 'Enter' );
await page.getByRole( 'textbox', { name: 'Hex color' } ).fill( '333333' );
Expand Down
Loading