Skip to content

Move CSS to a @layer #2782

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

Closed
hesxenon opened this issue Nov 25, 2024 · 1 comment
Closed

Move CSS to a @layer #2782

hesxenon opened this issue Nov 25, 2024 · 1 comment
Milestone

Comments

@hesxenon
Copy link

Search Terms

css layer

Problem

Currently it's kinda "hard" to override styles in custom css, especially if you want to include your own libraries in typedoc.

Suggested Solution

wrapping all css declarations in a

@layer typedoc {
  /* typedoc styles */
}

so that consumers can do

@layer my-library, typedoc;

Current workaround

// plugin.js
export function load(
 /**
  * @type import("typedoc").Application
  */
  app
) {
  app.renderer.hooks.on("head.end", (ctx) =>
      JSX.createElement(JSX.Raw, {
        html: `<script async>document.head.querySelector('link[href*="style.css"]').remove()</script>`,
      }),
  );
}

with

/* custom.css */
@import url("style.css") layer(typedoc);
@layer my-library, typedoc;

and

{
  "$schema": "https://typedoc.org/schema.json",
  "customCss": "custom.css",
  "plugin": ["plugin.js"],
}
@Gerrit0
Copy link
Collaborator

Gerrit0 commented Nov 26, 2024

Easy enough of a change to do, TIL about @layer!

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