Skip to content

Commit 7153200

Browse files
committed
feat: added dark styling for m-btn, minor clean up and refactoring of some names
1 parent ec5336b commit 7153200

File tree

4 files changed

+15
-15
lines changed

4 files changed

+15
-15
lines changed

vue-m-ui/src/components/m-btn/m-btn.vue

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,13 @@
2121
<script lang="ts" setup>
2222
import { ComputedRef, StyleValue, computed, ref, watch } from 'vue';
2323
import { dynamicSVG } from '@/utils';
24-
import { btnSizes, btnStyles, btnShapes, btnColors, createLighterShades } from './props';
24+
import { btnSizes, btnStyles, btnShapes, textColors, createLighterShades } from './props';
2525
2626
const mBtn = ref<HTMLButtonElement | null>(null);
2727
const shades = ref<string[]>([]);
2828
const customColorTest = ref<StyleValue>();
2929
const mousedown = ref(false);
3030
31-
watch(mousedown, () => {
32-
console.log('watch: ', mousedown.value);
33-
});
34-
3531
const btnProps = defineProps({
3632
text: {
3733
type: String,
@@ -78,7 +74,7 @@ const btnProps = defineProps({
7874
const 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
8480
const 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(() => {
129125
const 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>

vue-m-ui/src/components/m-btn/props.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export const btnStyles = {
77
warning: 'm-btn m-btn-warning',
88
info: 'm-btn m-btn-info',
99
light: 'm-btn m-btn-light',
10+
dark: 'm-btn m-btn-dark',
1011

1112
indigo: 'm-btn m-btn-indigo',
1213
purple: 'm-btn m-btn-purple',
@@ -30,7 +31,7 @@ export const btnShapes = {
3031
pill: 'm-btn-shape-pill',
3132
};
3233

33-
export const btnColors = {
34+
export const textColors = {
3435
default: '',
3536

3637
dark: 'm-text-dark',

vue-m-ui/src/style.css

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,13 @@
105105
}
106106

107107
.m-btn-dark {
108-
@apply m-text-light bg-neutral-800 hover:bg-gray-700 active:bg-gray-600;
109-
110-
background-color: rgb(30,32,35);
108+
@apply m-text-light bg-neutral-800 hover:bg-neutral-700 active:bg-neutral-600
109+
}
110+
.m-btn-dark:focus-visible {
111+
box-shadow: 0px 0px 0px white, 0px 0px 0px 1.5px rgb(38 38 38);
112+
outline-color: rgb(229 229 229);
111113
}
114+
112115
.m-btn-pink:focus-visible {
113116
box-shadow: 0px 0px 0px white, 0px 0px 0px 1.5px rgb(219 39 119);
114117
}
@@ -248,7 +251,7 @@
248251
@apply text-sky-400
249252
}
250253
.m-text-secondary {
251-
@apply text-[#f4f4f4]
254+
@apply text-[#bbbbbb]
252255
}
253256
.m-text-success {
254257
@apply text-emerald-300;

vue-m-ui/src/utils/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { defineAsyncComponent } from "vue";
22

3-
43
export function dynamicSVG(name: String) {
54
if (name)
65
return defineAsyncComponent(() => import(`@/icons/${name}.vue`));

0 commit comments

Comments
 (0)