File tree Expand file tree Collapse file tree 6 files changed +49
-20
lines changed
Expand file tree Collapse file tree 6 files changed +49
-20
lines changed Original file line number Diff line number Diff line change 11import { AnchorHTMLAttributes , ButtonHTMLAttributes , ReactNode } from 'react'
22import { DefaultTheme } from 'styled-components'
3+ import { WithStyledProps } from '../../../types'
34
45export type ButtonSize = 'sm' | 'md' | 'lg'
56export type ButtonTag = 'button' | 'a'
67
78export type ButtonProps = AnchorHTMLAttributes < HTMLAnchorElement > &
8- ButtonHTMLAttributes < HTMLButtonElement > & {
9+ ButtonHTMLAttributes < HTMLButtonElement > &
10+ WithStyledProps < ButtonTag > & {
911 children : ReactNode
1012 kind ?: string
1113 variant ?: string
@@ -18,7 +20,6 @@ export type ButtonProps = AnchorHTMLAttributes<HTMLAnchorElement> &
1820 focus ?: boolean
1921 disabled ?: boolean
2022
21- as ?: ButtonTag
2223 className ?: string
2324
2425 animation ?:
Original file line number Diff line number Diff line change 11import { HTMLAttributes , ReactNode } from 'react'
22import { Typo , TypoKind } from '../../../themes/types'
3+ import { WithStyledProps } from '../../../types'
34
45export type TypeElements =
56 | 'h1'
@@ -17,14 +18,14 @@ export type TypeElements =
1718 | 'span'
1819 | 'strong'
1920
20- export type TextGradientProps = HTMLAttributes < HTMLElement > & {
21- children : ReactNode
22- size ?: number | string
23- color ?: string
24- type ?: TypoKind
25- className ?: string
26- as ?: TypeElements
27- }
21+ export type TextGradientProps = HTMLAttributes < HTMLElement > &
22+ WithStyledProps < TypeElements > & {
23+ children : ReactNode
24+ size ?: number | string
25+ color ?: string
26+ type ?: TypoKind
27+ className ?: string
28+ }
2829
2930export type StyledTextGradientProps = {
3031 size ?: number | string
Original file line number Diff line number Diff line change @@ -32,6 +32,10 @@ export const Tooltip = ({
3232 onClose,
3333 onCloseClick,
3434 closeDelay = 200 ,
35+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
36+ forwardedAs : _forwardedAs ,
37+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
38+ as : _as ,
3539 ...rest
3640} : TooltipProps ) => {
3741 const tooltipRef = useRef < any > ( )
Original file line number Diff line number Diff line change 11import { ReactNode , RefObject } from 'react'
22import { FloatPosition , FloatPositionType } from '../../../hooks'
3+ import { WithStyledProps } from '../../../types'
34
45export type TooltipPositionType = FloatPositionType
56export type TooltipPosition = FloatPosition
67export type TooltipVariant = 1 | 2
78
8- export type TooltipProps = {
9+ export type TooltipProps = WithStyledProps & {
910 my : TooltipPositionType
1011 at : TooltipPositionType
1112 margin ?: TooltipPosition
@@ -22,12 +23,12 @@ export type TooltipProps = {
2223 onClose ?: ( ) => void
2324 onCloseClick ?: ( ) => void
2425} & (
25- | {
26- children : ReactNode & { ref ?: RefObject < any > }
27- targetRef ?: RefObject < any >
28- }
29- | {
30- children ?: ReactNode & { ref ?: RefObject < any > }
31- targetRef : RefObject < any >
32- }
33- )
26+ | {
27+ children : ReactNode & { ref ?: RefObject < any > }
28+ targetRef ?: RefObject < any >
29+ }
30+ | {
31+ children ?: ReactNode & { ref ?: RefObject < any > }
32+ targetRef : RefObject < any >
33+ }
34+ )
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ export const CompositeTitle = ({
1111 numberColor = 'text' ,
1212 labelColor = 'text' ,
1313 label,
14+ forwardedAs : _forwardedAs , // eslint-disable-line @typescript-eslint/no-unused-vars
1415 ...rest
1516} : CompositeTitleProps ) => {
1617 return (
Original file line number Diff line number Diff line change 11import { AnchorHTMLAttributes , ComponentType , ImgHTMLAttributes } from 'react'
2+ import type { CSSProp } from 'styled-components'
23import type { IconName } from './components/common/Icon'
34
5+ /**
6+ * Utility type for adding styled-components props to component types.
7+ * Provides `as`, `forwardedAs`, and `css` props with optional type constraints.
8+ *
9+ * @template TAs - Type constraint for `as` and `forwardedAs` props (defaults to string | Element)
10+ *
11+ * @example
12+ * // With type constraint
13+ * type ButtonProps = WithStyledProps<'button' | 'a'> & { ... }
14+ *
15+ * @example
16+ * // Without constraint (accepts any element)
17+ * type GenericProps = WithStyledProps & { ... }
18+ */
19+ export type WithStyledProps < TAs = string | Element > = {
20+ as ?: TAs
21+ forwardedAs ?: TAs
22+ css ?: CSSProp
23+ }
24+
425export type Route = {
526 href : string
627 external ?: boolean
You can’t perform that action at this time.
0 commit comments