-
Notifications
You must be signed in to change notification settings - Fork 667
refactor(styled-react): update how we re-export components #6726
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
448a776
refactor(styled-react): update how we re-export components
joshblack d6817df
chore: add changesets
joshblack 8fe405d
chore(lint): fix eslint error
joshblack 3c52b30
chore: disable Box eslint warning in styled-react
joshblack 8e84f1f
chore: remove eslint-disable
joshblack ab6d98c
refactor: add tests for styled-react entrypoint
joshblack c34dff9
test: add tests for each entrypoint
joshblack 4907e80
docs: add architecture docs
joshblack ad98370
chore: clean up lint errors
joshblack 02c3a4e
chore: add changesets
joshblack 3c876dc
chore: add changeset
joshblack 7094882
Merge branch 'main' into refactor/update-styled-react-entrypoint
joshblack 1c864f6
docs: fix markdownlint errors
joshblack 6e2373e
Merge branch 'refactor/update-styled-react-entrypoint' of github.com:…
joshblack 064b24a
chore: remove BranchName from styled-react
joshblack 967c7e3
Merge branch 'main' into refactor/update-styled-react-entrypoint
joshblack b457e81
chore: remove ProgressBar
joshblack 9bd61a5
Merge branch 'main' into refactor/update-styled-react-entrypoint
joshblack a540961
Merge branch 'refactor/update-styled-react-entrypoint' of github.com:…
joshblack ba0563a
chore: remove details component
joshblack e84b0e5
Merge branch 'main' into refactor/update-styled-react-entrypoint
joshblack File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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/styled-react': patch | ||
| --- | ||
|
|
||
| Refactor ToggleSwitch export type to match original type from @primer/react |
This file contains hidden or 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': minor | ||
| --- | ||
|
|
||
| Add ToggleSwitchProps type to package exports |
This file contains hidden or 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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,105 @@ | ||
| import { | ||
| type BetterSystemStyleObject, | ||
| Box, | ||
| type BoxProps, | ||
| type SxProp, | ||
| ToggleSwitch as PrimerToggleSwitch, | ||
| type ToggleSwitchProps as PrimerToggleSwitchProps, | ||
| } from '@primer/react' | ||
| import {forwardRef} from 'react' | ||
| import type { | ||
| BackgroundProps, | ||
| BorderProps, | ||
| ColorProps, | ||
| FlexboxProps, | ||
| GridProps, | ||
| LayoutProps, | ||
| PositionProps, | ||
| ShadowProps, | ||
| SpaceProps, | ||
| TypographyProps, | ||
| } from 'styled-system' | ||
| import type {ForwardRefComponent} from './polymorphic' | ||
|
|
||
| type StyledProps = SxProp & | ||
| SpaceProps & | ||
| ColorProps & | ||
| TypographyProps & | ||
| LayoutProps & | ||
| FlexboxProps & | ||
| GridProps & | ||
| BackgroundProps & | ||
| BorderProps & | ||
| PositionProps & | ||
| ShadowProps | ||
|
|
||
| const ToggleSwitch = forwardRef(function ToggleSwitch(props, ref) { | ||
| // @ts-expect-error there is an issue with polymorphic `as` with this | ||
| // component | ||
| return <Box as={PrimerToggleSwitch} ref={ref} {...props} /> | ||
| }) as ForwardRefComponent<'span', PrimerToggleSwitchProps & Omit<StyledProps, keyof PrimerToggleSwitchProps>> | ||
|
|
||
| export {ToggleSwitch} | ||
|
|
||
| export { | ||
| ActionList, | ||
| ActionMenu, | ||
| Autocomplete, | ||
| Avatar, | ||
| BranchName, | ||
| Breadcrumbs, | ||
| Button, | ||
| Checkbox, | ||
| CheckboxGroup, | ||
| CircleBadge, | ||
| CounterLabel, | ||
| Details, | ||
| Dialog, | ||
| Flash, | ||
| FormControl, | ||
| Header, | ||
| Heading, | ||
| IconButton, | ||
| Label, | ||
| LabelGroup, | ||
| Link, | ||
| LinkButton, | ||
| NavList, | ||
| Overlay, | ||
| PageHeader, | ||
| PageLayout, | ||
| Popover, | ||
| ProgressBar, | ||
| RadioGroup, | ||
| RelativeTime, | ||
| SegmentedControl, | ||
| Select, | ||
| SelectPanel, | ||
| SideNav, | ||
| Spinner, | ||
| Stack, | ||
| StateLabel, | ||
| SubNav, | ||
| Text, | ||
| Textarea, | ||
| TextInput, | ||
| TextInputWithTokens, | ||
| Timeline, | ||
| Token, | ||
| Tooltip, | ||
| Truncate, | ||
| UnderlineNav, | ||
|
|
||
| // styled-components components or types | ||
| Box, | ||
| sx, | ||
|
|
||
| // theming depends on styled-components | ||
| ThemeProvider, | ||
| merge, | ||
| theme, | ||
| themeGet, | ||
| useColorSchemeVar, | ||
| useTheme, | ||
| } from '@primer/react' | ||
| export type {BoxProps, SxProp, BetterSystemStyleObject} | ||
This file contains hidden or 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,60 @@ | ||
| /** | ||
| * This file is originally from `@radix-ui/react-polymorphic` before the package | ||
| * was deprecated. The original source for this lived in the URL below. | ||
| * | ||
| * @see https://github.com/radix-ui/primitives/blob/17ffcb7aaa42cbd36b3c210ba86d7d73d218e5be/packages/react/polymorphic/src/polymorphic.ts | ||
| */ | ||
|
|
||
| import * as React from 'react' | ||
|
|
||
| /* ------------------------------------------------------------------------------------------------- | ||
| * Utility types | ||
| * -----------------------------------------------------------------------------------------------*/ | ||
| type Merge<P1 = {}, P2 = {}> = Omit<P1, keyof P2> & P2 | ||
|
|
||
| /** | ||
| * Infers the OwnProps if E is a ForwardRefExoticComponentWithAs | ||
| */ | ||
| type OwnProps<E> = E extends ForwardRefComponent<any, infer P> ? P : {} | ||
|
|
||
| /** | ||
| * Infers the JSX.IntrinsicElement if E is a ForwardRefExoticComponentWithAs | ||
| */ | ||
| type IntrinsicElement<E> = E extends ForwardRefComponent<infer I, any> ? I : never | ||
|
|
||
| type ForwardRefExoticComponent<E, OwnProps> = React.ForwardRefExoticComponent< | ||
| Merge<E extends React.ElementType ? React.ComponentPropsWithRef<E> : never, OwnProps & {as?: E}> | ||
| > | ||
|
|
||
| /* ------------------------------------------------------------------------------------------------- | ||
| * ForwardRefComponent | ||
| * -----------------------------------------------------------------------------------------------*/ | ||
|
|
||
| interface ForwardRefComponent< | ||
| IntrinsicElementString, | ||
| OwnProps = {}, | ||
| /** | ||
| * Extends original type to ensure built in React types play nice | ||
| * with polymorphic components still e.g. `React.ElementRef` etc. | ||
| */ | ||
| > extends ForwardRefExoticComponent<IntrinsicElementString, OwnProps> { | ||
| /** | ||
| * When `as` prop is passed, use this overload. | ||
| * Merges original own props (without DOM props) and the inferred props | ||
| * from `as` element with the own props taking precedence. | ||
| * | ||
| * We explicitly avoid `React.ElementType` and manually narrow the prop types | ||
| * so that events are typed when using JSX.IntrinsicElements. | ||
| */ | ||
| <As = IntrinsicElementString>( | ||
| props: As extends '' | ||
| ? {as: keyof JSX.IntrinsicElements} | ||
| : As extends React.ComponentType<infer P> | ||
| ? Merge<P, OwnProps & {as: As}> | ||
| : As extends keyof JSX.IntrinsicElements | ||
| ? Merge<JSX.IntrinsicElements[As], OwnProps & {as: As}> | ||
| : never, | ||
| ): React.ReactElement | null | ||
| } | ||
|
|
||
| export type {ForwardRefComponent, OwnProps, IntrinsicElement, Merge} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.