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

Duotone Tracking & History #26361

Closed
wants to merge 162 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
162 commits
Select commit Hold shift + click to select a range
dc31379
Add noFilter icon for duotone
ajlende Sep 29, 2020
94bef4d
Add duotone support docs
ajlende Sep 29, 2020
469e883
Add initial duotone block support PHP
ajlende Sep 29, 2020
64eefdb
Refactor duotone support
ajlende Oct 7, 2020
0d9e24f
Move Duotone component into hooks to match php
ajlende Oct 7, 2020
4fa9b2a
Rename duotoneColors -> duotoneValues to be more precise
ajlende Oct 7, 2020
e7cf0d7
Move duotone support to theme.json
ajlende Oct 12, 2020
55cc946
Export CircularOptionPicker from components
ajlende Oct 12, 2020
78c215a
Refactor to use slug instead of generated id
ajlende Oct 12, 2020
d09cc98
Add custom color picker view
ajlende Oct 13, 2020
b548314
Remove base-control styling
ajlende Oct 13, 2020
9200a4d
Add custom colors
ajlende Oct 13, 2020
0fae265
Remove duotone export
ajlende Oct 16, 2020
2356a10
Use nullish coalescing operator instead of overloaded boolean or
ajlende Oct 16, 2020
dd405b0
Add support for multiple selectors
ajlende Oct 16, 2020
ddcd60b
Merge branch 'master' into add/duotone-filter
ajlende Oct 21, 2020
9ba0a10
Add render_block filter for the new class-wp-block-supports
ajlende Oct 21, 2020
5501d10
Render duotone with the new class-wp-block-supports
ajlende Oct 21, 2020
ca1e152
Refactor out duotone filter style & svg
ajlende Oct 22, 2020
70a80d7
Merge branch 'master' into add/duotone-filter
ajlende Oct 22, 2020
216656d
Add duotone support manually to image block
ajlende Nov 3, 2020
9cc0cf2
Auto-select alternate color when selecting first color
ajlende Nov 3, 2020
10907ff
Merge branch 'master' into add/duotone-filter
ajlende Nov 3, 2020
0af2b91
Fix lint
ajlende Nov 3, 2020
b427f37
Add a larger default duotone palette
ajlende Nov 3, 2020
6479f42
Move default duotone palette to experimental-default-theme.json
ajlende Nov 3, 2020
c89892b
Polish toolbar popover
ajlende Nov 3, 2020
053b430
Simplify choosing default colors for palettes with fewer than two colors
ajlende Nov 3, 2020
057047b
Hide on outside focus
ajlende Nov 3, 2020
89583cd
Fix duotone support php
ajlende Nov 3, 2020
a0d80ec
Remove DuotoneFilter scope prop
ajlende Nov 3, 2020
551d9e7
Add duotone block supports to media-text
ajlende Nov 3, 2020
a23d3c9
Move duotone supports to before the toolbar
ajlende Nov 4, 2020
b2417ff
Fix double-applied filter
ajlende Nov 4, 2020
66d42d8
Refactor to store duotone id instead of slug
ajlende Nov 5, 2020
b2e7ffd
Merge branch 'master' into add/duotone-filter
ajlende Nov 5, 2020
38e5488
Add min-width to duotone toolbar popover
ajlende Nov 5, 2020
0fb8788
Merge branch 'master' into add/duotone-filter
ajlende Dec 15, 2020
049a83e
Add duotone swatch i18n
ajlende Dec 15, 2020
2898abb
Add duotone to theme.json schema
ajlende Dec 15, 2020
1505f15
Refactor out custom duotone picker
ajlende Dec 16, 2020
787faa2
Refactor out duotone popover
ajlende Dec 16, 2020
9e60727
WIP Refactor out CSS gradient from custom-gradient-bar
ajlende Dec 16, 2020
27842fc
Refactor out CSS gradient from custom-gradient-bar
ajlende Dec 16, 2020
68b843d
Simplify initialPositions
ajlende Dec 16, 2020
a0d58ec
Remove unused initialPositions
ajlende Dec 16, 2020
f59f67b
Refactor gradient picker utils
ajlende Dec 16, 2020
84cfdf9
Refactor ControlPointKeyboardMove as function component
ajlende Dec 16, 2020
d64261c
Move InserterPoint to ControlPoints
ajlende Dec 16, 2020
f72a636
Refactor CustomGradientPicker
ajlende Dec 16, 2020
a2e34c9
Remove unused code
ajlende Dec 18, 2020
2a12275
Update color documentation
ajlende Dec 18, 2020
8e158b3
Simplify distance constant
ajlende Dec 18, 2020
bff8620
Refactor to use number instead of percent string
ajlende Dec 18, 2020
3e03411
Use tinycolor to convert to css string
ajlende Dec 18, 2020
14e1d20
Simplify control points serialization
ajlende Dec 18, 2020
015b475
Restore MINIMUM_DISTANCE_BETWEEN_POINTS constant
ajlende Dec 30, 2020
e152bfc
Move custom-gradient-bar into its own folder
ajlende Dec 30, 2020
ac8965b
Simplify clampPercent
ajlende Dec 30, 2020
7129936
get custom duotone id from hex colors
ajlende Jan 12, 2021
f62de2f
Add check for hex colors
ajlende Jan 13, 2021
7fff154
Cover all cases for gradient-parser color stop
ajlende Jan 13, 2021
7c3e27e
Merge branch 'master' into tmp/duotone-filter
ajlende Jan 27, 2021
ab62524
Refactor custom gradient bar events to not fire as often
ajlende Jan 14, 2021
20f2c5b
Refactor out frequent update to ref
ajlende Jan 16, 2021
7958b0a
Move controlPoint map to CustomGradientBar
ajlende Jan 16, 2021
4aa7c49
Merge branch 'master' into tmp/duotone-filter
ajlende Jan 28, 2021
972a119
Revert partial gradient picker changes
ajlende Jan 28, 2021
feddad3
Add angle to gradient generator
ajlende Feb 1, 2021
0f9a42e
Convert toBrightness to tinycolor
ajlende Feb 1, 2021
1f22adc
Update comments
ajlende Feb 1, 2021
4cee404
Fix one missing tinycolor rgb string
ajlende Feb 3, 2021
3d96e1e
Add duotone picker bar
ajlende Feb 3, 2021
d495baf
Add disableInserter prop to CustomGradientBar
ajlende Feb 5, 2021
2820ac1
Disable inserter for duotone bar
ajlende Feb 5, 2021
be9f51a
Revert gradient bar tinycolor change
ajlende Feb 5, 2021
1f9684f
Use stored color strings
ajlende Feb 5, 2021
527da58
Merge branch 'master' into tmp/duotone-filter
ajlende Feb 5, 2021
99540f2
Add disableRemove
ajlende Feb 5, 2021
d8716dd
Add duotone cover block support
ajlende Feb 5, 2021
85c63e2
Add duotone supports to video block
ajlende Feb 9, 2021
4a3b64d
Add duotone to cover block transforms
ajlende Feb 9, 2021
09fbc77
Add duotone to media & text block transforms
ajlende Feb 9, 2021
4ad937e
Rename duotone toolbar title
ajlende Feb 9, 2021
8c3d8ad
Increase duotone toolbar width
ajlende Feb 9, 2021
d7d4a72
Disable alpha for duotone bar
ajlende Feb 9, 2021
011ed9b
Refactor out tinycolorToRgb
ajlende Feb 9, 2021
9ccdc74
Refactor out getValuesFromHexColors
ajlende Feb 9, 2021
5bb2931
JSDoc and code cleanup
ajlende Feb 9, 2021
3fbcbbc
Fix disableAlpha typo
ajlende Feb 9, 2021
c2a0c0e
Fix hex string bug
ajlende Feb 9, 2021
0028d8a
Store gradients with rgb colors to match gradient picker
ajlende Feb 9, 2021
9e48dfd
Organize functions
ajlende Feb 9, 2021
f077f4c
Duotone for media & text videos
ajlende Feb 9, 2021
3bf0c7f
Merge branch 'master' into add/duotone-filter
ajlende Feb 11, 2021
26ca4c1
Sanitize duotone attributes
ajlende Feb 12, 2021
c219b42
Update icon, and size.
jasmussen Feb 15, 2021
ded7fb6
Small tweaks
jasmussen Feb 15, 2021
638d105
Try using menugroup.
jasmussen Feb 15, 2021
337b394
More polish.
jasmussen Feb 15, 2021
a2f721e
Merge branch 'master' into add/duotone-filter
ajlende Feb 15, 2021
a139db5
Sentence case i18n duotone strings
ajlende Feb 15, 2021
5521c21
Update presets.
jasmussen Feb 22, 2021
e24f4ea
Merge branch 'master' into add/duotone-filter
ajlende Feb 24, 2021
cb2f270
Move ToolbarGroup to just Block supports
ajlende Feb 24, 2021
6575f48
Make color control visible against white.
jasmussen Feb 25, 2021
fd2c3cf
Make them slightly more flourescent again.
jasmussen Feb 25, 2021
af4361b
Shadow/highlight + further color tweaks.
jasmussen Feb 25, 2021
2a7d18c
Remove description.
jasmussen Feb 26, 2021
fac8c68
Move duotone block supports under color
ajlende Mar 17, 2021
4fc2af3
Fix gradient -> duotone typo
ajlende Mar 18, 2021
3751849
Adjust getBlockSupport duotone calls
ajlende Mar 19, 2021
b01d279
Add duotone to style attribute
ajlende Mar 19, 2021
76f3a88
Merge remote-tracking branch 'upstream/trunk' into add/duotone-filter
ajlende Mar 20, 2021
ef0c44a
Fix _wp_array_get after merge
ajlende Mar 20, 2021
9477bf7
Refactor to use BlockListBlock for styles
ajlende Mar 20, 2021
97d3c90
Revert image block changes
ajlende Mar 20, 2021
1c831e9
Fix set duotone crash
ajlende Mar 20, 2021
70d5e95
Add image block duotone
ajlende Mar 20, 2021
724b8d9
Move duotone to block group of BlockControls
ajlende Mar 20, 2021
1c8703b
Use uniqid for duotone ids
ajlende Mar 23, 2021
5333527
Move duotone support under color in block.json
ajlende Mar 23, 2021
ae7b8dc
Use selector style from __experimentalSelector
ajlende Mar 23, 2021
6a988aa
Update color support docs
ajlende Mar 23, 2021
db6fce0
Update docs
ajlende Mar 24, 2021
ac990ac
Call render_block filter directly
ajlende Mar 24, 2021
f7fdef9
Add back block scope to duotone selector
ajlende Mar 24, 2021
994add7
Hacky fix for nested cover blocks
ajlende Mar 24, 2021
0ae3d7f
DuotoneToolbar -> DuotoneControl
ajlende Mar 29, 2021
624e798
Inline duotone filter php
ajlende Mar 29, 2021
a8dc192
Inline duotone filter js
ajlende Mar 29, 2021
c0fea73
Refactor duotone picker into @wordpress/components
ajlende Mar 31, 2021
c0aeb0a
Merge branch 'trunk' into add/duotone-filter
ajlende Mar 31, 2021
080bb70
Fix style import
ajlende Mar 31, 2021
a37d4af
Revert accidental gradient bar styles
ajlende Mar 31, 2021
806e6ab
Add missing line ending control style
ajlende Mar 31, 2021
84d8520
Un-experimental the duotone control
ajlende Mar 31, 2021
e488658
Add missing line ending control scss
ajlende Mar 31, 2021
611ffb1
Remove duotone from cover video transforms
ajlende Mar 31, 2021
5279560
Fix CSS lint
ajlende Mar 31, 2021
7e8aaed
Update block-editor docs
ajlende Mar 31, 2021
da1320f
Fix php lint
ajlende Mar 31, 2021
e26a7b8
Remove block class from selector
ajlende Mar 31, 2021
1f258eb
Refactor out stylesheet
ajlende Apr 7, 2021
4ef9045
Store only custom duotone values
ajlende Apr 8, 2021
9cdfbf6
Code cleanup
ajlende Apr 8, 2021
4f11efc
Use the newer i18n for theme.json
ajlende Apr 9, 2021
ac90216
Add more details to duotone theme.json docs
ajlende Apr 9, 2021
a757d3b
Revert "Refactor out stylesheet"
ajlende Apr 9, 2021
193549d
Mark duotone support as experimental
ajlende Apr 9, 2021
f72c79f
Merge branch 'trunk' into add/duotone-filter
ajlende Apr 12, 2021
18950fd
Revert "Un-experimental the duotone control"
ajlende Apr 12, 2021
599883d
Revert "Update block-editor docs"
ajlende Apr 12, 2021
edd9589
Update theme json test for duotone i18n
ajlende Apr 12, 2021
ce3c7f2
Implement a subset of tinycolor in duotone in php
ajlende Apr 15, 2021
6261d70
Refactor to parse colors in PHP
ajlende Apr 16, 2021
3f6ddec
Merge branch 'trunk' into add/duotone-filter
ajlende Apr 16, 2021
22b68a6
Fix function redeclaration for tinycolor functions
ajlende Apr 17, 2021
57129b0
Fix php lint
ajlende Apr 19, 2021
03da13a
Fix more php lint
ajlende Apr 19, 2021
d21585a
Fix duotone docs
ajlende Apr 20, 2021
fd15a1c
Update duotone supports docs
ajlende Apr 20, 2021
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
1 change: 1 addition & 0 deletions docs/how-to-guides/themes/theme-json.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ The settings section has the following structure and default values:
"color": {
"custom": true, /* false to opt-out, as in add_theme_support('disable-custom-colors') */
"customGradient": true, /* false to opt-out, as in add_theme_support('disable-custom-gradients') */
"duotone": [ ... ], /* duotone presets, a list of { "colors": [ "#000", "#FFF" ], "slug": "black-and-white", "name": "Black and White" } */
"gradients": [ ... ], /* gradient presets, as in add_theme_support('editor-gradient-presets', ... ) */
"link": false, /* true to opt-in, as in add_theme_support('experimental-link-color') */
"palette": [ ... ], /* color presets, as in add_theme_support('editor-color-palette', ... ) */
Expand Down
228 changes: 198 additions & 30 deletions docs/reference-guides/block-api/block-supports.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,11 @@ supports: {
- Default value: null
- Subproperties:
- `background`: type `boolean`, default value `true`
- `duotone`: type `string`, default value undefined
- `gradients`: type `boolean`, default value `false`
- `text`: type `boolean`, default value `true`

This value signals that a block supports some of the CSS style properties related to color. When it does, the block editor will show UI controls for the user to set their values.

The controls for background and text will source their colors from the `editor-color-palette` [theme support](https://developer.wordpress.org/block-editor/developers/themes/theme-support/#block-color-palettes), while the gradient's from `editor-gradient-presets` [theme support](https://developer.wordpress.org/block-editor/developers/themes/theme-support/#block-gradient-presets).
This value signals that a block supports some of the properties related to color. When it does, the block editor will show UI controls for the user to set their values.

Note that the `text` and `background` keys have a default value of `true`, so if the `color` property is present they'll also be considered enabled:

Expand All @@ -115,58 +114,227 @@ supports: {
}
```

When the block has support for a specific color property, the attributes definition is extended to include some attributes.
### color.background

This property adds UI controls which allow the user to apply a solid background color to a block.

- `style`: attribute of `object` type with no default assigned. This is added when any of support color properties are declared. It stores the custom values set by the user. The block can apply a default style by specifying its own `style` attribute with a default e.g.:
When color support is declared, this property is enabled by default (along with text), so simply setting color will enable background color.

```js
attributes: {
style: {
type: 'object',
default: {
color: {
background: 'value',
gradient: 'value',
text: 'value'
}
}
supports: {
color: true // Enable both background and text
}
```

To disable background support while keeping other color supports enabled, set to `false`.

```js
supports: {
color: {
// Disable background support. Text color support is still enabled.
background: false
}
}
```

- When `background` support is declared: it'll be added a new `backgroundColor` attribute of type `string` with no default assigned. It stores the preset values set by the user. The block can apply a default background color by specifying its own attribute with a default e.g.:
When the block declares support for `color.background`, the attributes definition is extended to include two new attributes: `backgroundColor` and `style`:

- `backgroundColor`: attribute of `string` type with no default assigned.

When a user chooses from the list of preset background colors, the preset slug is stored in the `backgroundColor` attribute.

Background color presets are sourced from the `editor-color-palette` [theme support](https://developer.wordpress.org/block-editor/developers/themes/theme-support/#block-color-palettes).

The block can apply a default preset background color by specifying its own attribute with a default e.g.:

```js
attributes: {
backgroundColor: {
type: 'string',
default: 'some-preset-background-slug',
}
}
```

- `style`: attribute of `object` type with no default assigned.

When a custom background color is selected (i.e. using the custom color picker), the custom color value is stored in the `style.color.background` attribute.

The block can apply a default custom background color by specifying its own attribute with a default e.g.:

```js
attributes: {
style: {
type: 'object',
default: {
color: {
background: '#aabbcc',
}
}
}
}
```

### color.__experimentalDuotone

This property adds UI controls which allow to apply a duotone filter to a block or part of a block.

The parent selector is automatically added much like nesting in Sass/SCSS (however, the `&` selector is not supported).

```js
attributes: {
backgroundColor: {
type: 'string',
default: 'some-value',
supports: {
color: {
// Apply the filter to the same selector in both edit and save.
__experimentalDuotone: '> .duotone-img, > .duotone-video',

// Default values must be disabled if you don't want to use them with duotone.
background: false,
text: false
}
}
```

- When `gradients` support is declared: it'll be added a new `gradient` attribute of type `string` with no default assigned. It stores the preset values set by the user. The block can apply a default text color by specifying its own attribute with a default e.g.:
Duotone presets are sourced from `color.duotone` in [theme.json](https://developer.wordpress.org/block-editor/developers/themes/theme-json/).

When the block declares support for `color.duotone`, the attributes definition is extended to include the attribute `style`:

- `style`: attribute of `object` type with no default assigned.

The block can apply a default duotone color by specifying its own attribute with a default e.g.:

```js
attributes: {
style: {
type: 'object',
default: {
color: {
duotone: [
'#FFF',
'#000
]
}
}
}
}
```

### color.gradients

This property adds UI controls which allow the user to apply a gradient background to a block.

```js
attributes: {
gradient: {
type: 'string',
default: 'some-value',
supports: {
color: {
gradient: true,

// Default values must be disabled if you don't want to use them with gradient.
background: false,
text: false
}
}
```

- When `text` support is declared: it'll be added a new `textColor` attribute of type `string` with no default assigned. It stores the preset values set by the user. The block can apply a default text color by specifying its own attribute with a default e.g.:
Gradient presets are sourced from `editor-gradient-presets` [theme support](https://developer.wordpress.org/block-editor/developers/themes/theme-support/#block-gradient-presets).


When the block declares support for `color.gradient`, the attributes definition is extended to include two new attributes: `gradient` and `style`:

- `gradient`: attribute of `string` type with no default assigned.

When a user chooses from the list of preset gradients, the preset slug is stored in the `gradient` attribute.

The block can apply a default preset gradient by specifying its own attribute with a default e.g.:

```js
attributes: {
gradient: {
type: 'string',
default: 'some-preset-gradient-slug',
}
}
```

- `style`: attribute of `object` type with no default assigned.

When a custom gradient is selected (i.e. using the custom gradient picker), the custom gradient value is stored in the `style.color.gradient` attribute.

The block can apply a default custom gradient by specifying its own attribute with a default e.g.:

```js
attributes: {
style: {
type: 'object',
default: {
color: {
background: 'linear-gradient(135deg,rgb(170,187,204) 0%,rgb(17,34,51) 100%)',
}
}
}
}
```

### color.text

This property adds block controls which allow the user to set text color in a block.

When color support is declared, this property is enabled by default (along with background), so simply setting color will enable text color.

```js
attributes: {
textColor: {
type: 'string',
default: 'some-value',
supports: {
color: true // Enable both text and background
}
```

To disable text color support while keeping other color supports enabled, set to `false`.

```js
supports: {
color: {
// Disable text color support. Background support is still enabled.
text: false
}
}
```

Text color presets are sourced from the `editor-color-palette` [theme support](https://developer.wordpress.org/block-editor/developers/themes/theme-support/#block-color-palettes).


When the block declares support for `color.text`, the attributes definition is extended to include two new attributes: `textColor` and `style`:

- `textColor`: attribute of `string` type with no default assigned.

When a user chooses from the list of preset text colors, the preset slug is stored in the `textColor` attribute.

The block can apply a default preset text color by specifying its own attribute with a default e.g.:

```js
attributes: {
textColor: {
type: 'string',
default: 'some-preset-text-color-slug',
}
}
```

- `style`: attribute of `object` type with no default assigned.

When a custom text color is selected (i.e. using the custom color picker), the custom color value is stored in the `style.color.text` attribute.

The block can apply a default custom text color by specifying its own attribute with a default e.g.:

```js
attributes: {
style: {
type: 'object',
default: {
color: {
text: '#aabbcc',
}
}
}
}
```

## customClassName

- Type: `boolean`
Expand Down
Loading