Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
19358d7
Post Featured Image: Fix height/scale overwriting border inline style…
aaronrobertshaw Sep 19, 2022
cfe41d8
Fluid typography: add font size constraints (#44993)
ramonjd Oct 18, 2022
c1d0fb8
Allow direct selection of nested Page List block by avoiding dual ren…
getdave Oct 20, 2022
27fc28f
Fix popover deprecations (#45195)
talldan Oct 26, 2022
d1e989b
Components: Refactor `ColorPalette` tests to `@testing-library/react`…
tyxla Sep 15, 2022
b7c87a9
Fix changelog
Mamaduka Nov 10, 2022
a69ad93
Convert the `ColorPalette` component to TypeScript (#44632)
kienstra Oct 26, 2022
1d6e86f
List v2: fix migration when nested list is invalid (#44822)
ellatrix Oct 28, 2022
5df9d42
Link to homeUrl from site editor view menu. (#45475)
peterwilsoncc Nov 3, 2022
86755ae
Table Block: Apply borders and padding on both front end and editor (…
mikachan Nov 4, 2022
2406bb9
Change the order of the pseudo-states in the pseudo selectors array (…
mikachan Nov 7, 2022
78717bd
Do not look for block variants, if not supporting block-templates (#4…
spacedmonkey Nov 8, 2022
bcff52e
Restore the empty paragraph inserter (#45542)
youknowriad Nov 9, 2022
d6485c6
Cover: Avoid content loss when the templateLock value is all or conte…
Mamaduka Nov 10, 2022
035afba
List: disable nested list drop zone so dropping list items works (#45…
ellatrix Nov 10, 2022
6941ad1
Fix cherry-picking error
Mamaduka Nov 10, 2022
67b7b5e
Switch background color to text color on block separator (#44943)
cbravobernal Nov 2, 2022
3b4797b
Fix performance tests
Mamaduka Nov 10, 2022
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
Prev Previous commit
Next Next commit
Convert the ColorPalette component to TypeScript (#44632)
* Convert the ColorPalette component to TypeScript

    There are some ts-ignore statements
    that would be good to remove.

* Correct the PR number in the CHANGELOG

* Apply Marco's suggestion to remove ts-ignore comments

Destructure props int constants after the function
signature, not inside it.

* Replace complex type with ReactNode, thanks to Marco's suggestion

* Apply Marco's suggestions for TS verbatim

#44632 (review)

* Prevent an error from colors possibly being undefined

Types of property 'colors' are incompatible.
  Type 'Colors | undefined' is not assignable to type '(Color | MultipleColors)[]'.
    Type 'undefined' is not assignable to type '(Color | MultipleColors)[]'.

* Rename Color and MultipleColors to ColorObject and PaletteObject

* Alphabetize the imports again

* Remove another needless ts-ignore comment

* Revert "Prevent an error from colors possibly being undefined"

This reverts commit 7fe648e.

* Make colors allow undefined

* Make actions optional, which I forgot before

* Commit Marco's changes, including a named export

* Add default tags, thanks to Marco's idea

* Apply Marco's suggestion to remove ts-ignore

Add 'as CSSProperties'
to remove the need for ts-ignore

* Apply Marco's suggestions, creating UnforwardedColorProps

The jsx example might not be right.
Also, I added a description for the component
in the JS DocBlock, as there wasn't one in README.md.
But maybe that's not right.

* Fix a linting error, remove needless className

* Commit Marco's suggestion: Update packages/components/src/color-palette/stories/index.tsx

Co-authored-by: Marco Ciampini <[email protected]>

* Commit Marco's suggestion: Update packages/components/src/color-palette/types.ts

Co-authored-by: Marco Ciampini <[email protected]>

* Rename test/index.js to test/indes.tsx, mv snapshot

* Add types to test/index.tsx

* Renamce styles.js to styles.ts

* Commit Marco's suggestion: Update packages/components/src/color-palette/types.ts

Co-authored-by: Marco Ciampini <[email protected]>

* Revert "Add types to test/index.tsx"

This reverts commit 06f7c4e.

* Paste Marco's description verbatim

#44632 (review)

* Copy props verbatim from types.ts into README.md

* Update the JSDoc description to be the same as the README.md description

The usage example was already the same
as in the README.md

* Remove extra entry for Tooltip

I think I added this
when merging in trunk and resolving the conflicts.

* Move the CHANGELOG entry up, to Unreleased

* Move Usage section to the top of the README. remove experimental props from README

* Commit Marco's suggestion: Update packages/components/src/color-palette/README.md

Co-authored-by: Marco Ciampini <[email protected]>

* Remove the example of the full props

* Change the props format to match CONTRIBUTING.md

https://github.com/WordPress/gutenberg/blob/a42805e157f6c6933f4ef7cabcfc87fa3af81aea/packages/components/CONTRIBUTING.md#readme-example

* Commit Marco's suggestion: Update packages/components/src/color-palette/stories/index.tsx

Co-authored-by: Marco Ciampini <[email protected]>

* Commit Marco's suggestion: Update packages/components/src/color-palette/types.ts

Co-authored-by: Marco Ciampini <[email protected]>

* Commit Marco's suggestion: Update packages/components/src/color-palette/types.ts

Co-authored-by: Marco Ciampini <[email protected]>

* Commit Marco's suggestion: Update packages/components/src/color-palette/types.ts

Co-authored-by: Marco Ciampini <[email protected]>

Co-authored-by: Marco Ciampini <[email protected]>
  • Loading branch information
2 people authored and Mamaduka committed Nov 10, 2022
commit a69ad93cf5afd9d85b9e18b77a064261ede1ead9
1 change: 1 addition & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
### Internal

- `NavigationMenu` updated to ignore `react/exhaustive-deps` eslint rule ([#44090](https://github.com/WordPress/gutenberg/pull/44090)).
- `ColorPalette`: Convert to TypeScript ([#44632](https://github.com/WordPress/gutenberg/pull/44632)).

## 21.0.0 (2022-09-13)

Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/border-control/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export type Border = {

export type Color = {
name: string;
color: CSSProperties[ 'color' ];
color: NonNullable< CSSProperties[ 'color' ] >;
};

export type ColorOrigin = {
Expand Down
34 changes: 14 additions & 20 deletions packages/components/src/circular-option-picker/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@ import Button from '../button';
import Dropdown from '../dropdown';
import Tooltip from '../tooltip';

function Option( {
className,
isSelected,
selectedIconProps,
tooltipText,
...additionalProps
} ) {
function Option( props ) {
const {
className,
isSelected,
selectedIconProps,
tooltipText,
...additionalProps
} = props;
const optionButton = (
<Button
isPressed={ isSelected }
Expand Down Expand Up @@ -52,12 +53,8 @@ function Option( {
);
}

function DropdownLinkAction( {
buttonProps,
className,
dropdownProps,
linkText,
} ) {
function DropdownLinkAction( props ) {
const { buttonProps, className, dropdownProps, linkText } = props;
return (
<Dropdown
className={ classnames(
Expand All @@ -80,7 +77,8 @@ function DropdownLinkAction( {
);
}

function ButtonAction( { className, children, ...additionalProps } ) {
function ButtonAction( props ) {
const { className, children, ...additionalProps } = props;
return (
<Button
className={ classnames(
Expand All @@ -95,12 +93,8 @@ function ButtonAction( { className, children, ...additionalProps } ) {
);
}

export default function CircularOptionPicker( {
actions,
className,
options,
children,
} ) {
export default function CircularOptionPicker( props ) {
const { actions, className, options, children } = props;
return (
<div
className={ classnames(
Expand Down
100 changes: 51 additions & 49 deletions packages/components/src/color-palette/README.md
Original file line number Diff line number Diff line change
@@ -1,54 +1,6 @@
# ColorPalette

## Props

The component accepts the following props.

{ colors, disableCustomColors = false, value, onChange, className, clearable = true }

### colors

Array with the colors to be shown.

- Type: `Array`
- Required: Yes

### disableCustomColors

Whether to allow custom color or not.

- Type: `Boolean`
- Required: No
- Default: false

### value

currently active value

- Type: `String`
- Required: No

### onChange

Callback called when a color is selected.

- Type: `Function`
- Required: Yes

### className

classes to be applied to the container.

- Type: `String`
- Required: No

### clearable

Whether the palette should have a clearing button or not.

- Type: `Boolean`
- Required: No
- Default: true
`ColorPalette` allows the user to pick a color from a list of pre-defined color entries.

## Usage

Expand Down Expand Up @@ -79,3 +31,53 @@ If you're using this component outside the editor, you can
for the `ColorPalette`'s color swatches, by rendering your `ColorPalette` with a
`Popover.Slot` further up the element tree and within a
`SlotFillProvider` overall.

## Props

The component accepts the following props.

### `colors`: `( PaletteObject | ColorObject )[]`

Array with the colors to be shown. When displaying multiple color palettes to choose from, the format of the array changes from an array of colors objects, to an array of color palettes.

- Required: No
- Default: `[]`

### `disableCustomColors`: `boolean`

Whether to allow the user to pick a custom color on top of the predefined choices (defined via the `colors` prop).

- Required: No
- Default: `false`

### `enableAlpha`: `boolean`

Whether the color picker should display the alpha channel both in the bottom inputs as well as in the color picker itself.

- Required: No
- Default: `false`

### `value`: `string`

currently active value

- Required: No

### `onChange`: `OnColorChange`

Callback called when a color is selected.

- Required: Yes

### `className`: `string`

classes to be applied to the container.

- Required: No

### `clearable`: `boolean`

Whether the palette should have a clearing button.

- Required: No
- Default: `true`
Loading