-
Notifications
You must be signed in to change notification settings - Fork 536
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into interactive-token-state
- Loading branch information
Showing
12 changed files
with
249 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@primer/react': patch | ||
--- | ||
|
||
Update TooltipProps to extend from StyledTooltip props |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# ADR 016: Internal Modules | ||
|
||
## Status | ||
|
||
| Stage | Status | | ||
| -------- | ------ | | ||
| Approved | ✅ | | ||
| Adopted | 🚧 | | ||
|
||
## Context | ||
|
||
Currently all files live under the `src` directory. In the `npm` package for `@primer/react`, we specify the following export pattern: | ||
|
||
```json5 | ||
{ | ||
"exports": { | ||
// ... | ||
"./lib-esm/*": { | ||
"import": [ | ||
// ... | ||
], | ||
"require": [ | ||
// ... | ||
] | ||
} | ||
} | ||
} | ||
``` | ||
|
||
This pattern, along with our Rollup setup, opts-in files and folders under the `src` directory into the public API of the package. This means that certain parts of the codebase which aren't intended to be used outside of `@primer/react` are considered part of its public API and can be imported and used by consumers. | ||
|
||
## Decision | ||
|
||
Adopt a convention in Primer React where internal modules live in the `src/internal` folder. This folder which would include all components, hooks, and other modules which are not intended for usage outside of the project. Files within `src/internal` may be grouped by area, such as `src/internal/components`, `src/internal/hooks`, etc. | ||
|
||
In the `"exports"` field of our `npm` package, we can then add the following pattern: | ||
|
||
```json5 | ||
{ | ||
"exports": { | ||
// ... | ||
"./lib-esm/internal/*": null | ||
} | ||
} | ||
``` | ||
|
||
This pattern would remove any files and folders within `src/internal` from the public API of the `npm` package. This pattern is inspired by [this section](https://nodejs.org/api/packages.html#package-entry-points) from Node.js, specifically this example: | ||
|
||
```json | ||
{ | ||
"name": "my-package", | ||
"exports": { | ||
".": "./lib/index.js", | ||
"./feature/*.js": "./feature/*.js", | ||
"./feature/internal/*": null | ||
} | ||
} | ||
``` | ||
|
||
|
||
### Impact | ||
|
||
- Update the `"exports"` field in `package.json` to exclude `./lib-esm/internal` from usage | ||
- (In a major release) Move internal-only files into internal folder | ||
- For internal modules that are being created after this ADR is accepted, add them to the `src/internal` folder |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import React from 'react' | ||
import {Meta} from '@storybook/react' | ||
import SubNav from './SubNav' | ||
import {ComponentProps} from '../utils/types' | ||
|
||
export default { | ||
title: 'Components/SubNav/Features', | ||
component: SubNav, | ||
subcomponents: { | ||
'SubNav.Link': SubNav.Link, | ||
}, | ||
} as Meta<ComponentProps<typeof SubNav>> | ||
|
||
export const Selected = () => ( | ||
<SubNav aria-label="Main"> | ||
<SubNav.Links> | ||
<SubNav.Link href="#home" selected> | ||
Home | ||
</SubNav.Link> | ||
<SubNav.Link href="#documentation">Documentation</SubNav.Link> | ||
<SubNav.Link href="#support">Support</SubNav.Link> | ||
</SubNav.Links> | ||
</SubNav> | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import React from 'react' | ||
import {Meta, Story} from '@storybook/react' | ||
import SubNav from './SubNav' | ||
import {ComponentProps} from '../utils/types' | ||
|
||
export default { | ||
title: 'Components/SubNav', | ||
component: SubNav, | ||
subcomponents: { | ||
'SubNav.Link': SubNav.Link, | ||
}, | ||
} as Meta<ComponentProps<typeof SubNav>> | ||
|
||
export const Playground: Story<ComponentProps<typeof SubNav>> = args => ( | ||
<SubNav {...args}> | ||
<SubNav.Links> | ||
<SubNav.Link href="#home" selected> | ||
Home | ||
</SubNav.Link> | ||
<SubNav.Link href="#documentation">Documentation</SubNav.Link> | ||
<SubNav.Link href="#support">Support</SubNav.Link> | ||
</SubNav.Links> | ||
</SubNav> | ||
) | ||
|
||
Playground.args = { | ||
'aria-label': 'Main', | ||
} | ||
Playground.argTypes = { | ||
'aria-label': { | ||
type: 'string', | ||
}, | ||
} | ||
|
||
export const Default = () => ( | ||
<SubNav aria-label="Main"> | ||
<SubNav.Links> | ||
<SubNav.Link href="#home" selected> | ||
Home | ||
</SubNav.Link> | ||
<SubNav.Link href="#documentation">Documentation</SubNav.Link> | ||
<SubNav.Link href="#support">Support</SubNav.Link> | ||
</SubNav.Links> | ||
</SubNav> | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export {default, SubNavProps, SubNavLinkProps, SubNavLinksProps} from './SubNav' |
Oops, something went wrong.