summaryrefslogtreecommitdiffstats
path: root/docs/theme/ThemeSwitch.jinja
blob: 3543b73dda99c266f45adb5a4fdebdfbdef2affb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
{#def text=true #}

<button {{ attrs.render(
  class="cd-theme-switch",
  data_component="ThemeSwitch",
  title="Toggle light & dark mode",
  aria_label="auto",
  aria_live="polite",
) }}>
  <svg
    class="sun-and-moon"
    aria-hidden="true"
    stroke-linecap="round"
    viewBox="0 0 24 24"
  >
    <circle class="sun" cx="12" cy="12" r="6" mask="url(#moon-mask)"></circle>
    <g class="sun-beams">
      <line x1="12" y1="1" x2="12" y2="3" />
      <line x1="12" y1="21" x2="12" y2="23" />
      <line x1="4.22" y1="4.22" x2="5.64" y2="5.64" />
      <line x1="18.36" y1="18.36" x2="19.78" y2="19.78" />
      <line x1="1" y1="12" x2="3" y2="12" />
      <line x1="21" y1="12" x2="23" y2="12" />
      <line x1="4.22" y1="19.78" x2="5.64" y2="18.36" />
      <line x1="18.36" y1="5.64" x2="19.78" y2="4.22" />
    </g>
    <mask class="moon" id="moon-mask">
      <rect x="0" y="0" width="100%" height="100%" fill="white" />
      <circle cx="24" cy="10" r="6"></circle>
    </mask>
  </svg>
  {% if text -%}
  <span class="light-text">Light</span>
  <span class="dark-text">Dark</span>
  {%- endif %}
</button>