diff options
author | Thedro Neely <thedroneely@gmail.com> | 2019-04-18 02:07:33 -0400 |
---|---|---|
committer | Thedro Neely <thedroneely@gmail.com> | 2019-04-18 02:07:33 -0400 |
commit | 5452369c8c4af48254d331ed3bbe3f79c489e665 (patch) | |
tree | 3a8724e85b9e3e47f4bae1a8e7ed9ebe68a71246 /app | |
parent | 6e8bedd4551edaaa50b628d4648a7b7b95351309 (diff) | |
download | thedroneely.com-5452369c8c4af48254d331ed3bbe3f79c489e665.tar.gz thedroneely.com-5452369c8c4af48254d331ed3bbe3f79c489e665.tar.bz2 thedroneely.com-5452369c8c4af48254d331ed3bbe3f79c489e665.zip |
app/model/Theme: Add dark theme
Diffstat (limited to 'app')
-rw-r--r-- | app/model/Theme.php | 31 | ||||
-rw-r--r-- | app/views/partials/navigator.php | 87 | ||||
-rw-r--r-- | app/views/snippets/stylesheets.php | 4 |
3 files changed, 122 insertions, 0 deletions
diff --git a/app/model/Theme.php b/app/model/Theme.php new file mode 100644 index 0000000..36a4c6f --- /dev/null +++ b/app/model/Theme.php @@ -0,0 +1,31 @@ +<?php + +class Theme +{ + public function dark() + { + return $darkTheme = $_COOKIE['darkTheme'] ?? null; + } + + public function set($theme) + { + $time = time()+3600*24*365*10; + + if ($theme === null) { + setcookie('darkTheme', 'on', $time, '/'); + return $_COOKIE['darkTheme'] = 'on'; + } + + setcookie('darkTheme', null, $time, '/'); + return $_COOKIE['darkTheme'] = null; + } + + public function toggle() + { + $toggle = $_GET['toggle'] ?? null; + + if ($toggle === 'theme') { + $theme = $this->set($this->dark()); + } + } +} diff --git a/app/views/partials/navigator.php b/app/views/partials/navigator.php index 24f9794..6a9cc94 100644 --- a/app/views/partials/navigator.php +++ b/app/views/partials/navigator.php @@ -77,6 +77,50 @@ <div class="columns is-centered has-margin-bottom-none"> + <div class="navbar__left column"> + <a href="https://www.thedroneely.com/git/explore/repos" + class="brand__custom is-inline-block"> + <?php echo file_get_contents( + $_SERVER['DOCUMENT_ROOT'] + . '/..' . '/public/css/fonts/feather-icons/terminal.svg' + ) ?> + </a> + + <div class="navbar__separator is-inline-block"></div> + + <div class ="is-inline-block theme-toggle"> + <form method="get" action="<?php echo $_SERVER['REQUEST_URI']; ?>"> + <button class="theme-toggle-button button is-text" + name="toggle" type="submit" value="theme"> + + <?php if($theme->dark()) { ?> + + <span class="theme-toggle-sun"> + <?php echo file_get_contents( + $_SERVER['DOCUMENT_ROOT'] + . '/..' + . '/public/css/fonts/feather-icons/sun.svg' + ) ?> + </span> + + <?php } else { ?> + + <span class="theme-toggle-moon"> + <?php echo file_get_contents( + $_SERVER['DOCUMENT_ROOT'] + . '/..' + . '/public/css/fonts/feather-icons/moon.svg' + ) ?> + </span> + + <?php } ?> + + </button> + </form> + </div> + + </div> + <div class="navbar__left column is-2"> <?php require $_SERVER['DOCUMENT_ROOT'] . '/..' . '/app/views/partials/navigator.home.php'; ?> @@ -87,6 +131,18 @@ . '/..' . '/app/views/partials/navigator.links.php'; ?> </div> + <div class="navbar__right column"> + <a href ="https://ko-fi.com/thedroneely" + class="navbar-item coffee button is-success + is-outlined is-inline-flex"> + <?php echo file_get_contents( + $_SERVER['DOCUMENT_ROOT'] + . '/..' . '/public/css/fonts/feather-icons/coffee.svg' + ) ?> + <span>Coffee</span> + </a> + </div> + </div> </div> @@ -103,5 +159,36 @@ <?php require $_SERVER['DOCUMENT_ROOT'] . '/..' . '/app/views/partials/navigator.links.php'; ?> + <div class ="theme-toggle"> + <form method="get" action="<?php echo $_SERVER['REQUEST_URI']; ?>"> + <button class="theme-toggle-button button is-text has-text-centered is-block" + name="toggle" type="submit" value="theme"> + + <?php if ($theme->dark()) { ?> + + <span class="theme-toggle-sun"> + <?php echo file_get_contents( + $_SERVER['DOCUMENT_ROOT'] + . '/..' + . '/public/css/fonts/feather-icons/sun.svg' + ) ?> + </span> + + <?php } else { ?> + + <span class="theme-toggle-moon"> + <?php echo file_get_contents( + $_SERVER['DOCUMENT_ROOT'] + . '/..' + . '/public/css/fonts/feather-icons/moon.svg' + ) ?> + </span> + + <?php } ?> + + </button> + </form> + </div> + </div> </nav> diff --git a/app/views/snippets/stylesheets.php b/app/views/snippets/stylesheets.php index 9449c8a..45f9a27 100644 --- a/app/views/snippets/stylesheets.php +++ b/app/views/snippets/stylesheets.php @@ -1 +1,5 @@ <link rel="stylesheet" href="/css/tdro.css"> + +<?php if ($theme->dark()) { ?> +<link rel="stylesheet" href="/css/tdro-dark.css"> +<?php } ?> |