GH-1975 Theme Framework & GH-1972 Palm Theme #517
Conversation
benstrumeyer
commented
Mar 26, 2020
•
|
…z feature buttons
|
Still looking at the CSS stuff, but here are my other comments in the meantime. Lemme know if you have any questions! |
| @@ -330,6 +331,7 @@ class Blocking extends React.Component { | |||
| smartBlock={smartBlock} | |||
| unknownCategory={unknownCategory} | |||
| enable_anti_tracking={enable_anti_tracking} | |||
| current_theme={current_theme} | |||
wlycdgr
Mar 27, 2020
Member
This is a good use case for contexts, which allow you to make this kind of 'global' setting available to every component in the tree without manually passing the value down component by component. In fact, themes are the example used in the context React docs! - https://reactjs.org/docs/context.html
This is a good use case for contexts, which allow you to make this kind of 'global' setting available to every component in the tree without manually passing the value down component by component. In fact, themes are the example used in the context React docs! - https://reactjs.org/docs/context.html
benstrumeyer
Apr 6, 2020
Author
Contributor
Used context for the first time! It's soo clean
Used context for the first time! It's soo clean
| * @memberof PanelBuildingBlocks | ||
| */ | ||
|
|
||
| const RadioButton = (props) => { |
wlycdgr
Mar 27, 2020
Member
Destructure to clean up a lil
const { checked, handleClick } = props;, etc
Destructure to clean up a lil
const { checked, handleClick } = props;, etc
benstrumeyer
Mar 31, 2020
Author
Contributor
Destructured!
Destructured!
|
|
||
| // PropTypes ensure we pass required props of the correct type | ||
| RadioButton.propTypes = { | ||
| handleClick: PropTypes.func.isRequired, |
wlycdgr
Mar 27, 2020
Member
add checked
add checked
benstrumeyer
Mar 31, 2020
Author
Contributor
Added checked!
Added checked!
| * file, You can obtain one at http://mozilla.org/MPL/2.0 | ||
| */ | ||
|
|
||
| /* eslint jsx-a11y/label-has-associated-control: 0 */ |
wlycdgr
Mar 27, 2020
Member
Try to resolve this using the suggestions at https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/HEAD/docs/rules/label-has-associated-control.md if you haven't yet
Try to resolve this using the suggestions at https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/HEAD/docs/rules/label-has-associated-control.md if you haven't yet
benstrumeyer
Mar 31, 2020
Author
Contributor
Definitely will try to resolve those before resorting to eslint, I think I mistakenly put that here since there are no labels
Definitely will try to resolve those before resorting to eslint, I think I mistakenly put that here since there are no labels
| constructor(props) { | ||
| super(props); | ||
| this.state = { | ||
| buttons: [] |
wlycdgr
Mar 27, 2020
Member
buttons suggests that the items are button objects/components. Use a name that better reflects the nature of the (on/off bool) elements.
buttons suggests that the items are button objects/components. Use a name that better reflects the nature of the (on/off bool) elements.
benstrumeyer
Mar 31, 2020
•
Author
Contributor
Changed to buttonState! Actually, removed altogether per Ethan's comment:
It looks like this is the only place that you're using the local state in this component. You can instead just pass the props to the <RadioButton /> component like this:
const { indexClicked, handleItemClick } = this.props
// ...code in between...
<RadioButton
checked={index === indexClicked}
handleClick={() => handleItemClick(index)}
/>
Then, you can remove all of the code from componentDidMount and RadioButtonGroup.handleClick and not have to worry about local state.
Changed to buttonState! Actually, removed altogether per Ethan's comment:
It looks like this is the only place that you're using the local state in this component. You can instead just pass the props to the <RadioButton /> component like this:
const { indexClicked, handleItemClick } = this.props
// ...code in between...
<RadioButton
checked={index === indexClicked}
handleClick={() => handleItemClick(index)}
/>
Then, you can remove all of the code from componentDidMount and RadioButtonGroup.handleClick and not have to worry about local state.
| @@ -161,6 +161,15 @@ class StatsGraph extends React.Component { | |||
| .attrTween('stroke-dasharray', interpolator); | |||
| } | |||
|
|
|||
| function getThemeColor(theme) { | |||
wlycdgr
Mar 27, 2020
Member
Nice
Nice
| @@ -524,11 +524,12 @@ class Stats extends React.Component { | |||
| * @return {ReactComponent} StatsView instance | |||
| */ | |||
| render() { | |||
| const { user, loggedIn, current_theme } = this.props; | |||
wlycdgr
Mar 27, 2020
Member
👍
wlycdgr
Mar 27, 2020
Member
Let's do same for this.state while we're at it.
Let's do same for this.state while we're at it.
benstrumeyer
Mar 31, 2020
Author
Contributor
Destructured this.state as well
Destructured this.state as well
| text: 'subscription_default_theme', | ||
| }, | ||
| { | ||
| name: 'midnight-theme', |
wlycdgr
Mar 27, 2020
Member
Update to dark-blue-theme here too
Update to dark-blue-theme here too
wlycdgr
Mar 27, 2020
Member
And let's be consistent with the naming -default-theme, palm-theme, leaf-theme, etc
And let's be consistent with the naming -default-theme, palm-theme, leaf-theme, etc
benstrumeyer
Mar 31, 2020
Author
Contributor
Ah I wanted to do that. It's my understanding that these theme names rely on the account project for API calls and we don't want to update these for now, however we have a ticket in the backlog for it https://cliqztix.atlassian.net/browse/GH-1974
Ah I wanted to do that. It's my understanding that these theme names rely on the account project for API calls and we don't want to update these for now, however we have a ticket in the backlog for it https://cliqztix.atlassian.net/browse/GH-1974
|
|
||
| const handleThemeClick = (index) => { | ||
| const theme = themes[index]; | ||
| console.log('CLICK', index, themes, theme); |
wlycdgr
Mar 27, 2020
Member
Was gonna say remember to remove this but I guess this isn't getting merged so it doesn't matter! :)
Was gonna say remember to remove this but I guess this isn't getting merged so it doesn't matter! :)
benstrumeyer
Mar 31, 2020
Author
Contributor
Removed it anyway!
Removed it anyway!
|
|
||
| path { | ||
| fill: #FFF; | ||
| stroke: #FFF; |
wlycdgr
Mar 27, 2020
Member
Use $summary_text
Use $summary_text
wlycdgr
Mar 27, 2020
Member
(That's prob my bad from before!)
(That's prob my bad from before!)
benstrumeyer
Mar 31, 2020
Author
Contributor
Changed all text colors to $summary_text!
Changed all text colors to $summary_text!
| @@ -19,8 +19,9 @@ | |||
| right: 0; | |||
| bottom: 0; | |||
| left: 0; | |||
| z-index: 8000; | |||
wlycdgr
Mar 27, 2020
Member
Is this meant to be an "on top of everything else for sure" value? If so, use max int
Is this meant to be an "on top of everything else for sure" value? If so, use max int
benstrumeyer
Mar 31, 2020
Author
Contributor
Used max int!
Used max int!
| const now = Date.now(); | ||
| const { themeData } = conf.account; | ||
| let shouldGet = false; | ||
| if (!themeData || !themeData[name]) { | ||
| shouldGet = true; | ||
| } else { | ||
| const { timestamp } = themeData[name]; | ||
| shouldGet = (now - timestamp > 86400000); // true if 24hrs have passed | ||
| } | ||
| let css = ''; | ||
| if (shouldGet) { |
wlycdgr
Mar 27, 2020
Member
Factor the determination of whether we shouldGet out to a helper. this avoids using let and ensures that getTheme has a single responsibility that matches its name.
Factor the determination of whether we shouldGet out to a helper. this avoids using let and ensures that getTheme has a single responsibility that matches its name.
fcjr
Mar 27, 2020
Member
This function should not have to be changed in the real PR. I think these changes were just made for testing the themes locally, is that correct @benstrumeyer?
This function should not have to be changed in the real PR. I think these changes were just made for testing the themes locally, is that correct @benstrumeyer?
benstrumeyer
Mar 31, 2020
Author
Contributor
Ah yea, I should have let you know that this was re-added for testing purposes! My bad Ilya! This function is staying as is.
Ah yea, I should have let you know that this was re-added for testing purposes! My bad Ilya! This function is staying as is.
| @@ -555,7 +555,7 @@ export function fetchLocalJSONResource(url) { | |||
| */ | |||
| export function injectScript(tabId, scriptfile, cssfile, runAt) { | |||
| return new Promise((resolve, reject) => { | |||
| chrome.tabs.executeScript(tabId, { file: scriptfile, runAt }, () => { | |||
| chrome.tabs.executeScript(tabId || 0, { file: scriptfile, runAt }, () => { | |||
wlycdgr
Mar 27, 2020
Member
Is this to avoid an error if tabId is undefined? What happens if it is undefined and so we pass 0 but there is not tab with id 0?
Is this to avoid an error if tabId is undefined? What happens if it is undefined and so we pass 0 but there is not tab with id 0?
benstrumeyer
Mar 31, 2020
•
Author
Contributor
This was also added for testing purposes
This was also added for testing purposes
| @@ -0,0 +1,365 @@ | |||
| /** | |||
wlycdgr
Mar 27, 2020
Member
How comes this duplicates themes/theme.scss instead of also using it as the template in the manner of palm-theme.scss?
How comes this duplicates themes/theme.scss instead of also using it as the template in the manner of palm-theme.scss?
benstrumeyer
Mar 31, 2020
Author
Contributor
Good idea! I will do it after the LEAF theme if that's okay with you
Good idea! I will do it after the LEAF theme if that's okay with you
| $tracker-list: $green_dark; | ||
| $divider: $cyan_dark_desaturated; | ||
|
|
||
| @import './themes/theme.scss'; |
wlycdgr
Mar 27, 2020
Member
I am poking around to see if we can use the preferred @use directive instead (https://sass-lang.com/documentation/at-rules/use). It's not working yet but we should look into it some more....or have you already tried and it didn't work?
I am poking around to see if we can use the preferred @use directive instead (https://sass-lang.com/documentation/at-rules/use). It's not working yet but we should look into it some more....or have you already tried and it didn't work?
| default: | ||
| return '#124559'; | ||
| case 'palm-theme': | ||
| return '#172a0b'; | ||
| } |
fcjr
Mar 28, 2020
•
Member
Ignore my last comment, the early returns makes this work 😬 I'm dumb, but regardless, can you swap the order of these statements, switches read a bit clearer when the default case is the last one
Ignore my last comment, the early returns makes this work
benstrumeyer
Mar 31, 2020
Author
Contributor
Oh wow, I didn't know it worked like that. I'll always put default on the bottom then. Either way, good find
Oh wow, I didn't know it worked like that. I'll always put default on the bottom then. Either way, good find