File tree 2 files changed +21
-11
lines changed
packages/qwik-storefront-ui/src/components/SfButton
2 files changed +21
-11
lines changed Original file line number Diff line number Diff line change @@ -18,14 +18,25 @@ export const getSizeClasses = (
18
18
) => {
19
19
switch ( size ) {
20
20
case SfButtonSize . sm :
21
- return [ square ? 'p-1.5' : 'leading-5 text-sm py-1.5 px-3' , 'gap-1.5' ] ;
21
+ return [
22
+ square ? 'p-1.5' : 'leading-5 text-sm py-1.5 px-3' ,
23
+ 'gap-1.5' ,
24
+ ] . join ( ' ' ) ;
22
25
case SfButtonSize . lg :
23
- return [ square ? 'p-4' : 'py-3 leading-6 px-6' , 'gap-3' ] ;
26
+ return [ square ? 'p-4' : 'py-3 leading-6 px-6' , 'gap-3' ] . join ( ' ' ) ;
24
27
default :
25
- return [ square ? 'p-2' : 'py-2 leading-6 px-4' , 'gap-2' ] ;
28
+ return [ square ? 'p-2' : 'py-2 leading-6 px-4' , 'gap-2' ] . join ( ' ' ) ;
26
29
}
27
30
} ;
28
31
32
+ const Button = component$ ( ( attributes ) => {
33
+ return (
34
+ < button { ...attributes } >
35
+ < Slot />
36
+ </ button >
37
+ ) ;
38
+ } ) ;
39
+
29
40
export const SfButton = component$ < SfButtonProps > (
30
41
( {
31
42
as,
@@ -36,18 +47,15 @@ export const SfButton = component$<SfButtonProps>(
36
47
slotSuffix,
37
48
variant = SfButtonVariant . primary ,
38
49
square,
50
+ type,
39
51
...attributes
40
52
} ) => {
41
- const Tag = as || defaultButtonTag ;
53
+ const Tag = as || Button ;
42
54
43
55
return (
44
56
< Tag
45
57
{ ...( ref ? { ref } : { } ) }
46
- type = {
47
- typeof Tag === 'string' && Tag . toLowerCase ( ) === 'button'
48
- ? 'button'
49
- : undefined
50
- }
58
+ type = { type }
51
59
class = { [
52
60
'inline-flex items-center justify-center font-medium text-base focus-visible:outline focus-visible:outline-offset rounded-md disabled:text-disabled-500 disabled:bg-disabled-300 disabled:shadow-none disabled:ring-0 disabled:cursor-not-allowed' ,
53
61
getSizeClasses ( size , square ) ,
Original file line number Diff line number Diff line change @@ -5,16 +5,18 @@ import {
5
5
Signal ,
6
6
} from '@builder.io/qwik' ;
7
7
8
- export type SfButtonProps = QwikIntrinsicElements [ 'button' ] &
9
- QwikIntrinsicElements [ 'a' ] & {
8
+ export type SfButtonProps = Omit < QwikIntrinsicElements [ 'button' ] , 'type' > &
9
+ Omit < QwikIntrinsicElements [ 'a' ] , 'type' > & {
10
10
as ?: any ;
11
+ class ?: string ;
11
12
ref ?: Signal < Element | undefined > ;
12
13
size ?: `${SfButtonSize } `;
13
14
variant ?: `${SfButtonVariant } `;
14
15
slotPrefix ?: boolean ;
15
16
slotSuffix ?: boolean ;
16
17
disabled ?: boolean ;
17
18
square ?: boolean ;
19
+ type ?: 'button' | 'reset' | 'submit' ;
18
20
onClick$ ?: PropFunction <
19
21
( event : QwikMouseEvent < HTMLButtonElement , MouseEvent > ) => void
20
22
> ;
You can’t perform that action at this time.
0 commit comments