Browse Source

přidáno přepínání mezi dark/light theme

main
Ivan Pomykacz 6 months ago
parent
commit
84bc9f3209
  1. 6
      css/dark.css
  2. 2
      css/light.css
  3. 4
      header.php
  4. 7
      index.php
  5. 8
      paragraph.php
  6. 2
      test.php

6
css/dark.css

@ -0,0 +1,6 @@
body {
font-family: Arial, Helvetica, sans-serif;
color: #f5f5f5;
background-color: #555;
}

2
css/light.css

@ -1,4 +1,6 @@
body {
font-family: Arial, Helvetica, sans-serif;
color: #555;
background-color: whitesmoke;
}

4
header.php

@ -4,9 +4,9 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><?php echo "$title"; ?></title>
<link rel="stylesheet" href="css/light.css">
<link rel="stylesheet" href="css/<?php echo "$theme"; ?>.css">
<style>
body {
p.color {
color: <?php echo "$color"; ?>;
}
</style>

7
index.php

@ -9,6 +9,13 @@ if (isset($_GET["cc"])) {
$color = $_GET["cc"];
}
// změna theme stránky (dark/light)
$theme = "light";
if (isset($_GET["theme"])) {
// porušení pravidla - nikdy nepřiřazuj hodnotu přímo z GET (POST)
$theme = $_GET["theme"];
}
include "header.php";
include "test.php";

8
paragraph.php

@ -1,3 +1,7 @@
<p>
<p class="color">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Cupiditate labore illum possimus consectetur tempora ipsa eos necessitatibus! Dolores eius qui officia ipsam dolorem iure voluptatum voluptas ut. Quas, qui recusandae!
</p>
</p>
<p>
Necessitatibus illum animi ipsam pariatur, iure debitis commodi. Voluptatum illo officia, qui eum hic, ab rem culpa voluptatibus itaque earum deserunt doloremque?
</p>

2
test.php

@ -5,4 +5,6 @@
<a href="/?img=2">stránka s obrázkem 2</a>
<a href="/?img=333">stránka s chybnou hodnotou obrázku</a>
<a href="/?par=&cc=red">stránka s červeným textem</a>
<a href="/?par=&theme=dark">dark theme</a>
<a href="/?par=&theme=light">light theme</a>
</p>

Loading…
Cancel
Save