Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
7e93e07
README: add notes
ciampo Aug 9, 2021
37e1759
README: add link to `CONTRIBUTING.md`
ciampo Aug 9, 2021
cefad1f
CONTRIBUTING: Add initial notes
ciampo Aug 9, 2021
02114ce
More notes into CONTRIBUTING
ciampo Aug 10, 2021
3d665fb
Update CONTRIBUTING
ciampo Aug 11, 2021
0fb4753
Add `enable` to boolean prefixes
ciampo Aug 12, 2021
00e2b35
Remove `View` suffix for styled components
ciampo Aug 12, 2021
17ccabe
Update folder structure: move styles and types into each subfolder
ciampo Aug 12, 2021
1459214
Less strict working about typescript, rename PolymorphicComponent to …
ciampo Aug 24, 2021
c6f6a24
Update packages/components/CONTRIBUTING.md
ciampo Aug 24, 2021
f533857
Refer to the repo testing overview docs in the unit test section
ciampo Sep 1, 2021
4c1c200
Update polyfill info
ciampo Sep 1, 2021
89a89d1
Remove "Components Structure" paragraph
ciampo Sep 1, 2021
5238a88
Reword text in "Folder structure" section, exclude shared utilities
ciampo Sep 1, 2021
7acc925
Folder structure schemes: name parent folders, remove useless sub-com…
ciampo Sep 1, 2021
6621f1e
Expand Storybook section
ciampo Sep 1, 2021
6f6d8de
Add details to soft deprecation strategy
ciampo Sep 1, 2021
9d0ece7
Misc smaller improvements
ciampo Sep 1, 2021
d394f5d
Fix typo
ciampo Sep 1, 2021
3359502
Expand hooks vs components section, move under composition
ciampo Sep 1, 2021
cfc843d
Move sub components naming convention under "APIs consistency" section
ciampo Sep 1, 2021
abf50ad
Add Polymorphic components sub-section, reorganise "Components compos…
ciampo Sep 1, 2021
0021dfc
Add more details about listing props through knobs in storybook
ciampo Sep 2, 2021
15f7023
Remove hyphen from subcomponents
ciampo Sep 2, 2021
4520f7e
Add content to the `Context System` section
ciampo Sep 2, 2021
95de8fb
comment out unfinied sections
ciampo Sep 3, 2021
5393b9a
Apply suggestions from code review
ciampo Sep 8, 2021
6647446
Comment out reference to the "composition section"
ciampo Sep 8, 2021
670ca6c
Rename "Emotion" section to "Styling"
ciampo Sep 8, 2021
e65518d
Updale unit test section to link directly to components snapshot testing
ciampo Sep 8, 2021
b6edc2e
Update the storybook section, adding more details on stories and knobs
ciampo Sep 8, 2021
e8bb18d
Link to the Coding Guidelines in the "Documentation" section
ciampo Sep 8, 2021
08cd356
remove note about relevance of SCSS-related docs in README
ciampo Sep 8, 2021
c34f731
Update context section with example snippets
ciampo Sep 8, 2021
8c494c8
Format internal links to absolute path format
ciampo Sep 8, 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
Prev Previous commit
Next Next commit
Apply suggestions from code review
Co-authored-by: Haz <[email protected]>
Co-authored-by: Greg Ziółkowski <[email protected]>
  • Loading branch information
3 people committed Sep 8, 2021
commit 5393b9ab128e522424d58695004375b6037edc3e
18 changes: 11 additions & 7 deletions packages/components/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,21 @@ The following is a set of guidelines for contributing to the `@wordpress/compone

Contributions to the `@wordpress/components` package should follow a set of core principles and technical requirements.

This set of guidelines should apply especially to newly introduced components. It is, in fact, possible that some of the older component don't respect some of these guidelines for legacy/compat reasons.
This set of guidelines should apply especially to newly introduced components. It is, in fact, possible that some of the older components don't respect some of these guidelines for legacy/compatibility reasons.

### Compatibility

The `@wordpress/components` package includes components that are relied upon by many developers across different projects. It is, therefore, very important to avoid introducing breaking changes.

In these situations, one possible approach is to "soft-deprecate" a given legacy API. This is achieved by:

1. Removing traces of the API from the docs, while still supporing it in code;
2. Updating all places in Gutenberg that use that API;
3. Adding deprecation warnings (only after the previous point is completed, otherwide the Browser Console will be polluted by all those warnings and some e2e tests may fail).
1. Removing traces of the API from the docs, while still supporting it in code.
2. Updating all places in Gutenberg that use that API.
3. Adding deprecation warnings (only after the previous point is completed, otherwise the Browser Console will be polluted by all those warnings and some e2e tests may fail).

When adding new components or new props to existing components, it's recommended to prefix them with `__unstable` or `__experimental` until they're stable enough to be exposed as part of the public API.

Learn more on [How to preserve backward compatibility for a React Component](https://github.com/WordPress/gutenberg/blob/trunk/docs/how-to-guides/backward-compatibility/README.md#how-to-preserve-backward-compatibility-for-a-react-component) and [Experimental and Unstable APIs](https://github.com/WordPress/gutenberg/blob/trunk/docs/contributors/code/coding-guidelines.md#experimental-and-unstable-apis).

### Components composition

Expand Down Expand Up @@ -52,7 +56,7 @@ One way to enable reusability and composition is to extract a component's underl
// in `hook.ts`
function useExampleComponent( props: PolymorphicComponentProps< ExampleProps, 'div' > ) {
// Merge received props with the context system.
const { isVisible, className, ...otherProps } = useContextSystem( props, 'Example' );
const { isVisible, className, ...otherProps } = useContextSystem( props, 'Example' );

// Any other reusable rendering logic (e.g. computing className, state, event listeners...)
const cx = useCx();
Expand Down Expand Up @@ -105,7 +109,7 @@ TDB -->

The following are a set of technical requirements for all newly introduced components. These requirements are also retroactively being applied to existing components.

For an example of a component that follows these requirements, take a look at [`ItemGroup`](/packages/components/src/item-group) as an example.
For an example of a component that follows these requirements, take a look at [`ItemGroup`](/packages/components/src/item-group).

#### TypeScript

Expand Down Expand Up @@ -153,7 +157,7 @@ export const secondary = () => <Button variant="secondary">Secondary Button</But

For even more flexibility while writing stories, the [`@storybook/addons-controls`](https://storybook.js.org/addons/@storybook/addon-controls) addon is a great way to interact with a component's arguments dynamically and in real time.

Ideally, all of the props for the story's components should be exposed by using knobs. The default value of the knobs should coincide with the default value of the props (i.e. it should be `undefined` if a prop is not required). A story should, therefore, also explicitely show how values from the Context System are applied to (sub)components. A good example of how this may look like is the [`Card` story](https://wordpress.github.io/gutenberg/?path=/story/components-card--default) (code [here](/packages/components/src/card/stories/index.js)).
Ideally, all of the props for the story's components should be exposed by using knobs. The default value of the knobs should coincide with the default value of the props (i.e. it should be `undefined` if a prop is not required). A story should, therefore, also explicitly show how values from the Context System are applied to (sub)components. A good example of how this may look like is the [`Card` story](https://wordpress.github.io/gutenberg/?path=/story/components-card--default) (code [here](/packages/components/src/card/stories/index.js)).

Storybook can be started on a local maching by running `npm run storybook:dev`. Alternatively, the components' catalogue (up to date with the latest code on `trunk`) can be found at [wordpress.github.io/gutenberg/](https://wordpress.github.io/gutenberg/).

Expand Down