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

[pull] trunk from WordPress:trunk #127

Merged
merged 3 commits into from
Dec 30, 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
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@
"resize-observer-polyfill": "1.5.1",
"rimraf": "5.0.10",
"rtlcss": "4.3.0",
"sass": "1.50.1",
"sass": "1.54.0",
"sass-loader": "16.0.3",
"semver": "7.5.4",
"simple-git": "3.24.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# BorderRadiusControl

`BorderRadiusControl` is a React component that provides a user interface for managing border radius values. It allows users to control the border radius of each corner independently or link them together for uniform values.

## Usage

```jsx
/**
* WordPress dependencies
*/
import { __experimentalBorderRadiusControl as BorderRadiusControl } from '@wordpress/block-editor';
import { useState } from '@wordpress/element';

const MyBorderRadiusControl = () => {
const [values, setValues] = useState({
topLeft: '10px',
topRight: '10px',
bottomLeft: '10px',
bottomRight: '10px',
});

return (
<BorderRadiusControl
values={values}
onChange={setValues}
/>
);
};
```

## Props

### values

An object containing the border radius values for each corner.

- **Type:** `Object`
- **Required:** No
- **Default:** `undefined`

The values object has the following schema:

| Property | Description | Type |
| ----------- | ------------------------------------ | ------ |
| topLeft | Border radius for top left corner | string |
| topRight | Border radius for top right corner | string |
| bottomLeft | Border radius for bottom left corner | string |
| bottomRight | Border radius for bottom right corner| string |

Each value should be a valid CSS border radius value (e.g., '10px', '1em').

### onChange

Callback function that is called when any border radius value changes.

- **Type:** `Function`
- **Required:** Yes

The function receives the updated values object as its argument.
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/**
* WordPress dependencies
*/
import { useState } from '@wordpress/element';

/**
* Internal dependencies
*/
import BorderRadiusControl from '../';

const meta = {
title: 'BlockEditor/BorderRadiusControl',
component: BorderRadiusControl,
parameters: {
docs: {
canvas: { sourceState: 'shown' },
description: {
component: 'Control to display border radius options.',
},
},
},
argTypes: {
values: {
control: 'object',
description: 'Border radius values.',
table: {
type: { summary: 'object' },
},
},
onChange: {
action: 'onChange',
control: { type: null },
table: {
type: { summary: 'function' },
},
description: 'Callback to handle onChange.',
},
},
};

export default meta;

export const Default = {
render: function Template( { onChange, ...args } ) {
const [ values, setValues ] = useState( args.values );

return (
<BorderRadiusControl
{ ...args }
values={ values }
onChange={ ( ...changeArgs ) => {
setValues( ...changeArgs );
onChange( ...changeArgs );
} }
/>
);
},
};
2 changes: 2 additions & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

- `BoxControl`: Add presets support ([#67688](https://github.com/WordPress/gutenberg/pull/67688)).
- `Navigation`: Upsize back buttons ([#68157](https://github.com/WordPress/gutenberg/pull/68157)).
- `Heading`: Fix text contrast for dark mode ([#68349](https://github.com/WordPress/gutenberg/pull/68349)).
- `Text`: Fix text contrast for dark mode ([#68349](https://github.com/WordPress/gutenberg/pull/68349)).

### Deprecations

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ exports[`DimensionControl rendering renders with custom sizes 1`] = `
}

.emotion-12 {
color: #1e1e1e;
color: var(--wp-components-color-foreground, #1e1e1e);
line-height: 1.4;
margin: 0;
text-wrap: balance;
Expand Down Expand Up @@ -345,7 +345,7 @@ exports[`DimensionControl rendering renders with defaults 1`] = `
}

.emotion-12 {
color: #1e1e1e;
color: var(--wp-components-color-foreground, #1e1e1e);
line-height: 1.4;
margin: 0;
text-wrap: balance;
Expand Down Expand Up @@ -637,7 +637,7 @@ exports[`DimensionControl rendering renders with icon and custom icon label 1`]
}

.emotion-12 {
color: #1e1e1e;
color: var(--wp-components-color-foreground, #1e1e1e);
line-height: 1.4;
margin: 0;
text-wrap: balance;
Expand Down Expand Up @@ -941,7 +941,7 @@ exports[`DimensionControl rendering renders with icon and default icon label 1`]
}

.emotion-12 {
color: #1e1e1e;
color: var(--wp-components-color-foreground, #1e1e1e);
line-height: 1.4;
margin: 0;
text-wrap: balance;
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/heading/hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export function useHeading(
const {
as: asProp,
level = 2,
color = COLORS.gray[ 900 ],
color = COLORS.theme.foreground,
isBlock = true,
weight = CONFIG.fontWeightHeading as import('react').CSSProperties[ 'fontWeight' ],
...otherProps
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

exports[`props should render correctly 1`] = `
.emotion-0 {
color: #1e1e1e;
color: var(--wp-components-color-foreground, #1e1e1e);
line-height: 1.4;
margin: 0;
text-wrap: balance;
text-wrap: pretty;
color: #1e1e1e;
color: var(--wp-components-color-foreground, #1e1e1e);
font-size: calc(1.95 * 13px);
font-weight: 600;
display: block;
Expand All @@ -30,7 +30,7 @@ Snapshot Diff:
@@ -1,10 +1,10 @@
Array [
Object {
"color": "#1e1e1e",
"color": "var(--wp-components-color-foreground, #1e1e1e)",
"display": "block",
- "font-size": "calc(1.25 * 13px)",
+ "font-size": "calc(1.95 * 13px)",
Expand All @@ -49,7 +49,7 @@ Snapshot Diff:
@@ -1,10 +1,10 @@
Array [
Object {
"color": "#1e1e1e",
"color": "var(--wp-components-color-foreground, #1e1e1e)",
"display": "block",
- "font-size": "calc(1.25 * 13px)",
+ "font-size": "calc(1.95 * 13px)",
Expand Down
4 changes: 2 additions & 2 deletions packages/components/src/text/hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ export default function useText(
getOptimalTextShade( optimizeReadabilityFor ) === 'dark';

sx.optimalTextColor = isOptimalTextColorDark
? css( { color: COLORS.gray[ 900 ] } )
: css( { color: COLORS.white } );
? css( { color: COLORS.theme.foreground } )
: css( { color: COLORS.theme.foregroundInverted } );
}

return cx(
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/text/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { css } from '@emotion/react';
import { COLORS, CONFIG } from '../utils';

export const Text = css`
color: ${ COLORS.gray[ 900 ] };
color: ${ COLORS.theme.foreground };
line-height: ${ CONFIG.fontLineHeightBase };
margin: 0;
text-wrap: balance; /* Fallback for Safari. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Snapshot Diff:
+ Base styles

@@ -3,8 +3,9 @@
"color": "#1e1e1e",
"color": "var(--wp-components-color-foreground, #1e1e1e)",
"font-size": "calc((13 / 13) * 13px)",
"font-weight": "normal",
"line-height": "1.4",
Expand All @@ -19,7 +19,7 @@ Snapshot Diff:

exports[`Text should render highlighted words with highlightCaseSensitive 1`] = `
.emotion-0 {
color: #1e1e1e;
color: var(--wp-components-color-foreground, #1e1e1e);
line-height: 1.4;
margin: 0;
text-wrap: balance;
Expand Down Expand Up @@ -52,7 +52,7 @@ exports[`Text should render highlighted words with highlightCaseSensitive 1`] =

exports[`Text snapshot tests should render correctly 1`] = `
.emotion-0 {
color: #1e1e1e;
color: var(--wp-components-color-foreground, #1e1e1e);
line-height: 1.4;
margin: 0;
text-wrap: balance;
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/text/test/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe( 'Text', () => {
</Text>
);
expect( screen.getByRole( 'heading' ) ).toHaveStyle( {
color: COLORS.white,
color: 'rgb( 255, 255, 255 )',
} );
} );

Expand Down
1 change: 1 addition & 0 deletions packages/scripts/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Internal

- The bundled `rtlcss-webpack-plugin` dependency has been replaced with a modified fork of the plugin to fix issues with the original package ([#68201](https://github.com/WordPress/gutenberg/pull/68201)).
- The bundled `sass` dependency has been updated from `^1.50.0` to `^1.54.0` ([#68380](https://github.com/WordPress/gutenberg/pull/68380)).

## 30.7.0 (2024-12-11)

Expand Down
2 changes: 1 addition & 1 deletion packages/scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
"read-pkg-up": "^7.0.1",
"resolve-bin": "^0.4.0",
"rtlcss": "^4.3.0",
"sass": "^1.50.1",
"sass": "^1.54.0",
"sass-loader": "^16.0.3",
"schema-utils": "^4.2.0",
"source-map-loader": "^3.0.0",
Expand Down
Loading