Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 2 additions & 1 deletion packages/react/src/__tests__/ThemeProvider.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import {render, screen, waitFor} from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import {describe, expect, it, vi} from 'vitest'
import React from 'react'
import {Box, ThemeProvider, useColorSchemeVar, useTheme} from '..'
import {ThemeProvider, useColorSchemeVar, useTheme} from '../'
import Box from '../Box'

// window.matchMedia() is not implemented by JSDOM so we have to create a mock:
// https://vijs.io/docs/manual-mocks#mocking-methods-which-are-not-implemented-in-jsdom
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ exports[`@primer/react > should not update exports without a semver change 1`] =
"type BaseStylesProps",
"type BetterCssProperties",
"type BetterSystemStyleObject",
"Box",
"type BoxProps",
"BranchName",
"type BranchNameProps",
"Breadcrumb",
Expand Down
2 changes: 0 additions & 2 deletions packages/react/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ export {default as ThemeProvider, useTheme, useColorSchemeVar} from './ThemeProv
export type {ThemeProviderProps} from './ThemeProvider'

// Layout
export {default as Box} from './Box'
export type {BoxProps} from './Box'
export * from './Button'
export {PageLayout} from './PageLayout'
export type {
Expand Down
60 changes: 59 additions & 1 deletion packages/styled-react/src/components/Box.tsx
Original file line number Diff line number Diff line change
@@ -1 +1,59 @@
export {Box, type BoxProps} from '@primer/react'
import styled from 'styled-components'
import type {
BackgroundProps,
BorderProps,
ColorProps,
FlexboxProps,
GridProps,
LayoutProps,
PositionProps,
ShadowProps,
SpaceProps,
TypographyProps,
} from 'styled-system'
import {background, border, color, flexbox, grid, layout, position, shadow, space, typography} from 'styled-system'
import type {SxProp} from '../sx'
import {sx} from '../sx'

type ComponentProps<T> =
T extends React.ComponentType<React.PropsWithChildren<infer Props>> ? (Props extends object ? Props : never) : never
Comment thread
francinelucca marked this conversation as resolved.

type StyledBoxProps = SxProp &
SpaceProps &
ColorProps &
TypographyProps &
LayoutProps &
FlexboxProps &
GridProps &
BackgroundProps &
BorderProps &
PositionProps &
ShadowProps

/**
* @deprecated The Box component is deprecated. Replace with a `div` or
* appropriate HTML element instead, with CSS modules for styling.
* @see https://github.com/primer/react/blob/main/contributor-docs/migration-from-box.md
*/
const Box = styled.div<StyledBoxProps>(
space,
color,
typography,
layout,
flexbox,
grid,
background,
border,
position,
shadow,
sx,
)

/**
* @deprecated The Box component is deprecated. Replace with a `div` or
* appropriate HTML element instead, with CSS modules for styling.
* @see https://github.com/primer/react/blob/main/contributor-docs/migration-from-box.md
*/
export type BoxProps = ComponentProps<typeof Box>
export default Box
export {Box}
7 changes: 2 additions & 5 deletions packages/styled-react/src/components/CheckboxGroup.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import {
Box,
CheckboxGroup as PrimerCheckboxGroup,
type CheckboxGroupProps as PrimerCheckboxGroupProps,
} from '@primer/react'
import {CheckboxGroup as PrimerCheckboxGroup, type CheckboxGroupProps as PrimerCheckboxGroupProps} from '@primer/react'
import React, {type PropsWithChildren} from 'react'
import type {SxProp} from '../sx'
import Box from './Box'

export type CheckboxGroupProps = PropsWithChildren<PrimerCheckboxGroupProps> & SxProp

Expand Down
3 changes: 2 additions & 1 deletion packages/styled-react/src/components/NavList.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {NavList as PrimerNavList, Box} from '@primer/react'
import {NavList as PrimerNavList} from '@primer/react'
import type {
NavListProps as PrimerNavListProps,
NavListItemProps as PrimerNavListItemProps,
Expand All @@ -8,6 +8,7 @@ import type {
} from '@primer/react'
import {forwardRef, type PropsWithChildren} from 'react'
import {type SxProp} from '../sx'
import Box from './Box'

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

Expand Down
3 changes: 2 additions & 1 deletion packages/styled-react/src/components/RadioGroup.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {Box, RadioGroup as PrimerRadioGroup, type RadioGroupProps as PrimerRadioGroupProps} from '@primer/react'
import {RadioGroup as PrimerRadioGroup, type RadioGroupProps as PrimerRadioGroupProps} from '@primer/react'
import React, {type PropsWithChildren} from 'react'
import type {SxProp} from '../sx'
import Box from './Box'

export type RadioGroupProps = PropsWithChildren<PrimerRadioGroupProps> & SxProp

Expand Down
3 changes: 2 additions & 1 deletion packages/styled-react/src/components/RelativeTime.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {Box, RelativeTime as PrimerRelativeTime, type RelativeTimeProps as PrimerRelativeTimeProps} from '@primer/react'
import {RelativeTime as PrimerRelativeTime, type RelativeTimeProps as PrimerRelativeTimeProps} from '@primer/react'
import React from 'react'
import type {SxProp} from '../sx'
import Box from './Box'

export type RelativeTimeProps = PrimerRelativeTimeProps & SxProp

Expand Down
Loading