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

Adopt :where() selector for defining classes in built-in themes #244

Closed
Tracked by #247
yhatt opened this issue Jul 13, 2021 · 0 comments · Fixed by #264
Closed
Tracked by #247

Adopt :where() selector for defining classes in built-in themes #244

yhatt opened this issue Jul 13, 2021 · 0 comments · Fixed by #264

Comments

@yhatt
Copy link
Member

yhatt commented Jul 13, 2021

Let's consider the following example, covering invert color scheme class.

/* @theme example */

section {
  background: white;
  color: black;
}

section.invert {
  background: black;
  color: white;
}

If user thought to override colors through inline <style> in Markdown, a below Markdown will work correctly:

---
theme: example
---

<style>
section {
  background: yellow;
  color: red;
}
</style>

However, this overloading will not work if used the custom color scheme through class: invert. CSS specificity of section.invert (0-1-1) is higher than section (0-0-1) so its style is always overloaded.

---
theme: example
class: invert
---

<style>
/* Not working */
section {
  background: yellow;
  color: red;
}
</style>

This behavior may bring confusion of user who expected to overload styles.

By using :where() pseudo-selector to apply classes, built-in themes will allow simple overloading via section selector and reduce users stressful. :where() always has 0 specificity so styles in section:where(.invert) (0-0-1) can overload through section selector.

/* @theme example */

section {
  background: white;
  color: black;
}

section:where(.invert) {
  background: black;
  color: white;
}
@yhatt yhatt mentioned this issue Jul 19, 2021
6 tasks
@yhatt yhatt moved this to Todo in Marp Roadmap Oct 17, 2021
@yhatt yhatt moved this from Todo to In Progress in Marp Roadmap Nov 3, 2021
@yhatt yhatt moved this from In Progress to Done ✅ in Marp Roadmap Nov 3, 2021
@yhatt yhatt linked a pull request Nov 3, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant