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

Custom CSS replaces existing one instead of enhancing it. #67

Closed
genmeblog opened this issue Feb 1, 2022 · 3 comments
Closed

Custom CSS replaces existing one instead of enhancing it. #67

genmeblog opened this issue Feb 1, 2022 · 3 comments

Comments

@genmeblog
Copy link

genmeblog commented Feb 1, 2022

Calling below:

(swap! config/!resource->url assoc "/css/viewer.css" "notebooks/custom.css")

works as (probably) intended. However I don't think anyone wishes to build complete CSS for Clerk from the scratch. I think typical use case would be just to add/replace some (small) CSS subset. A couple of classes/ids.

What do you think?

@mk
Copy link
Member

mk commented Feb 2, 2022

Actually, replacing the full stylesheet is actually the intended usage. Clerk currently uses tailwind 3's play cdn. This is a javascript script that generates the used classes on-demand (using a mutation observer on the dom). This is primarily intended as a dev affordance.

When publishing in production, tailwind recommends to compile a custom stylesheet containing only the used classes. So we have this abstraction as a way for a user to override the stylesheet, compile it with a different tailwind config or user-appended styles (that can again include the viewer.css) but after going down that road we realized we don't want to be in the business of running a css pipeline for folks.

Also note that you can add inline styles using the html viewer like so:

^{:nextjournal.clerk/visibility :hide-ns}
(ns style-tag
  (:require [nextjournal.clerk :as clerk]))

^{::clerk/viewer :html ::clerk/visibility :hide}
[:style ".my-custom-class { color: blue; background-color: red; border-radius: 5px;}"]

(clerk/html [:div.my-custom-class.p-2 [:h1 "Hello 👋"]])

Screen Shot 2022-02-02 at 10 22 00

Please let me know if that works for you.

@genmeblog
Copy link
Author

Thank you, above solution sounds as a reasonable one. I think this is exactly what I need (inline CSS for a couple of custom classes). Need to try that still (be back soon with conclusions).

@genmeblog
Copy link
Author

Works!

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

No branches or pull requests

2 participants