-
Notifications
You must be signed in to change notification settings - Fork 42
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
Dark theme #239
Dark theme #239
Conversation
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.
Some cursory comments:
The side bar seems to stay in dark theme mode until you close and open it again.
(edit) both the sidebar and popup stay in dark mode until opened again - though will switch dynamically from light to dark
nit:
- there is a white flash on the sidebar when it is in dark mode.
run npm run lint
to find some code style fixes
addon/theming.js
Outdated
@@ -0,0 +1,111 @@ | |||
var updateBackground = function(el, color) { |
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.
use let
and const
instead of var
addon/popup.js
Outdated
handleThemes(isPopup = true); | ||
|
||
// // watch for switch to dark theme. | ||
// // BUG: No event transmitted when switching back to default |
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.
remove this comment, since we aren't using themes other than dark/light
Instead of using |
Regarding |
addon/theming.js
Outdated
(theme.colors.popup_highlight || "#ededf0") + "!important }"; | ||
let style = document.createElement("style"); | ||
|
||
if (style.styleSheet) { |
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.
does this ever evaluate to true?
addon/theming.js
Outdated
if (theme.colors) { | ||
let panel = document.getElementById("panel"); | ||
let tabs = document.getElementsByClassName("tab"); | ||
let feedback = document.getElementsByClassName("feedback-button")[0]; |
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.
document.querySelector('.feedback-button') will get you only the first element it finds with that selector
addon/theming.js
Outdated
}; | ||
|
||
function updateSidebarStyle() { | ||
if (theme.colors) { |
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.
can these styles be applied with css instead? select a parent element el.classList.add('dark-theme') then style all the children within it dark?
We talked about how the border and carat of the panel can only be changed with JS, but in all other cases css is better
The selection of what elements to dark theme is more specific than "all children of root" to avoid writing too many exceptions in the CSS. |
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.
Can the "Recent Tabs" and "Current Tabs" labels be a lighter color in dark mode?
Can you use variables in css, it doesn't look like they've been used yet, but might as well start them.
ex:
root {
--dark-theme-background-color: #6d6d6f;
}
addon/sidebar.js
Outdated
@@ -2,6 +2,25 @@ function element(selector) { | |||
return document.querySelector(selector); | |||
} | |||
|
|||
function applyDarkTheme() { | |||
document.body.style.background = "#4a4a4f"; | |||
document.body.style.color = "#fff"; |
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.
Do you know why this needs to be applied when the sidebar is triggered? I tried removing it and the popup styling was affected
} | ||
|
||
async function checkForDark() { | ||
browser.management.getAll().then((extensions) => { |
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.
I wish there was a better way to listen for this event that didn't require us to request more permissions...
addon/popup.css
Outdated
|
||
#panel.dark-theme, | ||
#panel.dark-theme .tab { | ||
background: #4a4a4f !important; |
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.
I think you can remove most, if not all, of the !important
addon/sidebar.css
Outdated
.page.dark-theme button:hover, | ||
.page.dark-theme button:focus, | ||
.page.dark-theme .graphic__shadow { | ||
background: #6d6d6f; |
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.
I like the effect on the shadow, but it creates a strange highlighter effect on the links.
addon/sidebar.js
Outdated
function applyDarkTheme() { | ||
document.body.style.background = "#4a4a4f"; | ||
document.body.style.color = "#fff"; | ||
document.querySelector(".page").classList.add("dark-theme"); |
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.
looks like there's already a utility function written above on this page for this, we should use it.
Is there anything with There's a possibility we could detect the theme using browser_style and getComputedStyle(). (Note that I don't know if browser_style even respects the dark theme, and I haven't tested any of this, it's just a hunch.) There's also a possibility that if we don't specify things browser_style already gives us, then the dark theme would magically be applied? (That seems unlikely to me.) |
|
It's ready! |
@htwyford This looks good, but it has some conflicts now. Can you resolve them? Thanks! |
although JS theming is required for the base of the popup. A listener is installed to update the sidebar on default -> dark changes.
Nice! |
Addresses #185. The onboarding in the sidebar and doorhanger now take on the dark theme if it's applied in Firefox.
One outstanding issue is that Firefox broadcasts a switch from the default to the dark theme, but not from the the dark theme to the default. This means the sidebar changes when the dark theme is applied but doesn't return to default without a browser restart. I figured this is a smallish edge case: a user would have to switch from default to dark while the onboarding window is open. This issue doesn't cause any breaking changes. Doesn't seem like it can be resolved until https://bugzilla.mozilla.org/show_bug.cgi?id=1435216 is addressed.
Alternatively, we could disable the listener. This would allow us to remove the
management
permission. The user would have to close and reopen the sidebar after switching to dark theme to see the changes.