Skip to content

Commit

Permalink
add enableAlpha prop to GradientPicker and custom-gradient-picker
Browse files Browse the repository at this point in the history
  • Loading branch information
wwdes committed Nov 26, 2024
1 parent 6cc6035 commit acf91da
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## Unreleased

- `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

- `DimensionControl`: Deprecate 36px default size ([#66705](https://github.com/WordPress/gutenberg/pull/66705)).
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 disable 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 disable 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 disable alpha transparency options in the picker.
*
* @default true
*/
enableAlpha?: boolean;
} & (
| {
// TODO: [#54055] Either this or `aria-labelledby` should be required
Expand Down

0 comments on commit acf91da

Please sign in to comment.