Skip to content

Commit

Permalink
updated: url flow
Browse files Browse the repository at this point in the history
  • Loading branch information
FelipeYslaoker committed Nov 13, 2024
1 parent 9ffc229 commit 66d8613
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
18 changes: 17 additions & 1 deletion components/Ly/FilledButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,27 @@ const props = withDefaults(
defineProps<{
disabled?: boolean | undefined;
loading?: boolean | undefined;
url?: string;
}>(),
{
theme: undefined,
disabled: false,
loading: false,
url: undefined,
},
);
const { openUrl } = useOpenUrl();
const emit = defineEmits(['click']);
function onClick() {
function onClick(event: MouseEvent) {
if (!props.disabled && !props.loading) {
emit('click');
}
if (props.url) {
event.preventDefault();
openUrl(props.url);
}
}
const isFocused = ref(false);
Expand All @@ -33,7 +40,12 @@ function handleBlur() {
</script>

<template>
<a v-if="url" :href="url" class="ly-filled-button" @click="onClick">
<LyCircularProgress v-if="loading" color="on-primary-color-border-top" />
<slot v-else />
</a>
<button
v-else
:class="['ly-filled-button']"
:disabled="disabled"
@click="onClick"
Expand All @@ -47,4 +59,8 @@ function handleBlur() {

<style scoped lang="scss">
@use '@/assets/scss/ui/buttons/LyFilledButton.scss';
a.ly-filled-button {
text-decoration: none;
}
</style>
9 changes: 2 additions & 7 deletions pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
definePageMeta({
layout: 'default',
});
const { openUrl } = useOpenUrl();
</script>

<template>
Expand All @@ -30,15 +28,12 @@ const { openUrl } = useOpenUrl();
class="d-flex justify-center mt-3 flex-col flex-md-row"
style="gap: 4px"
>
<LyFilledButton
class="width-md-45"
@click="openUrl('https://t.me/MusilyApp')"
>
<LyFilledButton class="width-md-45" url="https://t.me/MusilyApp">
Telegram Channel
</LyFilledButton>
<LyFilledButton
class="width-md-45"
@click="openUrl('https://github.com/MusilyApp')"
url="https://github.com/MusilyApp"
>
Github
</LyFilledButton>
Expand Down

0 comments on commit 66d8613

Please sign in to comment.