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

docs(style): update style guide for component naming #6642

Merged
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
37 changes: 10 additions & 27 deletions docs/style.md
Original file line number Diff line number Diff line change
Expand Up @@ -390,11 +390,6 @@ made before an official release.
For experimental or unstable code, we use the `unstable_` prefix. For example:

```js
// An unstable component
function unstable_Pagination(props) {
// ...
}

// An unstable method
function unstable_layout() {
// ...
Expand All @@ -404,6 +399,16 @@ function unstable_layout() {
const unstable_meta = {
// ...
};

// An unstable component will retain its name, specifically for things like
// the rules of hooks plugin which depend on the correct casing of the name
function Pagination(props) {
// ...
}

// However, when we export the component we will export it with the `unstable_`
// prefix. (Similar to React.unstable_Suspense, React.unstable_Profiler)
export { default as unstable_Pagination } from './components/Pagination';
```

For teams using these features, they will need to import the functionality by
Expand All @@ -416,28 +421,6 @@ import { unstable_Pagination as Pagination } from 'carbon-components-react';
This code should be treated as experimental and will break between release
versions for the package that it is being imported from.

<table>
<thead><tr><th>Unpreferred</th><th>Preferred</th></tr></thead>
<tbody>
<tr><td>

```jsx
function Unstable_MyComponent() {
// ...
}
```

</td><td>

```jsx
function unstable_MyComponent() {
// ...
}
```

</td></tr>
</tbody></table>

## Sass

### Guidelines
Expand Down
262 changes: 131 additions & 131 deletions packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -6454,137 +6454,6 @@ Map {
},
},
},
"PageSelector" => Object {
"defaultProps": Object {
"className": null,
"id": 1,
"labelText": "Current page number",
},
"propTypes": Object {
"className": Object {
"type": "string",
},
"currentPage": Object {
"isRequired": true,
"type": "number",
},
"id": Object {
"args": Array [
Array [
Object {
"type": "string",
},
Object {
"type": "number",
},
],
],
"type": "oneOfType",
},
"labelText": Object {
"type": "string",
},
"totalPages": Object {
"isRequired": true,
"type": "number",
},
},
},
"Unstable_Pagination" => Object {
"defaultProps": Object {
"backwardText": "Previous page",
"children": undefined,
"className": null,
"disabled": false,
"forwardText": "Next page",
"id": 1,
"initialPage": 1,
"itemRangeText": [Function],
"itemText": [Function],
"itemsPerPageText": "Items per page:",
"pageRangeText": [Function],
"pageSize": 10,
"pageSizes": undefined,
"pageText": [Function],
"pagesUnknown": false,
"totalItems": undefined,
},
"propTypes": Object {
"backwardText": Object {
"type": "string",
},
"children": Object {
"args": Array [
Array [
Object {
"type": "node",
},
Object {
"type": "func",
},
],
],
"type": "oneOfType",
},
"className": Object {
"type": "string",
},
"disabled": Object {
"type": "bool",
},
"forwardText": Object {
"type": "string",
},
"id": Object {
"args": Array [
Array [
Object {
"type": "string",
},
Object {
"type": "number",
},
],
],
"type": "oneOfType",
},
"initialPage": Object {
"type": "number",
},
"itemRangeText": Object {
"type": "func",
},
"itemText": Object {
"type": "func",
},
"itemsPerPageText": Object {
"type": "string",
},
"pageRangeText": Object {
"type": "func",
},
"pageSize": Object {
"type": "number",
},
"pageSizes": Object {
"args": Array [
Object {
"type": "number",
},
],
"type": "arrayOf",
},
"pageText": Object {
"type": "func",
},
"pagesUnknown": Object {
"type": "bool",
},
"totalItems": Object {
"type": "number",
},
},
},
"Content" => Object {
"defaultProps": Object {
"tagName": "main",
Expand Down Expand Up @@ -7079,5 +6948,136 @@ Map {
},
"render": [Function],
},
"unstable_PageSelector" => Object {
"defaultProps": Object {
"className": null,
"id": 1,
"labelText": "Current page number",
},
"propTypes": Object {
"className": Object {
"type": "string",
},
"currentPage": Object {
"isRequired": true,
"type": "number",
},
"id": Object {
"args": Array [
Array [
Object {
"type": "string",
},
Object {
"type": "number",
},
],
],
"type": "oneOfType",
},
"labelText": Object {
"type": "string",
},
"totalPages": Object {
"isRequired": true,
"type": "number",
},
},
},
"unstable_Pagination" => Object {
"defaultProps": Object {
"backwardText": "Previous page",
"children": undefined,
"className": null,
"disabled": false,
"forwardText": "Next page",
"id": 1,
"initialPage": 1,
"itemRangeText": [Function],
"itemText": [Function],
"itemsPerPageText": "Items per page:",
"pageRangeText": [Function],
"pageSize": 10,
"pageSizes": undefined,
"pageText": [Function],
"pagesUnknown": false,
"totalItems": undefined,
},
"propTypes": Object {
"backwardText": Object {
"type": "string",
},
"children": Object {
"args": Array [
Array [
Object {
"type": "node",
},
Object {
"type": "func",
},
],
],
"type": "oneOfType",
},
"className": Object {
"type": "string",
},
"disabled": Object {
"type": "bool",
},
"forwardText": Object {
"type": "string",
},
"id": Object {
"args": Array [
Array [
Object {
"type": "string",
},
Object {
"type": "number",
},
],
],
"type": "oneOfType",
},
"initialPage": Object {
"type": "number",
},
"itemRangeText": Object {
"type": "func",
},
"itemText": Object {
"type": "func",
},
"itemsPerPageText": Object {
"type": "string",
},
"pageRangeText": Object {
"type": "func",
},
"pageSize": Object {
"type": "number",
},
"pageSizes": Object {
"args": Array [
Object {
"type": "number",
},
],
"type": "arrayOf",
},
"pageText": Object {
"type": "func",
},
"pagesUnknown": Object {
"type": "bool",
},
"totalItems": Object {
"type": "number",
},
},
},
}
`;
4 changes: 2 additions & 2 deletions packages/react/src/__tests__/index-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ describe('Carbon Components React', () => {
"OrderedList",
"OverflowMenu",
"OverflowMenuItem",
"PageSelector",
"Pagination",
"PaginationNav",
"PaginationSkeleton",
Expand Down Expand Up @@ -192,7 +191,8 @@ describe('Carbon Components React', () => {
"TooltipDefinition",
"TooltipIcon",
"UnorderedList",
"Unstable_Pagination",
"unstable_PageSelector",
"unstable_Pagination",
]
`);
});
Expand Down
Loading