Skip to content

Commit

Permalink
Added disableAlpha prop to CustomGradientPicker and GradientPicker co…
Browse files Browse the repository at this point in the history
…mponents (#66974)

* add enableAlpha prop to GradientPicker and custom-gradient-picker

* Update packages/components/CHANGELOG.md

Co-authored-by: Lena Morita <[email protected]>

* Update packages/components/src/custom-gradient-picker/types.ts

Co-authored-by: Lena Morita <[email protected]>

* Update packages/components/src/gradient-picker/types.ts

Co-authored-by: Lena Morita <[email protected]>

* packages/components/src/gradient-picker/README.md update

---------

Unlinked contributors: wwdes.

Co-authored-by: tyxla <[email protected]>
Co-authored-by: mirka <[email protected]>
  • Loading branch information
3 people authored Dec 2, 2024
1 parent 66d952b commit 6ef2f24
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

## Unreleased

### Enhancements

- `GradientPicker`: Add `enableAlpha` prop ([#66974](https://github.com/WordPress/gutenberg/pull/66974))
- `CustomGradientPicker`: Add `enableAlpha` prop ([#66974](https://github.com/WordPress/gutenberg/pull/66974))

### Deprecations

- `BoxControl`: Passive deprecate `onMouseOver`/`onMouseOut`. Pass to the `inputProps` prop instead ([#67332](https://github.com/WordPress/gutenberg/pull/67332)).
Expand Down
2 changes: 2 additions & 0 deletions packages/components/src/custom-gradient-picker/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ const GradientTypePicker = ( {
export function CustomGradientPicker( {
value,
onChange,
enableAlpha = true,
__experimentalIsRenderedInSidebar = false,
}: CustomGradientPickerProps ) {
const { gradientAST, hasGradient } = getGradientAstWithDefault( value );
Expand Down Expand Up @@ -167,6 +168,7 @@ export function CustomGradientPicker( {
__experimentalIsRenderedInSidebar={
__experimentalIsRenderedInSidebar
}
disableAlpha={ ! enableAlpha }
background={ background }
hasGradient={ hasGradient }
value={ controlPoints }
Expand Down
6 changes: 6 additions & 0 deletions packages/components/src/custom-gradient-picker/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ export type CustomGradientPickerProps = {
* the `currentGradient` as an argument.
*/
onChange: ( currentGradient: string ) => void;
/**
* Whether to enable alpha transparency options in the picker.
*
* @default true
*/
enableAlpha?: boolean;
/**
* Whether this is rendered in the sidebar.
*
Expand Down
8 changes: 8 additions & 0 deletions packages/components/src/gradient-picker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,14 @@ gradients from `gradients` will be shown.
- Required: No
- Default: `false`

### `enableAlpha`

Whether to enable alpha transparency options in the picker.

- Type: `boolean`
- Required: No
- Default: `true`

### `gradients`

An array of objects as predefined gradients displayed above the gradient
Expand Down
2 changes: 2 additions & 0 deletions packages/components/src/gradient-picker/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ export function GradientPicker( {
onChange,
value,
clearable = true,
enableAlpha = true,
disableCustomGradients = false,
__experimentalIsRenderedInSidebar,
headingLevel = 2,
Expand All @@ -230,6 +231,7 @@ export function GradientPicker( {
__experimentalIsRenderedInSidebar={
__experimentalIsRenderedInSidebar
}
enableAlpha={ enableAlpha }
value={ value }
onChange={ onChange }
/>
Expand Down
6 changes: 6 additions & 0 deletions packages/components/src/gradient-picker/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ type GradientPickerBaseProps = {
* @default true
*/
loop?: boolean;
/**
* Whether to enable alpha transparency options in the picker.
*
* @default true
*/
enableAlpha?: boolean;
} & (
| {
// TODO: [#54055] Either this or `aria-labelledby` should be required
Expand Down

1 comment on commit 6ef2f24

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in 6ef2f24.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/12129584344
📝 Reported issues:

Please sign in to comment.