Skip to content

feat: Inject css styles into config viewer <head> #101

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jimmzzz
Copy link

@jimmzzz jimmzzz commented Jul 10, 2024

What does it solve?

issue: #86

Inject custom styles into <head>

This is useful in cases when you want inject css file with CSS variables and display them in tailwind-config-viewer

Alternative to themeReplacements

  • when you got variables defined in CSS file and not in JSON.
  • possible to define CSS variables for dark mode and display them when the user toggle mode in viewer

How does it work

  1. User define [name].css file in project
  2. add arguments -css <path to file.css> - default path is ./style.css
  3. App requests CSS file served on /style.css
  4. If file exists -> injected into <head>
  5. Colors and other properties are displayed correctly

example: tailwind-config-viewer -o -css ./css/my-variables.css

Caveats

  • for defining variables in dark mode they must have .mode-dark class name defined (class in viewer which is toggled in viewer) in custom css -> i didnt find any useful/versatile way how to handle this.

Possible future improvements:

  • link css files from external url

Feedback appreciated :)

@rogden
Copy link
Owner

rogden commented Nov 21, 2024

@jimmzzz Thanks for this PR. I'm in the process of a refactor to Vue 3 and removing / upgrading old dependencies. Once I'm through that I will dive into this. Thanks for your work!

@goodpixels
Copy link

Can we just merge it?

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

Successfully merging this pull request may close these issues.

3 participants