-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
light/darkMode #154
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
base: master
Are you sure you want to change the base?
light/darkMode #154
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,16 +1,49 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import React from 'react'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import React, { useState, useEffect } from 'react'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import Chat from './components/Chat/Chat'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import Join from './components/Join/Join'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { BrowserRouter as Router, Route } from "react-router-dom"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import './theme.css'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const App = () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const [theme, setTheme] = useState('dark'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| useEffect(() => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| document.documentElement.setAttribute('data-theme', theme); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, [theme]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const toggleTheme = () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| setTheme(theme === 'dark' ? 'light' : 'dark'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Router> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Route path="/" exact component={Join} /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Route path="/chat" component={Chat} /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </Router> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <button | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| onClick={toggleTheme} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| style={{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| position: 'fixed', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| top: 10, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| right: 10, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| zIndex: 1000, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| padding: '8px 16px', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| borderRadius: '5px', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| border: 'none', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| background: 'var(--primary-color)', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| color: 'var(--text-color)', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cursor: 'pointer', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| aria-label="Toggle theme" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| > | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Switch to {theme === 'dark' ? 'Light' : 'Dark'} Mode | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </button> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+24
to
+41
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Fix toggle button contrast and improve accessibility. Use the new Apply this diff: <button
onClick={toggleTheme}
+ type="button"
style={{
position: 'fixed',
top: 10,
right: 10,
zIndex: 1000,
padding: '8px 16px',
borderRadius: '5px',
border: 'none',
background: 'var(--primary-color)',
- color: 'var(--text-color)',
+ color: 'var(--on-primary-color)',
cursor: 'pointer',
}}
aria-label="Toggle theme"
+ aria-pressed={theme === 'dark'}
>Optional: move these inline styles into a CSS class to keep styling centralized with the rest of the theming. 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Router> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Route path="/" exact component={Join} /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Route path="/chat" component={Chat} /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </Router> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,6 +1,6 @@ | ||||||||||||||||||||||||
| .form { | ||||||||||||||||||||||||
| display: flex; | ||||||||||||||||||||||||
| border-top: 2px solid #D3D3D3; | ||||||||||||||||||||||||
| border-top: 2px solid var(--primary-color); | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| .input { | ||||||||||||||||||||||||
|
|
@@ -9,17 +9,19 @@ | |||||||||||||||||||||||
| padding: 5%; | ||||||||||||||||||||||||
| width: 80%; | ||||||||||||||||||||||||
| font-size: 1.2em; | ||||||||||||||||||||||||
| background: var(--secondary-color); | ||||||||||||||||||||||||
| color: var(--text-color); | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| input:focus, textarea:focus, select:focus{ | ||||||||||||||||||||||||
| outline: none; | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| .sendButton { | ||||||||||||||||||||||||
| color: #fff !important; | ||||||||||||||||||||||||
| color: var(--text-color) !important; | ||||||||||||||||||||||||
| text-transform: uppercase; | ||||||||||||||||||||||||
| text-decoration: none; | ||||||||||||||||||||||||
| background: #2979FF; | ||||||||||||||||||||||||
| background: var(--primary-color); | ||||||||||||||||||||||||
| padding: 20px; | ||||||||||||||||||||||||
|
Comment on lines
+21
to
25
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix contrast for primary buttons (text on primary).
Apply this diff here (paired with adding - color: var(--text-color) !important;
+ color: var(--on-primary-color) !important;📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||
| display: inline-block; | ||||||||||||||||||||||||
| border: none; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,7 +18,7 @@ html, body { | |
| text-align: center; | ||
| height: 100vh; | ||
| align-items: center; | ||
| background-color: #1A1A1D; | ||
| background: var(--background-color); | ||
| } | ||
|
|
||
| .joinInnerContainer { | ||
|
|
@@ -29,25 +29,27 @@ html, body { | |
| border-radius: 0; | ||
| padding: 15px 20px; | ||
| width: 100%; | ||
| background: var(--secondary-color); | ||
| color: var(--text-color); | ||
| } | ||
|
|
||
| .heading { | ||
| color: white; | ||
| color: var(--text-color); | ||
| font-size: 2.5em; | ||
| padding-bottom: 10px; | ||
| border-bottom: 2px solid white; | ||
| border-bottom: 2px solid var(--text-color); | ||
| } | ||
|
|
||
| .button { | ||
| color: #fff !important; | ||
| text-transform: uppercase; | ||
| text-decoration: none; | ||
| background: #2979FF; | ||
| padding: 20px; | ||
| border-radius: 5px; | ||
| display: inline-block; | ||
| border: none; | ||
| width: 100%; | ||
| color: var(--text-color) !important; | ||
| text-transform: uppercase; | ||
| text-decoration: none; | ||
| background: var(--primary-color); | ||
| padding: 20px; | ||
| border-radius: 5px; | ||
| display: inline-block; | ||
| border: none; | ||
| width: 100%; | ||
|
Comment on lines
+44
to
+52
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix button text contrast on primary background. Like the Input send button, this is likely to fail contrast in light mode. Apply this diff (paired with - color: var(--text-color) !important;
+ color: var(--on-primary-color) !important;Optional: add a visible focus style to retain keyboard accessibility (outline is removed later in the file). You can add the following rule elsewhere: .button:focus-visible {
outline: 3px solid var(--on-primary-color);
outline-offset: 2px;
}🤖 Prompt for AI Agents |
||
| } | ||
|
|
||
| .mt-20 { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,4 +2,5 @@ | |
| padding: 5% 0; | ||
| overflow: auto; | ||
| flex: auto; | ||
| background: var(--secondary-color); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| /* Theme variables */ | ||
| :root { | ||
| --background-color: #fff; | ||
| --text-color: #222; | ||
| --primary-color: #2979FF; | ||
| --secondary-color: #f3f3f3; | ||
| } | ||
|
Comment on lines
+2
to
+7
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add an “on-primary” token to guarantee readable text on primary backgrounds. Buttons and CTAs use Apply these diffs: :root {
--background-color: #fff;
--text-color: #222;
--primary-color: #2979FF;
--secondary-color: #f3f3f3;
+ --on-primary-color: #fff;
} [data-theme="dark"] {
--background-color: #1a1a1a;
--text-color: #fff;
--primary-color: #2979FF;
--secondary-color: #23272a;
+ --on-primary-color: #fff;
}Also applies to: 9-14 🤖 Prompt for AI Agents |
||
|
|
||
| [data-theme="dark"] { | ||
| --background-color: #1a1a1a; | ||
| --text-color: #fff; | ||
| --primary-color: #2979FF; | ||
| --secondary-color: #23272a; | ||
| } | ||
|
|
||
| body { | ||
| background: var(--background-color); | ||
| color: var(--text-color); | ||
| transition: background 0.3s, color 0.3s; | ||
| } | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Persist theme to localStorage and initialize from saved or system preference.
PR summary claims persistence, but it’s not implemented. Also set the attribute and save in one effect to avoid drift.
Apply this diff:
Add this helper above
const App = () => {:🤖 Prompt for AI Agents