Skip to content

Commit

Permalink
refactor: make types more readable
Browse files Browse the repository at this point in the history
  • Loading branch information
AshGw committed Jun 11, 2024
1 parent eb921c7 commit f71b60d
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,21 @@ const DEFAULT = {
GLOW_COLOR: 'rgb(155, 46, 199)',
} as const;

const Dot = styled.div<{ glowColor?: RGB; circleSize?: Pixel; delay?: string }>`
declare const __s: unique symbol;
type Brand<N, T> = T & {
[__s]: N;
};

export type RGB = Brand<'RBG', string>;
export type Pixel = Brand<'Pixel', string>;

type DotProps = {
glowColor?: RGB;
circleSize?: Pixel;
delay?: string;
};

const Dot = styled.div<DotProps>`
width: ${(props) => props.circleSize || DEFAULT.CIRCLE_SIZE};
height: ${(props) => props.circleSize || DEFAULT.CIRCLE_SIZE};
border-radius: 50%;
Expand Down Expand Up @@ -36,18 +50,7 @@ const Dot = styled.div<{ glowColor?: RGB; circleSize?: Pixel; delay?: string }>`
}
`;

declare const __s: unique symbol;
type _Brand<N, T> = T & {
[__s]: N;
};

export type RGB = _Brand<'RBG', string>;
export type Pixel = _Brand<'Pixel', string>;

interface DotsProps {
glowColor?: RGB;
circleSize?: Pixel;
}
type DotsProps = Omit<DotProps, 'delay'>;

export interface LoaderProps
extends React.ButtonHTMLAttributes<HTMLDivElement>,
Expand Down

0 comments on commit f71b60d

Please sign in to comment.