Skip to content
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

GH-1975 Theme Framework & GH-1972 Palm Theme #517

Closed
wants to merge 22 commits into from
Closed

Conversation

@benstrumeyer
Copy link
Contributor

@benstrumeyer benstrumeyer commented Mar 26, 2020

  • Have you followed the guidelines in CONTRIBUTING.md?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?
  • Have you added an explanation of what your changes do?
  • Does your submission pass tests?
  • Did you lint your code prior to submission?
  • DO NOT MERGE
  • This PR is to receive feedback on the theme framework and styling of the palm theme only
  • Theme files are stored locally as opposed to on the Account project which we do not want. A new PR will be opened afterwards that passes the css correctly
@benstrumeyer benstrumeyer requested review from christophertino, wlycdgr, zarembsky and ghostery/ghostery as code owners Mar 26, 2020
Copy link
Member

@wlycdgr wlycdgr left a comment

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}

This comment has been minimized.

@wlycdgr

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 comment has been minimized.

@benstrumeyer

benstrumeyer Apr 6, 2020
Author Contributor

Used context for the first time! It's soo clean

* @memberof PanelBuildingBlocks
*/

const RadioButton = (props) => {

This comment has been minimized.

@wlycdgr

wlycdgr Mar 27, 2020
Member

Destructure to clean up a lil
const { checked, handleClick } = props;, etc

This comment has been minimized.

@benstrumeyer

benstrumeyer Mar 31, 2020
Author Contributor

Destructured!


// PropTypes ensure we pass required props of the correct type
RadioButton.propTypes = {
handleClick: PropTypes.func.isRequired,

This comment has been minimized.

@wlycdgr

wlycdgr Mar 27, 2020
Member

add checked

This comment has been minimized.

@benstrumeyer

benstrumeyer Mar 31, 2020
Author Contributor

Added checked!

* file, You can obtain one at http://mozilla.org/MPL/2.0
*/

/* eslint jsx-a11y/label-has-associated-control: 0 */

This comment has been minimized.

This comment has been minimized.

@benstrumeyer

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

constructor(props) {
super(props);
this.state = {
buttons: []

This comment has been minimized.

@wlycdgr

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.

This comment has been minimized.

@benstrumeyer

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.

@@ -161,6 +161,15 @@ class StatsGraph extends React.Component {
.attrTween('stroke-dasharray', interpolator);
}

function getThemeColor(theme) {

This comment has been minimized.

@wlycdgr

wlycdgr Mar 27, 2020
Member

Nice

@@ -524,11 +524,12 @@ class Stats extends React.Component {
* @return {ReactComponent} StatsView instance
*/
render() {
const { user, loggedIn, current_theme } = this.props;

This comment has been minimized.

This comment has been minimized.

@wlycdgr

wlycdgr Mar 27, 2020
Member

Let's do same for this.state while we're at it.

This comment has been minimized.

@benstrumeyer

benstrumeyer Mar 31, 2020
Author Contributor

Destructured this.state as well

text: 'subscription_default_theme',
},
{
name: 'midnight-theme',

This comment has been minimized.

@wlycdgr

wlycdgr Mar 27, 2020
Member

Update to dark-blue-theme here too

This comment has been minimized.

@wlycdgr

wlycdgr Mar 27, 2020
Member

And let's be consistent with the naming -default-theme, palm-theme, leaf-theme, etc

This comment has been minimized.

@benstrumeyer

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


const handleThemeClick = (index) => {
const theme = themes[index];
console.log('CLICK', index, themes, theme);

This comment has been minimized.

@wlycdgr

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! :)

This comment has been minimized.

@benstrumeyer

benstrumeyer Mar 31, 2020
Author Contributor

Removed it anyway!


path {
fill: #FFF;
stroke: #FFF;

This comment has been minimized.

@wlycdgr

wlycdgr Mar 27, 2020
Member

Use $summary_text

This comment has been minimized.

@wlycdgr

wlycdgr Mar 27, 2020
Member

(That's prob my bad from before!)

This comment has been minimized.

@benstrumeyer

benstrumeyer Mar 31, 2020
Author Contributor

Changed all text colors to $summary_text!

@@ -19,8 +19,9 @@
right: 0;
bottom: 0;
left: 0;
z-index: 8000;

This comment has been minimized.

@wlycdgr

wlycdgr Mar 27, 2020
Member

Is this meant to be an "on top of everything else for sure" value? If so, use max int

This comment has been minimized.

@benstrumeyer

benstrumeyer Mar 31, 2020
Author Contributor

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) {
Comment on lines +197 to +207

This comment has been minimized.

@wlycdgr

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.

This comment has been minimized.

@fcjr

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 comment has been minimized.

@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.

@@ -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 }, () => {

This comment has been minimized.

@wlycdgr

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?

This comment has been minimized.

@benstrumeyer

benstrumeyer Mar 31, 2020
Author Contributor

This was also added for testing purposes

@@ -0,0 +1,365 @@
/**

This comment has been minimized.

@wlycdgr

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?

This comment has been minimized.

@benstrumeyer

benstrumeyer Mar 31, 2020
Author Contributor

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';

This comment has been minimized.

@wlycdgr

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?

This comment has been minimized.

@benstrumeyer

benstrumeyer Mar 31, 2020
Author Contributor

Oh, I didn't even know @use existed. I tried replacing @import with @use inside the account project (where I moved this code) and it seems to work there!

@fcjr fcjr self-requested a review Mar 28, 2020
default:
return '#124559';
case 'palm-theme':
return '#172a0b';
}
Comment on lines +166 to +170

This comment has been minimized.

@fcjr

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

This comment has been minimized.

@benstrumeyer

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

@benstrumeyer benstrumeyer mentioned this pull request Mar 31, 2020
5 of 5 tasks complete
@benstrumeyer benstrumeyer deleted the palm-theme branch Apr 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants