File tree Expand file tree Collapse file tree 2 files changed +21
-11
lines changed
packages/qwik-storefront-ui/src/components/SfButton Expand file tree Collapse file tree 2 files changed +21
-11
lines changed Original file line number Diff line number Diff line change @@ -18,14 +18,25 @@ export const getSizeClasses = (
1818) => {
1919 switch ( size ) {
2020 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 ( ' ' ) ;
2225 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 ( ' ' ) ;
2427 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 ( ' ' ) ;
2629 }
2730} ;
2831
32+ const Button = component$ ( ( attributes ) => {
33+ return (
34+ < button { ...attributes } >
35+ < Slot />
36+ </ button >
37+ ) ;
38+ } ) ;
39+
2940export const SfButton = component$ < SfButtonProps > (
3041 ( {
3142 as,
@@ -36,18 +47,15 @@ export const SfButton = component$<SfButtonProps>(
3647 slotSuffix,
3748 variant = SfButtonVariant . primary ,
3849 square,
50+ type,
3951 ...attributes
4052 } ) => {
41- const Tag = as || defaultButtonTag ;
53+ const Tag = as || Button ;
4254
4355 return (
4456 < Tag
4557 { ...( ref ? { ref } : { } ) }
46- type = {
47- typeof Tag === 'string' && Tag . toLowerCase ( ) === 'button'
48- ? 'button'
49- : undefined
50- }
58+ type = { type }
5159 class = { [
5260 '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' ,
5361 getSizeClasses ( size , square ) ,
Original file line number Diff line number Diff line change @@ -5,16 +5,18 @@ import {
55 Signal ,
66} from '@builder.io/qwik' ;
77
8- export type SfButtonProps = QwikIntrinsicElements [ 'button' ] &
9- QwikIntrinsicElements [ 'a' ] & {
8+ export type SfButtonProps = Omit < QwikIntrinsicElements [ 'button' ] , 'type' > &
9+ Omit < QwikIntrinsicElements [ 'a' ] , 'type' > & {
1010 as ?: any ;
11+ class ?: string ;
1112 ref ?: Signal < Element | undefined > ;
1213 size ?: `${SfButtonSize } `;
1314 variant ?: `${SfButtonVariant } `;
1415 slotPrefix ?: boolean ;
1516 slotSuffix ?: boolean ;
1617 disabled ?: boolean ;
1718 square ?: boolean ;
19+ type ?: 'button' | 'reset' | 'submit' ;
1820 onClick$ ?: PropFunction <
1921 ( event : QwikMouseEvent < HTMLButtonElement , MouseEvent > ) => void
2022 > ;
You can’t perform that action at this time.
0 commit comments