Skip to content

Commit

Permalink
Box block, VariantProps fix (#162)
Browse files Browse the repository at this point in the history
* fix(types): export VariantProps from @stitches/react

* fix(Box): default { display: block }

* fix(types): revert back to our VariantProps ☹️

* chore: export FlexProps with (to-be-deprecated) FlexVariant type alias
  • Loading branch information
shawnbot authored Feb 14, 2023
1 parent 86ad83e commit c332401
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
4 changes: 3 additions & 1 deletion react/src/components/Box.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { styled } from '../stitches.config'
import type { VariantProps } from '../utils'

export const Box = styled('div')
export const Box = styled('div', {
display: 'block'
})

export type BoxProps = VariantProps<typeof Box>
5 changes: 4 additions & 1 deletion react/src/components/Flex.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,7 @@ export const Flex = styled(Box, {
}
})

export type FlexVariant = VariantProps<typeof Flex>
export type FlexProps = VariantProps<typeof Flex>

// FIXME[1.0]: remove this alias
export type FlexVariant = FlexProps
8 changes: 5 additions & 3 deletions react/src/utils.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import React, { Component, ComponentProps, ComponentType } from 'react'
import React, { ComponentProps, ComponentType } from 'react'

// XXX: export type { VariantProps } from '@stitches/react'

export type VariantProps<T> = JSX.IntrinsicAttributes & (T extends ComponentType ? ComponentProps<T> : T)

export function identity (v: any) {
return v
Expand All @@ -21,5 +25,3 @@ export function withFixedProps (
return <Component {...fixed} {...props} />
}
}

export type VariantProps<T, P extends {} = T extends ComponentType ? ComponentProps<T> : T> = T & JSX.IntrinsicAttributes

0 comments on commit c332401

Please sign in to comment.