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

Fix/update docs alignment matrix control #34624

Merged

Conversation

ryanwelcher
Copy link
Contributor

Description

This PR updates the documentation for the AlignmentMatrixControl to include a working example and introduce props definitions as part of the larger effort in #33263

How has this been tested?

Docs updates only. I have tested the example in a local env.

Types of changes

Documentation only

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • I've tested my changes with keyboard and screen readers.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.
  • I've updated all React Native files affected by any refactorings/renamings in this PR (please manually search all *.native.js files for terms that need renaming or removal).

@ryanwelcher ryanwelcher added [Type] Developer Documentation Documentation for developers [Package] Components /packages/components [Feature] Component System WordPress component system labels Sep 7, 2021
Copy link
Member

@Mamaduka Mamaduka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this, @ryanwelcher.

@Mamaduka Mamaduka merged commit f20ad34 into WordPress:trunk Sep 8, 2021
@github-actions github-actions bot added this to the Gutenberg 11.5 milestone Sep 8, 2021
Copy link
Contributor

@ciampo ciampo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @ryanwelcher, thank you so much for working on this! It's very appreciated :)

Despite this PR already being reviewed and merged, I took a look at it and left a few comments — would you mind addressing them by opening a follow-up PR?

Comment on lines +28 to +29
The class that will be added with "component-alignment-matrix-control" to the classes of the wrapper <Composite/> component.
If no className is passed only "component-alignment-matrix-control" is used.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know that some older READMEs have a similar paragraph, but from now on let's not mention the "component-alignment-matrix-control" className in public docs

Unique ID for the component.
- Type: `String`
- Required: No
### label
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tiny nitpick: most headers used for props are missing an empty line above them

Suggested change
### label
### label


- Type: `function`
- Required: No
- Default: `noop`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know that the default value for this prop is a noop function, but I'd remove this line from the README, as it may confuse a reader instead of adding value


A function that receives the updated alignment value.

- Type: `function`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we replace types to be closer to how TypeScript types are described?

In this case, it could be something like ( nextValue: string ) => void

Other changes would be:

  • from String to string
  • from Number to number

- Required: No
### label

If provided, sets the aria-label attribute of the wrapper <Composite/> component.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit:

Suggested change
If provided, sets the aria-label attribute of the wrapper <Composite/> component.
Accessible label. If provided, sets the `aria-label` attribute of the underlying <Composite/> component.

Comment on lines +8 to 20
import { __experimentalAlignmentMatrixControl as AlignmentMatrixControl } from '@wordpress/components';
import { useState } from '@wordpress/element';

const Example = () => {
const [ alignment, setAlignment ] = useState( 'center center' );
const [alignment, setAlignment] = useState('center center');

return (
<AlignmentMatrixControl value={ alignment } onChange={ setAlignment } />
<AlignmentMatrixControl
value={alignment}
onChange={(newAlignment) => setAlignment(newAlignment)}
/>
);
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very very minor, but — it'd be great if the example snippet followed the repo's prettier formatting rules

Suggested change
import { __experimentalAlignmentMatrixControl as AlignmentMatrixControl } from '@wordpress/components';
import { useState } from '@wordpress/element';
const Example = () => {
const [ alignment, setAlignment ] = useState( 'center center' );
const [alignment, setAlignment] = useState('center center');
return (
<AlignmentMatrixControl value={ alignment } onChange={ setAlignment } />
<AlignmentMatrixControl
value={alignment}
onChange={(newAlignment) => setAlignment(newAlignment)}
/>
);
};
import { __experimentalAlignmentMatrixControl as AlignmentMatrixControl } from '@wordpress/components';
import { useState } from '@wordpress/element';
const Example = () => {
const [ alignment, setAlignment ] = useState( 'center center' );
return (
<AlignmentMatrixControl
value={ alignment }
onChange={ ( newAlignment ) => setAlignment( newAlignment ) }
/>
);
};

- Type: `String`
- Required: No
- Default: `Alignment Matrix Control`
### defaultValue
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we also add the value prop to the docs? It looks like it's currently missing

@Mamaduka
Copy link
Member

Mamaduka commented Sep 8, 2021

Thanks for the review, @ciampo, and sorry that I didn't catch those issues while reviewing.

@ciampo
Copy link
Contributor

ciampo commented Sep 8, 2021

Thanks for the review, @ciampo, and sorry that I didn't catch those issues while reviewing.

No worries! Most of my comments are minor, but they're mostly there to ensure consistency across different components' READMEs :)

@Mamaduka
Copy link
Member

Mamaduka commented Sep 8, 2021

Do we have a style guide for component documentation? It could be useful as a reference.

@ryanwelcher
Copy link
Contributor Author

@ciampo thanks for the feedback! I'll get that addressed today.

Do we have a style guide for component documentation? It could be useful as a reference.

This would be extremely useful and take any guesswork out for contributors.

@ciampo
Copy link
Contributor

ciampo commented Sep 8, 2021

Do we have a style guide for component documentation? It could be useful as a reference.

No, we don't yet — but we're working on updating the contributing guidelines. A documentation style guide may be a nice addition to that document, once the critical sections are addressed.

@ryanwelcher
Copy link
Contributor Author

@ciampo updated PR - #34662

fullofcaffeine added a commit that referenced this pull request Sep 9, 2021
* trunk: (214 commits)
  Fix snackbar overflow on nav editor (#34661)
  Mobile - Allow disabling text and background color via theme.json (#34633)
  Fix disabled blocks logical error on Widgets screen (#34634)
  [Mobile] - Global styles - Add support to render font sizes and line height (#34144)
  ESLint Plugin: Update eslint jsdoc dependency (#34338)
  Scripts: Add CHANGELOG entry for `jest-dev-server` upgrade (#34657)
  Bump jest-dev-server to v5 (#34560)
  Refactor the `core-data` store to thunks (#28389)
  Only capture toolbars on parent Nav block when not in vertical mode (#34615)
  Update Changelog for 11.5.0-rc.1
  Bump plugin version to 11.5.0-rc.1
  Gallery block: Fix media placeholder height in site editor (#34629)
  Border Controls: Display color indicator and check selected color (#34467)
  Remove horizontal and vertical navigation block variations from inserter (#34614)
  AlignmentMatrixControl : Fix/update docs (#34624)
  Gap block support: force gap change to cause the block to re-render (fix Safari issue) (#34567)
  [Block Library - Social Links]: Use the new `flex` layout (#34493)
  [Mobile] Update the bottom sheet header (#34309)
  Group block: Add a row variation (#34535)
  Migrate entities.js to thunks (#34582)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Component System WordPress component system [Package] Components /packages/components [Type] Developer Documentation Documentation for developers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants