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

Move deprecated components to deprecated folder #1881

Merged
merged 7 commits into from
Feb 24, 2022
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
5 changes: 5 additions & 0 deletions .changeset/empty-pillows-hunt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/react': major
---

Prepare library for `v35`
5 changes: 5 additions & 0 deletions .changeset/smooth-cameras-prove.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@primer/react": major
---

Move deprecated components to deprecated folder
Copy link
Contributor

Choose a reason for hiding this comment

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

A TODO for later @pksjce, we'll need to put more specific breaking change release notes for the components that have moved in this PR.

9 changes: 9 additions & 0 deletions deprecated/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"_comment1": "this is required only for typescript. once this is fixed https://github.com/microsoft/TypeScript/issues/33079 we can remove this hack",
"name": "@primer/react/deprecated",
"types": "../lib-esm/deprecated/index.d.ts",
"main": "../lib-esm/deprecated/index.js",
"type": "module",
"sideEffects": false
}

323 changes: 155 additions & 168 deletions docs/package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"npm": ">=7"
},
"dependencies": {
"@primer/gatsby-theme-doctocat": "^3.2.0",
"@primer/gatsby-theme-doctocat": "^3.2.1",
"@primer/octicons-react": "^16.1.0",
"@primer/primitives": "4.1.0",
"@styled-system/prop-types": "^5.1.0",
Expand Down
2 changes: 2 additions & 0 deletions docs/src/@primer/gatsby-theme-doctocat/live-code-scope.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import {
} from '@primer/octicons-react'
import * as primerComponents from '@primer/react'
import * as drafts from '@primer/react/drafts'
import * as deprecated from '@primer/react/deprecated'
import {Placeholder} from '@primer/react/Placeholder'
import React from 'react'
import {AnchoredOverlay} from '../../../../src/AnchoredOverlay'
Expand All @@ -51,6 +52,7 @@ export default function resolveScope(metastring) {
...doctocatComponents,
...primerComponents,
...(metastring.includes('drafts') ? drafts : {}),
...deprecated,
Copy link
Contributor

Choose a reason for hiding this comment

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

Out of curiosity, why is deprecated different to drafts in that we aren't checking metadata like the preceding line?

Copy link
Member

Choose a reason for hiding this comment

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

I think it needs to be conditional, otherwise deprecated components will override components with the same name and you will always see deprecated components in scope

...
...primerComponents, // has Button, ActionMenu
...
...deprecated // also has Button, ActionMenu

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
...deprecated,
...(metastring.includes('deprecated') ? deprecated : {}),

ReactRouterLink,
State,
CheckIcon,
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,19 @@
"exports": {
".": {
"node": "./lib/index.js",
"require": "./lib/index.js",
"default": "./lib-esm/index.js"
},
"./drafts": {
"node": "./lib/drafts/index.js",
"require": "./lib/drafts/index.js",
"default": "./lib-esm/drafts/index.js"
},
"./deprecated": {
"node": "./lib/deprecated/index.js",
"require": "./lib/deprecated/index.js",
"default": "./lib-esm/deprecated/index.js"
},
"./lib-esm/*": {
"node": [
"./lib/*.js",
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/BorderBox.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react'
import theme from '../theme'
import {BorderBox} from '..'
import {BorderBox} from '../deprecated'
import {render, behavesAsComponent, checkExports} from '../utils/testing'
import {render as HTMLRender, cleanup} from '@testing-library/react'
import {axe, toHaveNoViolations} from 'jest-axe'
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/Dropdown.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react'
import {Dropdown} from '..'
import {Dropdown} from '../deprecated'
import {behavesAsComponent, checkExports} from '../utils/testing'
import {render as HTMLRender, cleanup} from '@testing-library/react'
import {axe, toHaveNoViolations} from 'jest-axe'
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/Flex.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react'
import {Flex} from '..'
import {Flex} from '../deprecated'
import {render, behavesAsComponent, checkExports} from '../utils/testing'
import {render as HTMLRender, cleanup} from '@testing-library/react'
import {axe, toHaveNoViolations} from 'jest-axe'
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/Grid.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react'
import {Grid} from '..'
import {Grid} from '../deprecated'
import {render, behavesAsComponent, checkExports} from '../utils/testing'
import {render as HTMLRender, cleanup} from '@testing-library/react'
import {axe, toHaveNoViolations} from 'jest-axe'
Expand Down
3 changes: 2 additions & 1 deletion src/__tests__/Position.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react'
import {Box, Position, Absolute, Fixed, Relative, Sticky} from '..'
import {Box} from '..'
import {Position, Absolute, Fixed, Relative, Sticky} from '../deprecated'
import {render, behavesAsComponent, checkExports} from '../utils/testing'
import {render as HTMLRender, cleanup} from '@testing-library/react'
import {axe, toHaveNoViolations} from 'jest-axe'
Expand Down
3 changes: 2 additions & 1 deletion src/__tests__/SelectMenu.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react'
import {SelectMenu, Button} from '..'
import {SelectMenu} from '../deprecated'
import {Button} from '..'
import {mount, render, renderRoot, COMPONENT_DISPLAY_NAME_REGEX, checkExports} from '../utils/testing'
import {render as HTMLRender, cleanup} from '@testing-library/react'
import {axe, toHaveNoViolations} from 'jest-axe'
Expand Down
39 changes: 39 additions & 0 deletions src/deprecated/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/** This is the place where we keep components that are deprecated.
* We don't recommend using it in production.
* If you already use them, please move to the suggested alternative components
*
* But, they are published on npm and you can import them.
* example: import {FormGroup} from '@primer/react/deprecated
*/

export {default as BorderBox} from '../BorderBox'
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we intentionally importing these from src instead of moving them to src/deprecated/?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Well we don't have all the draft component in a separate folder, so I kept it the same for deprecated

export type {BorderBoxProps} from '../BorderBox'
export {default as Flex} from '../Flex'
export type {FlexProps} from '../Flex'
export {default as Grid} from '../Grid'
export type {GridProps} from '../Grid'
export {default as Position, Absolute, Fixed, Relative, Sticky} from '../Position'
export type {PositionProps, AbsoluteProps, FixedProps, RelativeProps, StickyProps} from '../Position'
export {default as Dropdown} from '../Dropdown'
export type {
DropdownProps,
DropdownCaretProps,
DropdownButtonProps,
DropdownItemProps,
DropdownMenuProps
} from '../Dropdown'
export {default as SelectMenu} from '../SelectMenu'
Copy link
Contributor

Choose a reason for hiding this comment

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

Think you're missing the props for SelectMenu, which are still in root index.ts

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done!

export type {
SelectMenuProps,
SelectMenuDividerProps,
SelectMenuFilterProps,
SelectMenuFooterProps,
SelectMenuItemProps,
SelectMenuListProps,
SelectMenuModalProps,
SelectMenuTabsProps,
SelectMenuHeaderProps,
SelectMenuTabProps,
SelectMenuTabPanelProps,
SelectMenuLoadingAnimationProps
} from '../SelectMenu'
32 changes: 1 addition & 31 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,8 @@ export {default as ThemeProvider, useTheme, useColorSchemeVar} from './ThemeProv
export type {ThemeProviderProps} from './ThemeProvider'

// Layout
export {default as BorderBox} from './BorderBox'
export type {BorderBoxProps} from './BorderBox'
export {default as Box} from './Box'
export type {BoxProps} from './Box'
export {default as Flex} from './Flex'
export type {FlexProps} from './Flex'
export {default as Grid} from './Grid'
export type {GridProps} from './Grid'
export {default as Position, Absolute, Fixed, Relative, Sticky} from './Position'
export type {PositionProps, AbsoluteProps, FixedProps, RelativeProps, StickyProps} from './Position'

// Hooks
export {default as useDetails} from './hooks/useDetails'
Expand Down Expand Up @@ -79,14 +71,7 @@ export type {DetailsProps} from './Details'
export {default as Dialog} from './Dialog'
export type {DialogProps, DialogHeaderProps} from './Dialog'
export {ConfirmationDialog} from './Dialog/ConfirmationDialog'
export {default as Dropdown} from './Dropdown'
export type {
DropdownProps,
DropdownCaretProps,
DropdownButtonProps,
DropdownItemProps,
DropdownMenuProps
} from './Dropdown'

export {DropdownButton, DropdownMenu} from './DropdownMenu'
// not exporting new DropdownMenu types yet due to conflict with Dropdown types above
// export type {DropdownButtonProps, DropdownMenuProps} from './DropdownMenu'
Expand Down Expand Up @@ -124,22 +109,7 @@ export type {PopoverProps, PopoverContentProps} from './Popover'
// export type {PortalProps} from './Portal'
export {default as ProgressBar} from './ProgressBar'
export type {ProgressBarProps} from './ProgressBar'
export {default as SelectMenu} from './SelectMenu'
export {default as Select} from './Select'
export type {
SelectMenuProps,
SelectMenuDividerProps,
SelectMenuFilterProps,
SelectMenuFooterProps,
SelectMenuItemProps,
SelectMenuListProps,
SelectMenuModalProps,
SelectMenuTabsProps,
SelectMenuHeaderProps,
SelectMenuTabProps,
SelectMenuTabPanelProps,
SelectMenuLoadingAnimationProps
} from './SelectMenu'
export {SelectPanel} from './SelectPanel'
export type {SelectPanelProps} from './SelectPanel'
export {default as SideNav} from './SideNav'
Expand Down