-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extracted Button element and fix button hover issue on mobile devices. (
#12)
- Loading branch information
1 parent
dc8815a
commit 0092106
Showing
5 changed files
with
126 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<script setup lang="ts"> | ||
import { inject, ref } from 'vue' | ||
import Ripple from '@/components/Ripple.vue' | ||
withDefaults(defineProps<{ enabled?: boolean; primary?: boolean }>(), { | ||
enabled: true, | ||
primary: false | ||
}) | ||
defineEmits(['click']) | ||
const isMobile = inject<boolean>('isMobile') as boolean | ||
const root = ref<HTMLElement | null>(null) | ||
function focus() { | ||
root.value?.focus() | ||
} | ||
defineExpose({ | ||
focus | ||
}) | ||
</script> | ||
|
||
<template> | ||
<button | ||
ref="root" | ||
v-if="enabled" | ||
@click="$emit('click')" | ||
type="button" | ||
tabindex="-1" | ||
:class="[ | ||
primary | ||
? 'border-primary-600 bg-primary-500 text-white' | ||
: 'dark:border-gray-950 border-primary-400 dark:text-primary-dark-100 dark:bg-primary-dark-600 dark:hover:bg-gray-700', | ||
{ 'hover:bg-primary-600 hover:shadow-lg': !isMobile && primary }, | ||
{ 'hover:bg-gray-200 hover:shadow-lg': !isMobile && !primary } | ||
]" | ||
class="relative flex focus:ring-1 ring-indigo-600 dark:ring-gray-600 items-center overflow-hidden rounded border px-4 py-2 transition duration-200 ease-linear" | ||
> | ||
<Ripple></Ripple> | ||
<slot name="default" class="block"></slot> | ||
<slot name="shortcut"></slot> | ||
</button> | ||
<button | ||
v-else | ||
type="button" | ||
class="relative flex cursor-not-allowed items-center overflow-hidden rounded border border-gray-600 bg-gray-500 px-4 py-2 text-white" | ||
> | ||
<span class="block"> | ||
<slot name="default"></slot> | ||
</span> | ||
</button> | ||
</template> | ||
|
||
<style scoped></style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters