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

Duplicate for Testing — GH-1975 Theme Framework, Leaf & Palm Themes #523

Closed
wants to merge 47 commits into from

Conversation

@benstrumeyer
Copy link
Contributor

@benstrumeyer benstrumeyer commented Apr 6, 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
  • #510 still has to be merged into this branch
  • Once accepted, I will merge this branch into feature/palm-theme and we can merge that one into develop
benstrumeyer and others added 30 commits Mar 11, 2020
@Eden12345 Eden12345 changed the title (Duplicate for Testing — DO NOT MERGE) GH-1975 Theme Framework, Leaf & Palm Themes Duplicate for Testing (Do Not Merge) GH-1975 Theme Framework, Leaf & Palm Themes Apr 7, 2020
@Eden12345 Eden12345 changed the title Duplicate for Testing (Do Not Merge) GH-1975 Theme Framework, Leaf & Palm Themes Duplicate for Testing — GH-1975 Theme Framework, Leaf & Palm Themes Apr 7, 2020
let protectedColor;
let allowedColor;
let restrictedColor;
switch (contextType) {
case 'palm-theme':
protectedColor = '#87f0fb';
allowedColor = '#b8e986';
restrictedColor = '#ff7e74';
break;
case 'leaf-theme':
protectedColor = '#2e3b80';
allowedColor = '#326c45';
restrictedColor = '#963939';
break;
default:
protectedColor = '#00AEF0';
allowedColor = '#96c761';
restrictedColor = '#00AEF0';
break;
}

Comment on lines 64 to 84

This comment has been minimized.

@wlycdgr

wlycdgr Apr 8, 2020
Member

I like inlining the SVGs, as per my other comment, but would it be better to set these attributes through CSS, so that there is a CSS file that is the single source of truth for all the styling values for any given theme? This does have the advantage of being a bit simpler and more direct than the CSS way, so I'm not sure. @Eden12345 - thoughts?

This comment has been minimized.

@Eden12345

Eden12345 Apr 8, 2020
Contributor

I think the CSS files should be the single source of truth, as you're saying. Since we're already using inline SVGs, it won't be too difficult to move these colors to a CSS file.

This comment has been minimized.

@benstrumeyer

benstrumeyer Apr 10, 2020
Author Contributor

The CSS is now the single source of truth!

@christophertino christophertino added this to the 8.5.0 milestone Apr 9, 2020
@benstrumeyer benstrumeyer requested review from wlycdgr and Eden12345 Apr 13, 2020
app/panel/components/Blocking/Category.jsx Outdated Show resolved Hide resolved
app/panel/components/Blocking/Category.jsx Outdated Show resolved Hide resolved
app/panel/components/Blocking/Category.jsx Outdated Show resolved Hide resolved
src/classes/Account.js Show resolved Hide resolved
@Eden12345
Copy link
Contributor

@Eden12345 Eden12345 commented Apr 13, 2020

Looks good to me. Won't give it the ol' GitHub approval as we aren't merging this into develop, though.

// const caretClasses = (this.state.isExpanded ? 'caret-up' : 'caret-down') + (isUnknown ? ' Category__antiTrackingCaret' : '');
const caretClasses = ClassNames(this.context, {
Comment on lines 163 to 164

This comment has been minimized.

@wlycdgr

wlycdgr Apr 13, 2020
Member

Did you mean to leave this?

This comment has been minimized.

@benstrumeyer

benstrumeyer Apr 13, 2020
Author Contributor

Ah, I did not. Deleted!

<path d="M1.283 7L0 5.676 5.5 0 11 5.676 9.717 7 5.5 2.649z" fillRule="evenodd" />
</svg>
);
// 4a4a4a

This comment has been minimized.

@wlycdgr

wlycdgr Apr 13, 2020
Member

Can be deleted?

This comment has been minimized.

@benstrumeyer

benstrumeyer Apr 13, 2020
Author Contributor

yes it can!

// const caretClasses = (this.state.isExpanded ? 'caret-up' : 'caret-down') + (isUnknown ? ' Category__antiTrackingCaret' : '');
// const caretClasses = (this.state.isExpanded ? this._renderCaret('up') : this._renderCaret('down'));
Comment on lines 200 to 201

This comment has been minimized.

@wlycdgr

wlycdgr Apr 13, 2020
Member

Can be deleted?

This comment has been minimized.

@benstrumeyer

benstrumeyer Apr 13, 2020
Author Contributor

yes it can!

_renderCliqzCookiesAndFingerprintsIcon() {
return (
<svg className="trk-cliqz-stats-icon" width="15" height="10" viewBox="0 0 10 10" xmlns="http://www.w3.org/2000/svg">
<path className={`cookies-and-fingerprints-icon ${this.context}`} fill="#FFF" fillRule="evenodd" strokeWidth=".96" d="M5.085 1.013a.288.288 0 0 0-.17 0l-3.66.97A.328.328 0 0 0 1 2.308c.017 2.606 1.413 5.024 3.813 6.642.05.034.119.051.187.051a.344.344 0 0 0 .187-.051C7.587 7.33 8.983 4.913 9 2.307a.328.328 0 0 0-.255-.323l-3.66-.971z" />
</svg>
);
}
Comment on lines 259 to 265

This comment has been minimized.

@wlycdgr

wlycdgr Apr 13, 2020
Member

Let's lift the class that identifies what sub-type of Cliqz icon this is up to the root svg element, since it applies to the whole thing. Let's also remove the fill attribute from the path element here to minimize confusion, since it's specified per-theme in the CSS.

This comment has been minimized.

@benstrumeyer

benstrumeyer Apr 13, 2020
Author Contributor

Love this idea--Moved the class up to the selector, removed the fill attribute in the JSX and made the CSS the single source of truth!

<svg className="trk-cliqz-stats-icon" width="15" height="10" viewBox="0 0 11 11" xmlns="http://www.w3.org/2000/svg">
<g fill="none" fillRule="evenodd">
<path fill="#FFF" d="M7.49 1.234L9.922 3.89l-.157 3.6L7.11 9.922l-3.6-.157L1.078 7.11l.157-3.6L3.89 1.078z" />
<path className={`ads-icon ${this.context}`} stroke="1DAFED" d="M2.788 8.54c.315.315.628.63.944.943.023.023.067.035.103.035 1.077.001 2.153.002 3.23-.001.04 0 .09-.02.117-.048a820.63 820.63 0 0 0 2.285-2.285.184.184 0 0 0 .05-.116c.003-1.08.003-2.16.002-3.24-.001-.03-.008-.068-.026-.088-.316-.321-.635-.64-.95-.956L2.789 8.54m-.436-.433l5.754-5.754c-.308-.309-.621-.623-.937-.936a.16.16 0 0 0-.102-.036 709.213 709.213 0 0 0-3.231 0c-.04 0-.09.02-.118.048-.765.762-1.53 1.525-2.291 2.29a.16.16 0 0 0-.045.1 928.271 928.271 0 0 0 0 3.26c0 .029.01.065.03.085.314.318.631.634.94.943m7.752-2.652c0 .581-.002 1.162.002 1.743a.405.405 0 0 1-.127.31 879.44 879.44 0 0 0-2.47 2.47.398.398 0 0 1-.303.128c-1.17-.003-2.341-.003-3.512 0a.4.4 0 0 1-.302-.126A884.3 884.3 0 0 0 .915 7.503a.385.385 0 0 1-.121-.294c.002-1.17.002-2.342 0-3.513 0-.122.036-.216.123-.303.827-.824 1.653-1.65 2.477-2.477a.388.388 0 0 1 .293-.123c1.174.002 2.348.002 3.523 0 .119 0 .21.038.293.122.827.83 1.655 1.657 2.484 2.484.081.08.12.17.119.285-.004.59-.002 1.181-.002 1.771" />
</g>
</svg>
Comment on lines 269 to 274

This comment has been minimized.

@wlycdgr

wlycdgr Apr 13, 2020
Member

Same deal with the subtype class and fill and stroke attributes here - let's lift up the former and remove the latter. Also, since (I think?) the fill and/or stroke attributes of both paths can vary depending on the fill, let's make sure that we can modify both from the CSS. Could use selectors, could give the first path a class too.

This comment has been minimized.

@benstrumeyer

benstrumeyer Apr 13, 2020
Author Contributor

Lifted the subtype classes, and made sure we can change the fill/stroke values inside the CSS. Love the idea of using a class name for the first path since it's nice to see which fill we're changing.

const borderClassNames = ClassNames('border', {
protected: type === 'antiTracking',
restricted: type !== 'antiTracking',
'palm-theme': contextType === 'palm-theme',
'leaf-theme': contextType === 'leaf-theme'
});

const backgroundClassNames = ClassNames('background', {
protected: type === 'antiTracking',
restricted: type !== 'antiTracking',
'palm-theme': contextType === 'palm-theme',
'leaf-theme': contextType === 'leaf-theme'
});

Comment on lines 64 to 77

This comment has been minimized.

@wlycdgr

wlycdgr Apr 13, 2020
Member

I could be tripping but I think you can just do restricted: type !== 'antiTracking', contextType,, right? Or will having an extraneous default/dark-theme class sometimes mess something up?

This comment has been minimized.

@benstrumeyer

benstrumeyer Apr 13, 2020
Author Contributor

You are def not tripping, I didn't know I could just slap a variable in there--thanks for the trick. Also we don't have any default / dark-theme specific CSS for these buttons so this works out!

<path className={borderClassNames} fill="#FFF" d="M-.5-.5h18.3v18.217H-.5z" />
<path className={backgroundClassNames} stroke="#FFF" d="M.5.5h16.3v16.217H.5z" />
Comment on lines 97 to 98

This comment has been minimized.

@wlycdgr

wlycdgr Apr 13, 2020
Member

Like with the Cliqz icons, since the fill and stroke are theme-dependent, let's define them entirely in the CSS

This comment has been minimized.

@benstrumeyer

benstrumeyer Apr 13, 2020
Author Contributor

Moved fill and stroke to the selectors in the CSS!

function getThemeColor() {
switch (StatsGraph.context) {
case 'palm-theme':
return '#172a0b';
case 'leaf-theme':
return '#173700';
default:
return '#124559';
}
}

Comment on lines 166 to 176

This comment has been minimized.

@wlycdgr

wlycdgr Apr 13, 2020
Member

There's not a different color for dark-theme? Or were you planning to add that after this PR

This comment has been minimized.

@benstrumeyer

benstrumeyer Apr 13, 2020
Author Contributor

Hmm, it looks like #124559 is exact blue we use for the midnight theme and we use the same blue across the default as well

image
image

Thoughts?

const { user, loggedIn } = this.props;
const { showResetModal, selection } = this.state;
return (
<StatsView
showResetModal={this.state.showResetModal}
showPitchModal={!this.props.user || !this.props.user.subscriptionsPlus}
loggedIn={this.props.loggedIn}
showResetModal={showResetModal}
showPitchModal={!user || !user.subscriptionsPlus}
loggedIn={loggedIn}
getStats={this.getStats}
selection={this.state.selection}
selection={selection}
Comment on lines +527 to +535

This comment has been minimized.

@wlycdgr

wlycdgr Apr 13, 2020
Member

Niiice

This comment has been minimized.

@benstrumeyer

benstrumeyer Apr 13, 2020
Author Contributor

thank you

@@ -22,7 +22,7 @@ import Stats from '../components/Stats';
* @todo We are not using ownProps, so we better not specify it explicitly,
* in this case it won't be passed by React (see https://github.com/reactjs/react-redux/blob/master/docs/api.md).
*/
const mapStateToProps = state => Object.assign({}, state.account);
const mapStateToProps = state => Object.assign({}, state.account, {});

This comment has been minimized.

@wlycdgr

wlycdgr Apr 13, 2020
Member

Is that empty object at the end intended?

This comment has been minimized.

@benstrumeyer

benstrumeyer Apr 13, 2020
Author Contributor

Just a remnant of when I was adding theme props to this container before we changed to context. Deleted!

@benstrumeyer benstrumeyer requested review from wlycdgr and Eden12345 Apr 13, 2020
@christophertino christophertino removed this from the 8.5.0 milestone Apr 15, 2020
@benstrumeyer benstrumeyer deleted the testable-theme-framework branch May 14, 2020
@benstrumeyer benstrumeyer restored the testable-theme-framework branch May 14, 2020
@benstrumeyer benstrumeyer deleted the testable-theme-framework branch May 14, 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

5 participants