chore: Replace darkmode mixin with useDarkMode composable [CW-3474] (#9949)
# Pull Request Template ## Description Replaces darkModeMixin with the new useDarkMode composable and replaces wll usages of mixin the the composable in components and pages Fixes https://linear.app/chatwoot/issue/CW-3474/rewrite-darkmodemixin-mixin-to-a-composable ## Type of change Please delete options that are not relevant. - [x] New feature (non-breaking change which adds functionality) --------- Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com> Co-authored-by: Sivin Varghese <64252451+iamsivin@users.noreply.github.com>
This commit is contained in:
@@ -1,13 +1,12 @@
|
||||
<script>
|
||||
import { useMessageFormatter } from 'shared/composables/useMessageFormatter';
|
||||
import FluentIcon from 'shared/components/FluentIcon/Index.vue';
|
||||
import darkModeMixin from 'widget/mixins/darkModeMixin.js';
|
||||
import { useDarkMode } from 'widget/composables/useDarkMode';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
FluentIcon,
|
||||
},
|
||||
mixins: [darkModeMixin],
|
||||
props: {
|
||||
items: {
|
||||
type: Array,
|
||||
@@ -16,9 +15,8 @@ export default {
|
||||
},
|
||||
setup() {
|
||||
const { truncateMessage } = useMessageFormatter();
|
||||
return {
|
||||
truncateMessage,
|
||||
};
|
||||
const { getThemeClass } = useDarkMode();
|
||||
return { getThemeClass, truncateMessage };
|
||||
},
|
||||
};
|
||||
</script>
|
||||
@@ -27,7 +25,7 @@ export default {
|
||||
<div
|
||||
v-if="!!items.length"
|
||||
class="chat-bubble agent"
|
||||
:class="$dm('bg-white', 'dark:bg-slate-700')"
|
||||
:class="getThemeClass('bg-white', 'dark:bg-slate-700')"
|
||||
>
|
||||
<div v-for="item in items" :key="item.link" class="article-item">
|
||||
<a :href="item.link" target="_blank" rel="noopener noreferrer nofollow">
|
||||
@@ -35,15 +33,16 @@ export default {
|
||||
<FluentIcon
|
||||
icon="link"
|
||||
class="mr-1"
|
||||
:class="$dm('text-black-900', 'dark:text-slate-50')"
|
||||
:class="getThemeClass('text-black-900', 'dark:text-slate-50')"
|
||||
/>
|
||||
<span :class="$dm('text-slate-900', 'dark:text-slate-50')">{{
|
||||
item.title
|
||||
}}</span>
|
||||
<span
|
||||
:class="getThemeClass('text-slate-900', 'dark:text-slate-50')"
|
||||
>{{ item.title }}</span
|
||||
>
|
||||
</span>
|
||||
<span
|
||||
class="description"
|
||||
:class="$dm('text-slate-700', 'dark:text-slate-200')"
|
||||
:class="getThemeClass('text-slate-700', 'dark:text-slate-200')"
|
||||
>
|
||||
{{ truncateMessage(item.description) }}
|
||||
</span>
|
||||
|
||||
@@ -6,14 +6,13 @@ import { getContrastingTextColor } from '@chatwoot/utils';
|
||||
|
||||
import FluentIcon from 'shared/components/FluentIcon/Index.vue';
|
||||
import Spinner from 'shared/components/Spinner.vue';
|
||||
import darkModeMixin from 'widget/mixins/darkModeMixin.js';
|
||||
import { useDarkMode } from 'widget/composables/useDarkMode';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
FluentIcon,
|
||||
Spinner,
|
||||
},
|
||||
mixins: [darkModeMixin],
|
||||
props: {
|
||||
messageId: {
|
||||
type: Number,
|
||||
@@ -25,7 +24,8 @@ export default {
|
||||
},
|
||||
},
|
||||
setup() {
|
||||
return { v$: useVuelidate() };
|
||||
const { getThemeClass } = useDarkMode();
|
||||
return { v$: useVuelidate(), getThemeClass };
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
@@ -47,9 +47,9 @@ export default {
|
||||
);
|
||||
},
|
||||
inputColor() {
|
||||
return `${this.$dm('bg-white', 'dark:bg-slate-600')}
|
||||
${this.$dm('text-black-900', 'dark:text-slate-50')}
|
||||
${this.$dm('border-black-200', 'dark:border-black-500')}`;
|
||||
return `${this.getThemeClass('bg-white', 'dark:bg-slate-600')}
|
||||
${this.getThemeClass('text-black-900', 'dark:text-slate-50')}
|
||||
${this.getThemeClass('border-black-200', 'dark:border-black-500')}`;
|
||||
},
|
||||
inputHasError() {
|
||||
return this.v$.email.$error
|
||||
|
||||
Reference in New Issue
Block a user