Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Any idea how we can change new message color. It show as bold and i need change also color for clarify. #432

Closed
ataryandev opened this issue Feb 21, 2023 · 10 comments
Labels
enhancement New feature or request

Comments

@ataryandev
Copy link

Is your feature request related to a problem? Please describe

A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like

A clear and concise description of what you want to happen.

Describe alternatives you've considered

A clear and concise description of any alternative solutions or features you've considered.

Additional context

Add any other context or screenshots about the feature request here.

@ataryandev ataryandev added the enhancement New feature or request label Feb 21, 2023
@antoine92190
Copy link
Collaborator

antoine92190 commented Feb 22, 2023

You can override css using shadow DOM:

Shadow DOM
CSS classes cannot be simply overridden anymore. You can still use CSS variables, and if needed you can override CSS classes like this:

const style = document.createElement('style')
const styles = await import('./src/styles/theme.scss')
style.innerHTML = styles
this.$refs.chatWindow.shadowRoot.appendChild(style)

@antoine92190
Copy link
Collaborator

Closing this, please reopen if you still have an issue

@khanhzizu
Copy link

Closing this, please reopen if you still have an issue

Hi Antoine, can you show me where to write the code to edit the css? I write it in Created(), then console log "can not read properties of undefined (reading 'shadowRoot')"

@antoine92190
Copy link
Collaborator

Have you added chatWindow ref to the chat window component?
Please refer to the demo code, everything is there: https://github.com/antoine92190/vue-advanced-chat/blob/master/demo/src/ChatContainer.vue#L33

@khanhzizu
Copy link

Have you added chatWindow ref to the chat window component? Please refer to the demo code, everything is there: https://github.com/antoine92190/vue-advanced-chat/blob/master/demo/src/ChatContainer.vue#L33

It worked. Thank you very much

@ataryandev
Copy link
Author

ataryandev commented Apr 27, 2023

Here is my solution

Added into Component

class="chat-container__chat-window"

And Styles

------------------------------------
&__chat-window {
  :deep(.vac-message-new) {
        animation: new-message 1s infinite;
        font-size: 14px;
        font-weight: 700;
  
        @keyframes new-message {
          50% {
            color: #f00;
          }
        }
      }
}
-------------------------------------

@seyfer
Copy link

seyfer commented Jul 10, 2023

It worked for me as well, but since I use webpack and typescript, I was getting Module object on scss import instead of CSS text.

Solved by altering webpack import behavior.

// eslint-disable-next-line import/no-webpack-loader-syntax,import/no-named-default
import { default as ChatCss } from '!css-loader!sass-loader!./chat-shadow-dom.scss';

// have to alter webpack behavior to make it load text, not Module object
// @see https://stackoverflow.com/a/66539355/1074834

const ChatCssString = ChatCss.toString();

export default ChatCssString;

then use ChatCssString to add

 const addChatShadowDomCss = async () => {
    const style = document.createElement('style');
    style.innerHTML = ChatCssString;
    chatWindow.value.shadowRoot.appendChild(style);
  };

@reslear
Copy link
Contributor

reslear commented Jul 17, 2023

better solution #453 (comment)

@seyfer
Copy link

seyfer commented Jul 21, 2023

@reslear as to me it is not better, as I want my styles to be SCSS and loaded from a file

@elfaz2
Copy link

elfaz2 commented Apr 7, 2024

<script setup type="module">
const vacRef = ref(null)
const addCustomStyle = () => {
    if (!vacRef.value) return
    const style = document.createElement('style')
    style.textContent = '.vac-message-wrapper .vac-message-current{background: linear-gradient(90deg, #BD42BB 0%, #663E97 100%) !important; color: white} .vac-message-actions-wrapper .vac-options-me {background: transparent;}'
    vacRef.value.shadowRoot.appendChild(style)
}
onMounted(() => { addCustomStyle() });
</script>
<template>
<vue-advanced-chat
            ref="vacRef"/>
</template>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

6 participants