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

Added disableAlpha prop to CustomGradientPicker and GradientPicker components #66974

Merged
merged 5 commits into from
Dec 2, 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
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
mirka marked this conversation as resolved.
Show resolved Hide resolved

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

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