dify icon indicating copy to clipboard operation
dify copied to clipboard

FR: #4048 - Add color customization to the chatbot

Open dromerolovo opened this issue 1 year ago • 1 comments

FR: #4048 - Add color customization to the chatbot

The scope of this PR is to apply customization only to the chatbot.

  1. Add chatbot_color_theme and chatbot_color_theme_inverted to the SiteInfo
  2. Create an input on SettingsModal to set chatbot_color_theme and chatbot_color_theme_inverted
  3. Create the db migration to support thos properties
  4. Create a context and a Theme builder
  5. Apply dynamic styles to components that are part of the chatbot embedded such as: Header, Welcome, Question, etc.
  6. Override and add default values in case that the theme is not built, because many components are used in contexts outside the chatbot
  7. Override the style of the button.

Because Tailwind doesn't support dynamic classes because of its JIT functionality I had to include styles directly https://v2.tailwindcss.com/docs/just-in-time-mode#arbitrary-value-support. It would've been nice to keep it with classes, but I think that It can't be done that way.

Type of Change

Please delete options that are not relevant.

  • [ ] Bug fix (non-breaking change which fixes an issue)
  • [X] New feature (non-breaking change which adds functionality)
  • [X] Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • [X] This change requires a documentation update, included: Dify Document
  • [X] Improvement, including but not limited to code refactoring, performance optimization, and UI/UX improvement
  • [ ] Dependency upgrade

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • [X] I have performed a self-review of my own code
  • [X] I have commented my code, particularly in hard-to-understand areas
  • [X] My changes generate no new warnings
  • [X] I ran dev/reformat(backend) and cd web && npx lint-staged(frontend) to appease the lint gods (Kind of)
  • [ ] optional I have made corresponding changes to the documentation
  • [ ] optional I have added tests that prove my fix is effective or that my feature works
  • [ ] optional New and existing unit tests pass locally with my changes

I considered this change useful as stated in the Issue made previously:

How will this feature improve your workflow or experience? It will improve the experience of developers and designers that want to include the embedded chatbot into a website that have clear or strict design requirements.

I encounter some errors when running bash dev/pytest/pytest_all_tests.sh but I think that were unrelated to my changes. I'm open to make some changes if needed, this is kind of a draft PR.

If you guys feel that this is not the way that you want to go, you can always let it fade into oblivion.

dromerolovo avatar May 29 '24 07:05 dromerolovo

That's cool, I will take a look at this later.n :)

crazywoola avatar May 29 '24 07:05 crazywoola

Hi, @takatost . Just to avoid confusions , when you mention 'target branch,' are you referring to the base branch when doing a PR? If that's so, I'm going to close this, because it got a little bit messy and make a new PR to main branch. Thanks

dromerolovo avatar May 31 '24 22:05 dromerolovo