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, Leaf & Palm Themes (FINAL) #525

Merged
merged 57 commits into from Apr 15, 2020
Merged
Changes from 1 commit
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
317ab64
Replace themes toggle with radio buttons
benstrumeyer Mar 11, 2020
f050b83
Center inner circle in radio buttons
benstrumeyer Mar 11, 2020
e8d7f92
Merge branch 'develop' into GH-1967/themes-panel-update
benstrumeyer Mar 12, 2020
f9b1546
Remove console error
benstrumeyer Mar 12, 2020
a9a12aa
Testing switching between themes
benstrumeyer Mar 18, 2020
fc61494
Add configuration that points to local account server
benstrumeyer Mar 18, 2020
05a37b3
Initial checkin
zarembsky Mar 19, 2020
0e0beef
Adding local themes
zarembsky Mar 19, 2020
8a66ff9
Adding comments.
zarembsky Mar 19, 2020
1ff8eb4
Fix (sort of)
zarembsky Mar 19, 2020
60cfc91
Real fix
zarembsky Mar 19, 2020
05f8718
Remove unneeded call
zarembsky Mar 19, 2020
824b2a3
Create theme framework and palm theme
benstrumeyer Mar 26, 2020
d36fd1a
Create palm theme svgs
benstrumeyer Mar 26, 2020
260c627
Add antiTracking, adBlocking and smartBlocking tracker counts to Cliq…
benstrumeyer Mar 26, 2020
8660643
Merge branch 'develop' into palm-theme
benstrumeyer Mar 26, 2020
d22b752
Remove console logs
benstrumeyer Mar 26, 2020
0fb546b
Get theme css from account project
benstrumeyer Mar 26, 2020
2a8bce2
Clean up radio button code
benstrumeyer Mar 31, 2020
2a58c29
Use context to pass theme
benstrumeyer Mar 31, 2020
37829c9
Merge branch 'develop' into feature/palm-theme
benstrumeyer Mar 31, 2020
2e44e44
Point to regular servers
benstrumeyer Mar 31, 2020
fc1a2a3
Remove local testing code
benstrumeyer Mar 31, 2020
1bbc72d
Uncomment function
benstrumeyer Mar 31, 2020
d0ec9be
Merge branch 'develop' into GH-1967/themes-panel-update
benstrumeyer Mar 31, 2020
bc90f18
Merge branch 'GH-1967/themes-panel-update' into feature/palm-theme
benstrumeyer Apr 1, 2020
5350c2b
Get database files from develop branch
benstrumeyer Apr 1, 2020
c1748dd
Get click2play from develop branch
benstrumeyer Apr 1, 2020
feb29b0
Delete leaf svg and png
benstrumeyer Apr 1, 2020
f08ff58
Style historical stats graph for leaf theme
benstrumeyer Apr 1, 2020
6bf02dd
Add leaf-theme tracker-list icons
benstrumeyer Apr 1, 2020
233d774
Refactor tracker-count status to account for leaf theme
benstrumeyer Apr 1, 2020
02671ef
Prep branch for testing
benstrumeyer Apr 6, 2020
5bf8902
Finalize leaf theme
benstrumeyer Apr 6, 2020
9334ab7
Use theme scss files as single source of truth for icon colors
benstrumeyer Apr 10, 2020
5a348ba
Refactor trackerButtons to use css fill and stroke colors. Use absolu…
benstrumeyer Apr 10, 2020
8805349
Remove antiTracking, adBlocking, and smartBlocking tracker counts to …
benstrumeyer Apr 10, 2020
d490c4b
Delete unused svgs
benstrumeyer Apr 10, 2020
f1aae45
Prevent tracker list styling from bleeding
benstrumeyer Apr 10, 2020
10e7c01
Style subscriber badge, and caret for palm-theme
benstrumeyer Apr 13, 2020
a2c4c53
Change subscriber badge fill color
benstrumeyer Apr 13, 2020
f9eb0e1
Refactor _renderCaret
benstrumeyer Apr 13, 2020
34e1831
Move stroke and fill colors into scss and removed fill/stroke attribu…
benstrumeyer Apr 13, 2020
3c44fef
Refactor trackerButtonRenderHelpers
benstrumeyer Apr 13, 2020
95b1c13
Remove empty object in StatsContainer
benstrumeyer Apr 13, 2020
6f864d8
Use css to style statsGraph point and line
benstrumeyer Apr 13, 2020
8519747
Merge branch 'develop' into testable-theme-framework
benstrumeyer Apr 14, 2020
92842cb
Remove code that makes theme framework locally testable
benstrumeyer Apr 14, 2020
2d9b216
Set the theme from account project as opposed to locally
benstrumeyer Apr 14, 2020
dd4c78b
Merge branch 'develop' into GH-1967/themes-panel-update
benstrumeyer Apr 14, 2020
03e8512
Merge branch 'GH-1967/themes-panel-update' into theme-framework
benstrumeyer Apr 14, 2020
174bf86
Update utils#setTheme function
benstrumeyer Apr 15, 2020
deb06ea
forEach loop cannot be used on an HTML collection
benstrumeyer Apr 15, 2020
5a43ce1
Host leaf and palm theme pngs on account server instead of extension
benstrumeyer Apr 15, 2020
a76dfc5
Merge branch 'develop' into theme-framework
benstrumeyer Apr 15, 2020
730a29b
Change utils#setTheme implementation detail
benstrumeyer Apr 15, 2020
4b39c20
Delete theme.scss file
benstrumeyer Apr 15, 2020
File filter
Filter file types
Jump to
Jump to file
Failed to load files.

Always

Just for now

Use context to pass theme

  • Loading branch information
benstrumeyer committed Mar 31, 2020
commit 2a58c29e4b9ee1c2f01b7b7efdc1d3bec68328bf
@@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" width="33" height="33" viewBox="0 0 33 33">
<circle cx="62.5" cy="147.5" r="13.5" fill="none" fill-rule="evenodd" stroke="#FFF" stroke-width="4.444" transform="translate(-46 -131)"/>
</svg>
@@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" width="29" height="29" viewBox="0 0 29 29">
<path fill="#FFF" fill-rule="evenodd" stroke="#FFF" stroke-width="3.78" d="M14.766 2.04c-.16-.053-.372-.053-.532 0L2.798 5.074C2.319 5.18 2 5.606 2 6.084c.053 8.143 4.415 15.7 11.915 20.756.16.107.372.16.585.16.213 0 .426-.053.585-.16C22.585 21.784 26.947 14.227 27 6.084c0-.478-.32-.904-.798-1.01L14.766 2.04z"/>
</svg>
@@ -0,0 +1,6 @@
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
<g fill="none" fill-rule="evenodd" stroke="#FFF" stroke-width="4.5" transform="translate(3 3)">
<path stroke-linecap="square" d="M0 0L18 18" transform="translate(4.5 4.5)"/>
<circle cx="13.219" cy="13.219" r="13.219"/>
</g>
</svg>
@@ -295,7 +295,6 @@ class Blocking extends React.Component {
sitePolicy,
smartBlock,
smartBlockActive,
current_theme,
} = this.props;

const {
@@ -331,7 +330,6 @@ class Blocking extends React.Component {
smartBlock={smartBlock}
unknownCategory={unknownCategory}
enable_anti_tracking={enable_anti_tracking}
current_theme={current_theme}
/>
)}
</div>
@@ -35,7 +35,6 @@ class Categories extends React.Component {
unknownCategory,
enable_anti_tracking,
sitePolicy,
current_theme,
} = this.props;
const globalBlocking = !!this.props.globalBlocking;
const filtered = !!this.props.filtered;
@@ -91,7 +90,6 @@ class Categories extends React.Component {
smartBlock={this.props.smartBlock}
enable_anti_tracking={enable_anti_tracking}
isUnknown={isUnknown}
current_theme={current_theme}
/>
);
};
@@ -164,7 +164,6 @@ class Category extends React.Component {
paused_blocking,
sitePolicy,
isUnknown,
current_theme,
} = this.props;

const globalBlocking = !!this.props.globalBlocking;
@@ -271,7 +270,6 @@ class Category extends React.Component {
smartBlockActive={this.props.smartBlockActive}
smartBlock={this.props.smartBlock}
isUnknown={isUnknown}
current_theme={current_theme}
/>
)}
</div>
@@ -17,6 +17,7 @@ import React from 'react';
import { ReactSVG } from 'react-svg';
import ClassNames from 'classnames';

import { ThemeContext } from '../../contexts/ThemeContext';
import globals from '../../../../src/classes/Globals';
import { log } from '../../../../src/utils/common';
import { sendMessageInPromise } from '../../utils/msg';
@@ -27,6 +28,8 @@ import { renderKnownTrackerButtons, renderUnknownTrackerButtons } from './tracke
* @memberOf BlockingComponents
*/
class Tracker extends React.Component {
static contextType = ThemeContext;

constructor(props) {
super(props);
this.state = {
@@ -259,8 +262,7 @@ class Tracker extends React.Component {
_renderCliqzAdsIcon() { return this._renderCliqzStatsIcon('ads'); }

_renderCliqzStatsIcon(type) {
const { current_theme } = this.props;
const path = `/app/images/panel/tracker-detail-cliqz-${type}-${current_theme}-icon.svg`;
const path = `/app/images/panel/tracker-detail-cliqz-${type}-${this.context}-icon.svg`;

return (
<ReactSVG src={path} className="trk-cliqz-stats-icon" />
@@ -40,7 +40,7 @@ class Trackers extends React.Component {
* @return {ReactComponent} ReactComponent instance
*/
render() {
const { trackers, isUnknown, current_theme } = this.props;
const { trackers, isUnknown } = this.props;
let trackerList;
if (this.props.globalBlocking) {
const trackersToShow = [];
@@ -75,7 +75,6 @@ class Trackers extends React.Component {
smartBlockActive={this.props.smartBlockActive}
smartBlock={this.props.smartBlock}
isUnknown={isUnknown}
current_theme={current_theme}
/>
));
}
@@ -11,8 +11,6 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0
*/

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

import React from 'react';
import PropTypes from 'prop-types';
import ClassNames from 'classnames';
@@ -23,15 +21,16 @@ import ClassNames from 'classnames';
*/

const RadioButton = (props) => {
const { checked, handleClick } = props;
const OuterCircleClassNames = ClassNames('RadioButton__outerCircle', {
checked: props.checked,
checked,
});
const InnerCircleClassNames = ClassNames('RadioButton__innerCircle', {
checked: props.checked,
checked,
});
return (
<span>
<span className={OuterCircleClassNames} onClick={props.handleClick}>
<span className={OuterCircleClassNames} onClick={handleClick}>
<span className={InnerCircleClassNames} />
</span>
</span>
@@ -40,6 +39,7 @@ const RadioButton = (props) => {

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

@@ -25,20 +25,20 @@ class RadioButtonGroup extends React.Component {
constructor(props) {
super(props);
this.state = {
buttons: []
buttonState: []
};
}

componentDidMount() {
const buttons = new Array(this.props.items.length).fill(false);
buttons[this.props.selectedIndex] = true;
this.setState({ buttons });
const buttonState = new Array(this.props.labels.length).fill(false);
buttonState[this.props.selectedIndex] = true;
this.setState({ buttonState });
}

handleClick(indexClicked) {
const { buttons } = this.state;
const updatedButtons = buttons.map((button, index) => (index === indexClicked));
this.setState({ buttons: updatedButtons });
const { buttonState } = this.state;
const updatedButtonState = buttonState.map((button, index) => (index === indexClicked));
this.setState({ buttonState: updatedButtonState });
this.props.handleItemClick(indexClicked);
}

@@ -47,15 +47,15 @@ class RadioButtonGroup extends React.Component {
* @return {JSX} JSX for rendering the Toggle Slider used throughout the extension
*/
render() {
const { buttons } = this.state;
const { buttonState } = this.state;
return (
this.props.items.map((item, index) => (
<div className="flex-container align-justify RadioButtonGroup__container" key={`${index * 2}`}>
this.props.labels.map((label, index) => (
<div className="flex-container align-justify RadioButtonGroup__container" key={label}>
<span className="RadioButtonGroup__label">
{t(item.text)}
{t(label)}
</span>
<div>
<RadioButton checked={buttons[index]} handleClick={() => this.handleClick(index)} />
<RadioButton checked={buttonState[index]} handleClick={() => this.handleClick(index)} />
</div>
</div>
))
@@ -65,7 +65,7 @@ class RadioButtonGroup extends React.Component {

// PropTypes ensure we pass required props of the correct type
RadioButtonGroup.propTypes = {
items: PropTypes.arrayOf(PropTypes.object).isRequired, // Number of objects in array is the number of radio buttons
labels: PropTypes.arrayOf(PropTypes.string).isRequired,
handleItemClick: PropTypes.func.isRequired,
selectedIndex: PropTypes.number.isRequired
};
@@ -14,12 +14,14 @@
import { isEqual } from 'underscore';
import React from 'react';
import * as D3 from 'd3';

import { ThemeContext } from '../../contexts/ThemeContext';
/**
* Generates an animated graph displaying locally stored stats
* @memberof PanelBuildingBlocks
*/
class StatsGraph extends React.Component {
static contextType = ThemeContext;

/**
* Lifecycle event
*/
@@ -161,12 +163,12 @@ class StatsGraph extends React.Component {
.attrTween('stroke-dasharray', interpolator);
}

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

@@ -179,7 +181,7 @@ class StatsGraph extends React.Component {
pathGroup.append('path')
.attr('d', line)
.attr('fill', 'none')
.attr('stroke', getThemeColor(this.props.theme))
.attr('stroke', getThemeColor())
.attr('stroke-width', 1.5)
.call(animator);
// ---------------------------------------------------------------------- //
@@ -204,7 +206,7 @@ class StatsGraph extends React.Component {
.enter()
.append('circle')
.attr('class', (d, i) => `point point-${i}`)
.attr('fill', getThemeColor(this.props.theme))
.attr('fill', getThemeColor())
.attr('cx', d => x(d.index))
.attr('cy', d => y(d.amount))
.attr('r', 0)
@@ -16,6 +16,7 @@ import { NavLink } from 'react-router-dom';
import Header from '../containers/HeaderContainer';
import { PremiumPromoModal } from '../../shared-components';
import InsightsPromoModal from './InsightsPromoModal';
import { ThemeContext } from '../contexts/ThemeContext';
import { DynamicUIPortContext } from '../contexts/DynamicUIPortContext';
import { sendMessage } from '../utils/msg';
import { setTheme } from '../utils/utils';
@@ -408,7 +409,7 @@ class Panel extends React.Component {
}

const notificationText = this.props.notificationShown && this.renderNotification();

const { current_theme } = this.props;
return (
<div id="panel">
{this._renderPromoModal()}
@@ -425,9 +426,11 @@ class Panel extends React.Component {
</div>
</div>
<Header />
<DynamicUIPortContext.Provider value={this._dynamicUIPort}>
{ this.props.children }
</DynamicUIPortContext.Provider>
<ThemeContext.Provider value={current_theme}>
<DynamicUIPortContext.Provider value={this._dynamicUIPort}>
{ this.props.children }
</DynamicUIPortContext.Provider>
</ThemeContext.Provider>

</div>
);
@@ -524,14 +524,15 @@ class Stats extends React.Component {
* @return {ReactComponent} StatsView instance
*/
render() {
const { user, loggedIn, current_theme } = this.props;
const { user, loggedIn } = this.props;
const { showResetModal, selection } = this.state;
return (
<StatsView
showResetModal={this.state.showResetModal}
showResetModal={showResetModal}
showPitchModal={!user || !user.subscriptionsPlus}
loggedIn={loggedIn}
getStats={this.getStats}
selection={this.state.selection}
selection={selection}
selectView={this.selectView}
selectType={this.selectType}
selectTimeframe={this.selectTimeframe}
@@ -540,7 +541,6 @@ class Stats extends React.Component {
cancelReset={this.cancelReset}
subscribe={this.subscribe}
signIn={this.signIn}
theme={current_theme}
/>
);
}
@@ -38,7 +38,6 @@ const StatsView = (props) => {
cancelReset,
subscribe,
signIn,
theme
} = props;

const {
@@ -123,7 +122,6 @@ const StatsView = (props) => {
tooltipText={tooltipText}
selectTimeframe={selectTimeframe}
timeframeSelectors={timeframeSelectors}
theme={theme}
/>
<div className="tab-header">
<div className="tab-container">
@@ -22,34 +22,16 @@ import { RadioButtonGroup } from '../BuildingBlocks';
* @memberOf SettingsComponents
*/
const SubscriptionThemes = (props) => {
const themes = [
{
name: 'default',
text: 'subscription_default_theme',
},
{
name: 'midnight-theme',
text: 'subscription_dark_blue_theme',
},
{
name: 'palm-theme',
text: 'subscription_palm_theme',
},
{
name: 'leaf',
text: 'subscription_leaf_theme',
}
];
const themes = ['default', 'midnight-theme', 'palm-theme', 'leaf-theme'];
const themeLabels = ['subscription_default_theme', 'subscription_dark_blue_theme', 'subscription_palm_theme', 'subscription_leaf_theme'];

const getSelectedIndex = () => {
const index = themes.findIndex(theme => theme.name === props.theme);
const index = themes.indexOf(props.theme);
return index;
};

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

return (
@@ -61,7 +43,7 @@ const SubscriptionThemes = (props) => {
<img src="../../app/images/panel/icon-information-tooltip-blue.svg" className="s-question" />
</span>
<RadioButtonGroup
items={themes}
labels={themeLabels}
handleItemClick={handleThemeClick}
selectedIndex={getSelectedIndex(props.theme)}
/>
@@ -74,7 +56,6 @@ const SubscriptionThemes = (props) => {
// PropTypes ensure we pass required props of the correct type
SubscriptionThemes.propTypes = {
changeTheme: PropTypes.func.isRequired,
theme: PropTypes.string.isRequired,
};

export default SubscriptionThemes;
@@ -35,7 +35,6 @@ const mapStateToProps = state => Object.assign({}, state.blocking, {
paused_blocking: state.summary.paused_blocking,
sitePolicy: state.summary.sitePolicy,
smartBlockActive: state.panel.enable_smart_block,
current_theme: state.panel.current_theme
});
/**
* Bind Blocking view component action creators using Redux's bindActionCreators
ProTip! Use n and p to navigate between commits in a pull request.