Skip to content

Add dark mode support via prefers-color-scheme (closes #808) #838

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -243,3 +243,6 @@ Pull requests are welcome. Open a discussion for feedback, requesting features,

Special thanks to [Thomas](https://github.com/trgwii) and [Muthu](https://github.com/MKRhere). Logo design by [Muthu](https://github.com/MKRhere).

## Dark Mode Support
Kutt automatically switches between light/dark themes based on your system preference.
To customize colors, override CSS variables in `static/css/styles.css`.
105 changes: 105 additions & 0 deletions static/css/_variables.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
:root {
--bg-color: hsl(206, 12%, 95%);
--text-color: hsl(200, 35%, 25%);
--color-primary: hsl(207, 90%, 54%);
--outline-color: hsl(188, 100%, 54%);
--button-bg: linear-gradient(to right, #e0e0e0, #bdbdbd);
--button-bg-box-shadow-color: rgba(160, 160, 160, 0.5);
--button-bg-primary: linear-gradient(to right, hsl(207, 90%, 61%), hsl(218, 100%, 58%));
--button-bg-primary-box-shadow-color: hsla(207, 90%, 61%, 0.5);
--button-bg-secondary: linear-gradient(to right, hsl(262, 47%, 55%), hsl(265, 100%, 46%));
--button-bg-secondary-box-shadow-color: hsla(258, 58%, 42%, 0.5);
--button-bg-danger: linear-gradient(to right, hsl(0, 84%, 58%), hsl(0, 78%, 50%));
--button-bg-danger-box-shadow-color: hsla(0, 58%, 42%, 0.5);
--button-bg-success: linear-gradient(to right, hsl(130, 58%, 45%), hsl(130, 67%, 45%));
--button-bg-success-box-shadow-color: hsla(128, 80%, 48%, 0.5);
--button-action-shadow-color: hsla(200, 15%, 60%, 0.12);
--underline-color: hsl(200, 35%, 65%);
--secondary-text-color: hsl(200, 14%, 60%);
--send-icon-hover-color: hsl(262, 52%, 47%);
--send-spinner-icon-color: hsl(200, 15%, 70%);
--success-icon-color: hsl(144, 40%, 57%);
--error-icon-color: hsl(0, 86%, 63%);
--copy-icon-color: hsl(144, 40%, 57%);
--copy-icon-bg-color: hsl(144, 100%, 96%);
--copy-icon-shadow-color: hsla(200, 15%, 60%, 0.12);
--focus-outline-color: hsla(207, 90%, 61%, 0.5);
--checkbox-bg-color: hsl(262, 47%, 63%);
--input-shadow-color: hsla(200, 15%, 70%, 0.2);
--input-hover-shadow-color: hsla(200, 15%, 70%, 0.4);
--input-label-color: hsl(200, 35%, 25%);
--table-bg-color: hsl(200, 12%, 95%);
--table-shadow-color: hsla(200, 20%, 70%, 0.3);
--table-tr-border-color: hsl(200, 14%, 94%);
--table-tr-hover-bg-color: hsl(200, 14%, 98%);
--table-head-tr-border-color: hsl(200, 14%, 90%);
--table-status-gray-bg-color: hsl(200, 12%, 95%);
--keyframe-slidey-offset: 0;
}

/* Dark theme */
@media (prefers-color-scheme: dark) {
:root {
--bg-color: #101827;
--text-color: #f8fafc;
--color-primary: hsl(207, 90%, 61%);
--outline-color: hsl(207, 90%, 54%);
--button-bg: linear-gradient(to right, #2d3748, #4a5568);
--button-bg-box-shadow-color: rgba(45, 55, 72, 0.5);
--button-bg-primary: linear-gradient(to right, hsl(207, 90%, 48%), hsl(218, 90%, 40%));
--button-bg-primary-box-shadow-color: hsla(207, 90%, 48%, 0.5);
--button-bg-secondary: linear-gradient(to right, hsl(262, 47%, 45%), hsl(265, 100%, 40%));
--button-bg-secondary-box-shadow-color: hsla(258, 58%, 32%, 0.5);
--button-bg-danger: linear-gradient(to right, hsl(0, 84%, 48%), hsl(0, 78%, 40%));
--button-bg-danger-box-shadow-color: hsla(0, 58%, 32%, 0.5);
--button-bg-success: linear-gradient(to right, hsl(130, 58%, 35%), hsl(130, 67%, 35%));
--button-bg-success-box-shadow-color: hsla(128, 80%, 38%, 0.5);
--button-action-shadow-color: hsla(200, 15%, 30%, 0.12);
--underline-color: hsl(200, 35%, 40%);
--secondary-text-color: hsl(200, 14%, 50%);
--send-icon-hover-color: hsl(262, 52%, 37%);
--send-spinner-icon-color: hsl(200, 15%, 50%);
--success-icon-color: hsl(144, 40%, 47%);
--error-icon-color: hsl(0, 86%, 53%);
--copy-icon-color: hsl(144, 40%, 47%);
--copy-icon-bg-color: hsl(144, 100%, 86%);
--copy-icon-shadow-color: hsla(200, 15%, 30%, 0.12);
--focus-outline-color: hsla(207, 90%, 48%, 0.5);
--checkbox-bg-color: hsl(262, 47%, 53%);
--input-shadow-color: hsla(219.13, 41.82%, 10.78%, 1);
--input-hover-shadow-color: hsla(200, 15%, 50%, 0.4);
--input-label-color: #f8fafc;
--table-bg-color: #1F2937;
--table-shadow-color: hsla(200, 20%, 40%, 0.3);
--table-tr-border-color: #374151;
--table-tr-hover-bg-color: #27303f;
--table-tr-bg-color: #27303f;
--table-head-tr-border-color: #2d3748;
--table-status-gray-bg-color: #1F2937;
--stats-bg: #19212d;
--hr-color: hsl(217.25, 85.85%, 58.43%);
--button-bg-color: hsl(217.25, 85.85%, 58.43%);
--button-bg-hover-color: hsl(217.25, 85.85%, 50%);
--button-text-color: #ffffff;
}

/* Fix inconsistent input field styles */
input[type="text"],
input[type="email"],
input[type="password"] {
background-color: rgb(38, 47, 62);
border: 1px solid #374151;
color: var(--text-color);
padding: 8px;
border-radius: 5px;
transition: all 0.3s ease-in-out;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus {
border-color: var(--outline-color);
box-shadow: 0 0 8px var(--input-hover-shadow-color);
outline: none;
}
}
54 changes: 11 additions & 43 deletions static/css/styles.css
Original file line number Diff line number Diff line change
@@ -1,49 +1,16 @@
@import "_variables.css";

* {
transition: background-color 0.3s ease, color 0.3s ease;
}

@font-face {
font-family: 'Nunito';
font-style: normal;
font-weight: 200 1000;
src: url(/fonts/nunito-variable.woff2) format('woff2');
}

:root {
--bg-color: hsl(206, 12%, 95%);
--text-color: hsl(200, 35%, 25%);
--color-primary: hsl(207, 90%, 54%);
--outline-color: hsl(188, 100%, 54%);
--button-bg: linear-gradient(to right, #e0e0e0, #bdbdbd);
--button-bg-box-shadow-color: rgba(160, 160, 160, 0.5);
--button-bg-primary: linear-gradient(to right, hsl(207, 90%, 61%), hsl(218, 100%, 58%));
--button-bg-primary-box-shadow-color: hsla(207, 90%, 61%, 0.5);
--button-bg-secondary: linear-gradient(to right, hsl(262, 47%, 55%), hsl(265, 100%, 46%));
--button-bg-secondary-box-shadow-color: hsla(258, 58%, 42%, 0.5);
--button-bg-danger: linear-gradient(to right, hsl(0, 84%, 58%), hsl(0, 78%, 50%));
--button-bg-danger-box-shadow-color: hsla(0, 58%, 42%, 0.5);
--button-bg-success: linear-gradient(to right, hsl(130, 58%, 45%), hsl(130, 67%, 45%));
--button-bg-success-box-shadow-color: hsla(128, 80%, 48%, 0.5);
--button-action-shadow-color: hsla(200, 15%, 60%, 0.12);
--underline-color: hsl(200, 35%, 65%);
--secondary-text-color: hsl(200, 14%, 60%);
--send-icon-hover-color: hsl(262, 52%, 47%);
--send-spinner-icon-color: hsl(200, 15%, 70%);
--success-icon-color: hsl(144, 40%, 57%);
--error-icon-color: hsl(0, 86%, 63%);
--copy-icon-color: hsl(144, 40%, 57%);
--copy-icon-bg-color: hsl(144, 100%, 96%);
--copy-icon-shadow-color: hsla(200, 15%, 60%, 0.12);
--focus-outline-color: hsla(207, 90%, 61%, 0.5);
--checkbox-bg-color: hsl(262, 47%, 63%);
--input-shadow-color: hsla(200, 15%, 70%, 0.2);
--input-hover-shadow-color: hsla(200, 15%, 70%, 0.4);
--input-label-color: hsl(200, 35%, 25%);
--table-bg-color: hsl(200, 12%, 95%);
--table-shadow-color: hsla(200, 20%, 70%, 0.3);
--table-tr-border-color: hsl(200, 14%, 94%);
--table-tr-hover-bg-color: hsl(200, 14%, 98%);
--table-head-tr-border-color: hsl(200, 14%, 90%);
--table-status-gray-bg-color: hsl(200, 12%, 95%);
--keyframe-slidey-offset: 0;
}

/* ANIMATIONS */
@keyframes spin {
from { transform: rotate(0deg); }
Expand Down Expand Up @@ -151,7 +118,7 @@ button {
text-align: center;
line-height: 1;
word-break: keep-all;
color: #444;
color: var(--button-text-color);
border: none;
border-radius: 100px;
transition: all 0.4s ease-out;
Expand Down Expand Up @@ -337,7 +304,7 @@ button.nav {
border-radius: 4px;
box-shadow: 0 0px 10px rgba(100, 100, 100, 0.1);
background: none;
background-color: white;
background-color: var(--button-nav-bg);
transition: all 0.2s ease-in-out;
font-size: 12px;
cursor: pointer;
Expand Down Expand Up @@ -618,7 +585,8 @@ table {
width: 100%;
display: flex;
flex-direction: column;
background-color: white;
background-color: var(--table-bg-color);
border: 1px solid var(--table-border-color);
border-radius: 12px;
box-shadow: 0 6px 15px var(--table-shadow-color);
text-align: center;
Expand Down Expand Up @@ -772,7 +740,7 @@ table .tab a:not(.active):hover {
align-items: center;
text-align: center;
padding: 3rem 2rem;
background-color: white;
background-color: var(--dialog-bg-color);
border-radius: 8px;
--keyframe-slidey-offset: -30px;
animation: slidey 0.2s ease-in-out;
Expand Down