Files
chatwoot/app/javascript/shared/components/Branding.vue
Sivin Varghese 3a693947b5 feat: Add RTL Support to Widget (#11022)
This PR adds RTL support to the web widget for improved right-to-left language compatibility, updates colors, and cleans up code.

Fixes https://linear.app/chatwoot/issue/CW-4089/rtl-issues-on-widget

https://github.com/chatwoot/chatwoot/issues/9791

Other PR: https://github.com/chatwoot/chatwoot/pull/11016
2025-03-21 09:39:03 -07:00

70 lines
1.7 KiB
Vue

<script>
import globalConfigMixin from 'shared/mixins/globalConfigMixin';
const {
LOGO_THUMBNAIL: logoThumbnail,
BRAND_NAME: brandName,
WIDGET_BRAND_URL: widgetBrandURL,
} = window.globalConfig || {};
export default {
mixins: [globalConfigMixin],
props: {
disableBranding: {
type: Boolean,
default: false,
},
},
data() {
return {
globalConfig: {
brandName,
logoThumbnail,
widgetBrandURL,
},
};
},
computed: {
brandRedirectURL() {
try {
const referrerHost = this.$store.getters['appConfig/getReferrerHost'];
const baseURL = `${this.globalConfig.widgetBrandURL}?utm_source=${
referrerHost ? 'widget_branding' : 'survey_branding'
}`;
if (referrerHost) {
return `${baseURL}&utm_referrer=${referrerHost}`;
}
return baseURL;
} catch (e) {
// Suppressing the error as getter is not defined in some cases
}
return '';
},
},
};
</script>
<template>
<div
v-if="globalConfig.brandName && !disableBranding"
class="px-0 py-3 flex justify-center"
>
<a
:href="brandRedirectURL"
rel="noreferrer noopener nofollow"
target="_blank"
class="branding--link text-n-slate-11 hover:text-n-slate-12 cursor-pointer text-xs inline-flex grayscale-[1] hover:grayscale-0 hover:opacity-100 opacity-90 no-underline justify-center items-center leading-3"
>
<img
class="ltr:mr-1 rtl:ml-1 max-w-3 max-h-3"
:alt="globalConfig.brandName"
:src="globalConfig.logoThumbnail"
/>
<span>
{{ useInstallationName($t('POWERED_BY'), globalConfig.brandName) }}
</span>
</a>
</div>
<div v-else class="p-3" />
</template>