2020-03-12 15:53:52 +00:00
|
|
|
<template>
|
|
|
|
<a
|
|
|
|
v-if="isLink"
|
|
|
|
:key="action.uri"
|
|
|
|
class="action-button button"
|
|
|
|
:href="action.uri"
|
2022-11-02 00:22:00 +00:00
|
|
|
:style="{
|
|
|
|
background: widgetColor,
|
|
|
|
borderColor: widgetColor,
|
|
|
|
color: textColor,
|
|
|
|
}"
|
2020-04-10 11:12:37 +00:00
|
|
|
target="_blank"
|
|
|
|
rel="noopener nofollow noreferrer"
|
2020-03-12 15:53:52 +00:00
|
|
|
>
|
|
|
|
{{ action.text }}
|
|
|
|
</a>
|
|
|
|
<button
|
|
|
|
v-else
|
|
|
|
:key="action.payload"
|
|
|
|
class="action-button button"
|
2022-10-25 23:17:05 +00:00
|
|
|
:style="{ borderColor: widgetColor, color: widgetColor }"
|
2020-03-12 15:53:52 +00:00
|
|
|
@click="onClick"
|
|
|
|
>
|
|
|
|
{{ action.text }}
|
|
|
|
</button>
|
|
|
|
</template>
|
|
|
|
<script>
|
2022-10-25 23:17:05 +00:00
|
|
|
import { mapGetters } from 'vuex';
|
2022-11-02 00:22:00 +00:00
|
|
|
import { getContrastingTextColor } from '@chatwoot/utils';
|
2020-03-12 15:53:52 +00:00
|
|
|
export default {
|
|
|
|
components: {},
|
|
|
|
props: {
|
|
|
|
action: {
|
|
|
|
type: Object,
|
|
|
|
default: () => {},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
computed: {
|
2022-10-25 23:17:05 +00:00
|
|
|
...mapGetters({
|
|
|
|
widgetColor: 'appConfig/getWidgetColor',
|
|
|
|
}),
|
2022-11-02 00:22:00 +00:00
|
|
|
textColor() {
|
|
|
|
return getContrastingTextColor(this.widgetColor);
|
|
|
|
},
|
2020-03-12 15:53:52 +00:00
|
|
|
isLink() {
|
|
|
|
return this.action.type === 'link';
|
|
|
|
},
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
onClick() {
|
|
|
|
// Do postback here
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped lang="scss">
|
|
|
|
@import '~widget/assets/scss/variables.scss';
|
|
|
|
@import '~dashboard/assets/scss/mixins.scss';
|
|
|
|
|
|
|
|
.action-button {
|
2020-04-10 11:12:37 +00:00
|
|
|
align-items: center;
|
2020-03-12 15:53:52 +00:00
|
|
|
border-radius: $space-micro;
|
2020-04-10 11:12:37 +00:00
|
|
|
display: flex;
|
2020-03-12 15:53:52 +00:00
|
|
|
font-weight: $font-weight-medium;
|
2020-04-10 11:12:37 +00:00
|
|
|
justify-content: center;
|
|
|
|
margin-top: $space-smaller;
|
|
|
|
max-height: 34px;
|
|
|
|
padding: 0;
|
|
|
|
width: 100%;
|
2020-03-12 15:53:52 +00:00
|
|
|
}
|
|
|
|
</style>
|