Skip to content

Commit

Permalink
refactor: add disabled prop to Link components
Browse files Browse the repository at this point in the history
  • Loading branch information
raphodn committed Aug 17, 2024
1 parent 5c3b8de commit aaef501
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 8 deletions.
10 changes: 7 additions & 3 deletions src/components/OpenFoodFactsLink.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<template>
<a v-if="display === 'link'" :href="getUrl" target="_blank">
<a v-if="display === 'link'" :href="getUrl" target="_blank" :disabled="disabled">
{{ getSourceName }}
</a>
<v-btn v-else-if="display === 'button'" size="small" :prepend-icon="getSourceIcon" append-icon="mdi-open-in-new" :href="getUrl" target="_blank">
<v-btn v-else-if="display === 'button'" size="small" :prepend-icon="getSourceIcon" append-icon="mdi-open-in-new" :href="getUrl" target="_blank" :disabled="disabled">
{{ getSourceName }}
</v-btn>
<v-list-item v-else-if="display === 'list-item'" :slim="true" :prepend-icon="getSourceIcon" append-icon="mdi-open-in-new" :href="getUrl" target="_blank">
<v-list-item v-else-if="display === 'list-item'" :slim="true" :prepend-icon="getSourceIcon" append-icon="mdi-open-in-new" :href="getUrl" target="_blank" :disabled="disabled">
{{ getSourceName }}
</v-list-item>
</template>
Expand Down Expand Up @@ -35,6 +35,10 @@ export default {
type: String,
default: 'link',
examples: ['link', 'button', 'list-item']
},
disabled: {
type: Boolean,
default: false
}
},
data() {
Expand Down
9 changes: 7 additions & 2 deletions src/components/PriceAddLink.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<a v-if="display === 'link'" :to="getAddUrl">
<a v-if="display === 'link'" :to="getAddUrl" :disabled="disabled">
{{ $t('Common.AddPrice') }}
</a>
<v-btn
Expand All @@ -8,10 +8,11 @@
color="primary"
prepend-icon="mdi-tag-plus-outline"
:to="getAddUrl"
:disabled="disabled"
>
{{ $t('Common.AddPrice') }}
</v-btn>
<v-list-item v-else-if="display === 'list-item'" :slim="true" base-color="primary" prepend-icon="mdi-tag-plus-outline" :to="getAddUrl">
<v-list-item v-else-if="display === 'list-item'" :slim="true" base-color="primary" prepend-icon="mdi-tag-plus-outline" :to="getAddUrl" :disabled="disabled">
{{ $t('Common.AddPrice') }}
</v-list-item>
</template>
Expand All @@ -37,6 +38,10 @@ export default {
default: 'link',
examples: ['link', 'button', 'list-item']
},
disabled: {
type: Boolean,
default: false
}
},
data() {
return {
Expand Down
10 changes: 8 additions & 2 deletions src/components/ShareLink.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<a v-if="display === 'link'" @click="shareViaWebShare">
<a v-if="display === 'link'" :disabled="disabled" @click="shareViaWebShare">
{{ $t('Common.Share') }}
</a>
<v-sheet v-else-if="display === 'button'">
Expand All @@ -11,6 +11,7 @@
color="teal"
icon="mdi-share-variant"
:title="$t('Common.Share')"
:disabled="disabled"
@click="shareViaWebShare"
/>
<v-btn
Expand All @@ -21,12 +22,13 @@
color="teal"
prepend-icon="mdi-share-variant"
:title="$t('Common.Share')"
:disabled="disabled"
@click="shareViaWebShare"
>
{{ $t('Common.Share') }}
</v-btn>
</v-sheet>
<v-list-item v-else-if="display === 'list-item'" :slim="true" base-color="teal" prepend-icon="mdi-share-variant" @click="shareViaWebShare">
<v-list-item v-else-if="display === 'list-item'" :slim="true" base-color="teal" prepend-icon="mdi-share-variant" :disabled="disabled" @click="shareViaWebShare">
{{ $t('Common.Share') }}
</v-list-item>

Expand All @@ -53,6 +55,10 @@ export default {
default: 'link',
examples: ['link', 'button', 'list-item']
},
disabled: {
type: Boolean,
default: false
}
},
data() {
return {
Expand Down
1 change: 0 additions & 1 deletion src/views/ProductDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

<v-row v-if="categoryFound" class="mt-0">
<v-col cols="12">
{{ category }}
<PriceAddLink v-if="category" class="mr-2" :productCode="category.name" display="button" />
</v-col>
</v-row>
Expand Down

0 comments on commit aaef501

Please sign in to comment.