2121<script lang="ts" setup>
2222import { ComputedRef , StyleValue , computed , ref , watch } from ' vue' ;
2323import { dynamicSVG } from ' @/utils' ;
24- import { btnSizes , btnStyles , btnShapes , btnColors , createLighterShades } from ' ./props' ;
24+ import { btnSizes , btnStyles , btnShapes , textColors , createLighterShades } from ' ./props' ;
2525
2626const mBtn = ref <HTMLButtonElement | null >(null );
2727const shades = ref <string []>([]);
2828const customColorTest = ref <StyleValue >();
2929const mousedown = ref (false );
3030
31- watch (mousedown , () => {
32- console .log (' watch: ' , mousedown .value );
33- });
34-
3531const btnProps = defineProps ({
3632 text: {
3733 type: String ,
@@ -78,7 +74,7 @@ const btnProps = defineProps({
7874const handleBtnTextColor: ComputedRef <String > = computed (() => {
7975 if (! btnProps .textColor )
8076 return ' ' ;
81- return (btnColors as any )[ btnProps .textColor ];
77+ return (textColors as any )[ btnProps .textColor ];
8278});
8379
8480const handleBtnColor: ComputedRef <StyleValue | String [] | String | undefined > = computed (() => {
@@ -90,7 +86,7 @@ const handleBtnColor: ComputedRef<StyleValue | String[] | String | undefined> =
9086 mBtn .value ?.addEventListener (' mouseenter' , () => mBtn .value ! .style .backgroundColor = shades .value [ 0 ]);
9187 mBtn .value ?.addEventListener (' mouseleave' , () => mBtn .value ! .style .backgroundColor = btnProps .color );
9288
93- mBtn .value ?.addEventListener (' mousedown' , () => mBtn .value ! .style .backgroundColor = shades .value [ 1 ]);
89+ mBtn .value ?.addEventListener (' mousedown' , () => { mBtn .value ! .style .backgroundColor = shades .value [ 1 ]; mousedown . value = true ; } );
9490 mBtn .value ?.addEventListener (' mouseup' , () => mBtn .value ! .style .backgroundColor = shades .value [ 0 ]);
9591
9692 mBtn .value ?.addEventListener (' focusin' , () => {
@@ -129,9 +125,10 @@ const handleBtnTransparency = computed(() => {
129125const isCustomColor: ComputedRef <boolean > = computed (() => {
130126 if (typeof handleBtnColor .value == ' string' )
131127 return false ;
132- const test: string = ' test' ;
133128
134- return typeof handleBtnColor .value == ' object' && (handleBtnColor as any ).value ?.backgroundColor ?.startsWith (' #' ) || (handleBtnColor as any ).value ?.backgroundColor ?.startsWith (' #' ) || (handleBtnColor as any ).value ?.backgroundColor ?.startsWith (' rgb' );
129+ return typeof handleBtnColor .value == ' object'
130+ && (handleBtnColor as any ).value ?.backgroundColor ?.startsWith (' #' )
131+ || (handleBtnColor as any ).value ?.backgroundColor ?.startsWith (' rgb' );
135132})
136133
137134 </script >
0 commit comments