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

use native CSS vars from exposer #2740

Merged
merged 2 commits into from
May 27, 2021
Merged

Conversation

Shogoki
Copy link
Contributor

@Shogoki Shogoki commented Jul 29, 2020

just created this change according to my request in #2739
This uses the already exposed CSS Variables in the theme template instead of the SASS vars. we´re still initializing the CSS Vars with the Values from SASS, so it should be compatible.

This allows us to easy overwrite theme vars without building a custom theme.

@Shogoki
Copy link
Contributor Author

Shogoki commented Jul 29, 2020

As an example how this could be used.

in Index.html

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <meta
      name="viewport"
      content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"
    />
    <title>reveal.js</title>
    <link rel="stylesheet" href="../dist/reset.css" />
    <link rel="stylesheet" href="../dist/reveal.css" />
    <link rel="stylesheet" href="../dist/theme/black.css" />
    <link rel="stylesheet" href="theme-customization.css" />

    <!-- Theme used for syntax highlighting of code -->
    <link rel="stylesheet" href="../plugin/highlight/monokai.css" />
  </head>
  <body>
    <div class="reveal">
      <div class="slides">
        <section
          data-markdown="slides.md"
          data-separator="^\n---\n$"
          data-separator-vertical="^\n\|\|\|\n$"
        ></section>
      </div>
    </div>

    <script type="module">
      import Reveal from "../dist/reveal.esm.js";
      import Markdown from "../plugin/markdown/markdown.esm.js";
      import Highlight from "../plugin/highlight/highlight.esm.js";
      import Notes from "../plugin/notes/notes.esm.js";
      import Math from "../plugin/math/math.esm.js";
      Reveal.initialize({
        plugins: [Markdown, Highlight, Notes, Math],
        math: {
          mathjax:
            "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js",
          config: "TeX-AMS_HTML-full",
        },
      });
    </script>
  </body>
</html>

with the following in theme-customization.css

:root {
    --background-color:  #ffffff;
    --main-color:  #000000;
    --heading-color: rgb(31, 2, 136);
    --main-font-size: 16pt;
}
.test {
    --heading-color: rgb(29, 153, 60);
}

overwriting the vars in :root I can customize my defaults, but can also super easy adjust it only for specific classes/slides like in the testclass which is can be quite handy.

Assuming a slides.md file with the following Content:

# Test Slide 1

some content

---

# Test Slide2
<!-- .slide:  data-state="test" -->
some other content

|||

# Horizontal Test-Slide

some content

@edemaine
Copy link

Any chance of this PR being revitalized and approved? I just wanted to change the font from a built-in theme, and this would make it really easy to do so.

Repository owner deleted a comment from Katy-kaboom101 May 27, 2021
@hakimel hakimel merged commit 83648bb into hakimel:master May 27, 2021
@hakimel
Copy link
Owner

hakimel commented May 27, 2021

This has been merged—thanks!

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.

None yet

4 participants