Skip to content

Commit 76be7da

Browse files
committed
frontend: cleanup types in button component
Use named type and fix indentation
1 parent 6a75fae commit 76be7da

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

frontends/web/src/components/forms/button.tsx

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ type TProps = TButtonStyleProp & {
3737
children: ReactNode;
3838
}
3939

40+
type TButtonLink = LinkProps & TProps;
41+
4042
export const ButtonLink = ({
4143
primary,
4244
secondary,
@@ -46,14 +48,14 @@ export const ButtonLink = ({
4648
children,
4749
disabled,
4850
...props
49-
}: LinkProps & TProps) => {
51+
}: TButtonLink) => {
5052
const classNames = [
5153
style[
5254
(primary && 'primary')
53-
|| (secondary && 'secondary')
54-
|| (transparent && 'transparent')
55-
|| (danger && 'danger')
56-
|| 'button'
55+
|| (secondary && 'secondary')
56+
|| (transparent && 'transparent')
57+
|| (danger && 'danger')
58+
|| 'button'
5759
], className
5860
].join(' ');
5961

@@ -75,6 +77,8 @@ export const ButtonLink = ({
7577
);
7678
};
7779

80+
type TButton = TProps & ComponentPropsWithoutRef<'button'>;
81+
7882
export const Button = ({
7983
type = 'button',
8084
primary,
@@ -84,13 +88,14 @@ export const Button = ({
8488
className = '',
8589
children,
8690
...props
87-
}: TProps & ComponentPropsWithoutRef<'button'>) => {
91+
}: TButton) => {
8892
const classNames = [
89-
style[(primary && 'primary')
90-
|| (secondary && 'secondary')
91-
|| (transparent && 'transparent')
92-
|| (danger && 'danger')
93-
|| 'button'
93+
style[
94+
(primary && 'primary')
95+
|| (secondary && 'secondary')
96+
|| (transparent && 'transparent')
97+
|| (danger && 'danger')
98+
|| 'button'
9499
], className
95100
].join(' ');
96101

0 commit comments

Comments
 (0)