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

Add margin-bottom lint rules for FocalPointPicker, TextareaControl, TreeSelect #63633

Merged
merged 4 commits into from
Jul 17, 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
25 changes: 25 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,31 @@ module.exports = {
],
},
},
{
// Temporary rules until we're ready to officially deprecate the bottom margins.
files: [ 'packages/*/src/**/*.[tj]s?(x)' ],
excludedFiles: [
'packages/components/src/**/@(test|stories)/**',
'**/*.@(native|ios|android).js',
],
rules: {
'no-restricted-syntax': [
'error',
...restrictedSyntax,
...restrictedSyntaxComponents,
...[
'FocalPointPicker',
'TextareaControl',
'TreeSelect',
].map( ( componentName ) => ( {
selector: `JSXOpeningElement[name.name="${ componentName }"]:not(:has(JSXAttribute[name.name="__nextHasNoMarginBottom"]))`,
message:
componentName +
' should have the `__nextHasNoMarginBottom` prop to opt-in to the new margin-free styles.',
} ) ),
],
},
},
{
files: [
// Components package.
Expand Down
9 changes: 9 additions & 0 deletions packages/components/src/focal-point-picker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const Example = () => {
return (
<>
<FocalPointPicker
__nextHasNoMarginBottom
url={ url }
value={ focalPoint }
onDragStart={ setFocalPoint }
Expand Down Expand Up @@ -98,3 +99,11 @@ Callback which is called at the start of drag operations.
- Required: No

Function which is called before internal updates to the value state. It receives the upcoming value and may return a modified one.

#### __nextHasNoMarginBottom

Start opting into the new margin-free styles that will become the default in a future version.

- Type: `Boolean`
- Required: No
- Default: `false`
1 change: 1 addition & 0 deletions packages/components/src/focal-point-picker/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ const GRID_OVERLAY_TIMEOUT = 600;
* return (
* <>
* <FocalPointPicker
* __nextHasNoMarginBottom
* url={ url }
* value={ focalPoint }
* onDragStart={ setFocalPoint }
Expand Down
8 changes: 8 additions & 0 deletions packages/components/src/textarea-control/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ const MyTextareaControl = () => {

return (
<TextareaControl
__nextHasNoMarginBottom
label="Text"
help="Enter some text"
value={ text }
Expand Down Expand Up @@ -131,6 +132,13 @@ The current value of the textarea.

- Required: Yes

#### `__nextHasNoMarginBottom`: `Boolean`

Start opting into the new margin-free styles that will become the default in a future version.

- Required: No
- Default: `false`

## Related components

- For a field where users only enter one line of text, use the `TextControl` component.
1 change: 1 addition & 0 deletions packages/components/src/textarea-control/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ function UnforwardedTextareaControl(
*
* return (
* <TextareaControl
* __nextHasNoMarginBottom
* label="Text"
* help="Enter some text"
* value={ text }
Expand Down
9 changes: 9 additions & 0 deletions packages/components/src/tree-select/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const MyTreeSelect = () => {

return (
<TreeSelect
__nextHasNoMarginBottom
label="Parent page"
noOptionLabel="No parent page"
onChange={ ( newPage ) => setPage( newPage ) }
Expand Down Expand Up @@ -89,3 +90,11 @@ An array containing the tree objects with the possible nodes the user can select

- Type: `Object[]`
- Required: No

#### __nextHasNoMarginBottom

Start opting into the new margin-free styles that will become the default in a future version.

- Type: `Boolean`
- Required: No
- Default: `false`
1 change: 1 addition & 0 deletions packages/components/src/tree-select/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ function getSelectOptions(
*
* return (
* <TreeSelect
* __nextHasNoMarginBottom
* label="Parent page"
* noOptionLabel="No parent page"
* onChange={ ( newPage ) => setPage( newPage ) }
Expand Down
Loading