Skip to content

Commit 0889246

Browse files
chore: remove Box, BoxProps export (#7015)
1 parent a3f7ea9 commit 0889246

File tree

9 files changed

+76
-14
lines changed

9 files changed

+76
-14
lines changed

.changeset/rich-chefs-attend.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"@primer/react": major
3+
"@primer/styled-react": patch
4+
---
5+
6+
@primer/react: chore: remove Box, BoxProps export
7+
@primer/styled-react: add Box component

packages/react/src/__tests__/ThemeProvider.test.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import {render, screen, waitFor} from '@testing-library/react'
22
import userEvent from '@testing-library/user-event'
33
import {describe, expect, it, vi} from 'vitest'
44
import React from 'react'
5-
import {Box, ThemeProvider, useColorSchemeVar, useTheme} from '..'
5+
import {ThemeProvider, useColorSchemeVar, useTheme} from '../'
6+
import Box from '../Box'
67

78
// window.matchMedia() is not implemented by JSDOM so we have to create a mock:
89
// https://vijs.io/docs/manual-mocks#mocking-methods-which-are-not-implemented-in-jsdom

packages/react/src/__tests__/__snapshots__/exports.test.ts.snap

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ exports[`@primer/react > should not update exports without a semver change 1`] =
3333
"type BaseStylesProps",
3434
"type BetterCssProperties",
3535
"type BetterSystemStyleObject",
36-
"Box",
37-
"type BoxProps",
3836
"BranchName",
3937
"type BranchNameProps",
4038
"Breadcrumb",

packages/react/src/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ export {default as ThemeProvider, useTheme, useColorSchemeVar} from './ThemeProv
88
export type {ThemeProviderProps} from './ThemeProvider'
99

1010
// Layout
11-
export {default as Box} from './Box'
12-
export type {BoxProps} from './Box'
1311
export * from './Button'
1412
export {PageLayout} from './PageLayout'
1513
export type {
Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,59 @@
1-
export {Box, type BoxProps} from '@primer/react'
1+
import styled from 'styled-components'
2+
import type {
3+
BackgroundProps,
4+
BorderProps,
5+
ColorProps,
6+
FlexboxProps,
7+
GridProps,
8+
LayoutProps,
9+
PositionProps,
10+
ShadowProps,
11+
SpaceProps,
12+
TypographyProps,
13+
} from 'styled-system'
14+
import {background, border, color, flexbox, grid, layout, position, shadow, space, typography} from 'styled-system'
15+
import type {SxProp} from '../sx'
16+
import {sx} from '../sx'
17+
18+
type ComponentProps<T> =
19+
T extends React.ComponentType<React.PropsWithChildren<infer Props>> ? (Props extends object ? Props : never) : never
20+
21+
type StyledBoxProps = SxProp &
22+
SpaceProps &
23+
ColorProps &
24+
TypographyProps &
25+
LayoutProps &
26+
FlexboxProps &
27+
GridProps &
28+
BackgroundProps &
29+
BorderProps &
30+
PositionProps &
31+
ShadowProps
32+
33+
/**
34+
* @deprecated The Box component is deprecated. Replace with a `div` or
35+
* appropriate HTML element instead, with CSS modules for styling.
36+
* @see https://github.com/primer/react/blob/main/contributor-docs/migration-from-box.md
37+
*/
38+
const Box = styled.div<StyledBoxProps>(
39+
space,
40+
color,
41+
typography,
42+
layout,
43+
flexbox,
44+
grid,
45+
background,
46+
border,
47+
position,
48+
shadow,
49+
sx,
50+
)
51+
52+
/**
53+
* @deprecated The Box component is deprecated. Replace with a `div` or
54+
* appropriate HTML element instead, with CSS modules for styling.
55+
* @see https://github.com/primer/react/blob/main/contributor-docs/migration-from-box.md
56+
*/
57+
export type BoxProps = ComponentProps<typeof Box>
58+
export default Box
59+
export {Box}

packages/styled-react/src/components/CheckboxGroup.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
import {
2-
Box,
3-
CheckboxGroup as PrimerCheckboxGroup,
4-
type CheckboxGroupProps as PrimerCheckboxGroupProps,
5-
} from '@primer/react'
1+
import {CheckboxGroup as PrimerCheckboxGroup, type CheckboxGroupProps as PrimerCheckboxGroupProps} from '@primer/react'
62
import React, {type PropsWithChildren} from 'react'
73
import type {SxProp} from '../sx'
4+
import Box from './Box'
85

96
export type CheckboxGroupProps = PropsWithChildren<PrimerCheckboxGroupProps> & SxProp
107

packages/styled-react/src/components/NavList.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {NavList as PrimerNavList, Box} from '@primer/react'
1+
import {NavList as PrimerNavList} from '@primer/react'
22
import type {
33
NavListProps as PrimerNavListProps,
44
NavListItemProps as PrimerNavListItemProps,
@@ -8,6 +8,7 @@ import type {
88
} from '@primer/react'
99
import {forwardRef, type PropsWithChildren} from 'react'
1010
import {type SxProp} from '../sx'
11+
import Box from './Box'
1112

1213
type RefComponent<E extends HTMLElement, P> = React.ForwardRefExoticComponent<P & React.RefAttributes<E>>
1314

packages/styled-react/src/components/RadioGroup.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import {Box, RadioGroup as PrimerRadioGroup, type RadioGroupProps as PrimerRadioGroupProps} from '@primer/react'
1+
import {RadioGroup as PrimerRadioGroup, type RadioGroupProps as PrimerRadioGroupProps} from '@primer/react'
22
import React, {type PropsWithChildren} from 'react'
33
import type {SxProp} from '../sx'
4+
import Box from './Box'
45

56
export type RadioGroupProps = PropsWithChildren<PrimerRadioGroupProps> & SxProp
67

packages/styled-react/src/components/RelativeTime.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import {Box, RelativeTime as PrimerRelativeTime, type RelativeTimeProps as PrimerRelativeTimeProps} from '@primer/react'
1+
import {RelativeTime as PrimerRelativeTime, type RelativeTimeProps as PrimerRelativeTimeProps} from '@primer/react'
22
import React from 'react'
33
import type {SxProp} from '../sx'
4+
import Box from './Box'
45

56
export type RelativeTimeProps = PrimerRelativeTimeProps & SxProp
67

0 commit comments

Comments
 (0)