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
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter
Filter file types
Jump to
Jump to file
Failed to load files.

Always

Just for now

Initial checkin
  • Loading branch information
zarembsky committed Mar 19, 2020
commit 05a37b3a8596009a6d502baa9332f8bd09a8d6b1
@@ -87,6 +87,7 @@ export const getTheme = name => dispatch => (
sendMessageInPromise('setPanelData', { current_theme: name })
.then(() => sendMessageInPromise('account.getTheme'))
.then((res) => {
console.log('GOT THEME', res);
if (res) {
dispatch({
type: SET_THEME,
@@ -58,6 +58,12 @@ class Panel extends React.Component {
});
}

shouldComponentUpdate(nextProps, nextState) {
console.log('COMPONENT DID UPDATE CALLED', nextProps, nextState);
this.forceUpdate();
return false;
}

/**
* Lifecycle event
*/
@@ -130,6 +136,7 @@ class Panel extends React.Component {
const { panel, summary, blocking } = payload;
const { current_theme, account } = panel;

console.log('INIT SET THEME', current_theme);
setTheme(document, current_theme, account);

this.props.actions.updatePanelData(panel);
@@ -48,6 +48,7 @@ const SubscriptionThemes = (props) => {

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!

props.changeTheme(theme.name);
};

@@ -77,10 +77,12 @@ export default (state = initialState, action) => {
}
case SET_THEME: {
const { name, css } = action.data;
console.log('PANEL ACTION SET THEME', name, css);
setTheme(document, name, { themeData: { [name]: { name, css } } });
return Object.assign({}, state, { current_theme: name });
}
case CLEAR_THEME: {
console.log('CLEAR THEME IS CALLED');
setTheme(document, initialState.current_theme);
return Object.assign({}, state, { current_theme: initialState.current_theme });
}
@@ -216,7 +216,7 @@ export function setTheme(doc, name, account) {
// if themeName is 'default' all we have to do is to remove style element
const styleTitlePrefix = 'Ghostery Theme';
// First remove all other style elements which may be there
const styleList = doc.head.getElementsByTagName('style');
const styleList = doc.head.getElementsByTagName('link');
// Other kinds of loops are not supported equally across browsers
for (let i = 0; i < styleList.length; i++) {
const style = styleList[i];
@@ -236,12 +236,14 @@ export function setTheme(doc, name, account) {
const { css } = themeData[name];

// Create element for the theme being set, if it is not there
const themeStyle = doc.createElement('style');
themeStyle.id = name;
const themeStyle = doc.createElement('link');
themeStyle.rel = 'stylesheet';
themeStyle.media = 'screen';
themeStyle.type = 'text/css';
themeStyle.title = `${styleTitlePrefix} ${name}`;

// Set content of style element to the theme text.
themeStyle.textContent = css;
document.head.appendChild(themeStyle);
themeStyle.href = css;
doc.head.appendChild(themeStyle);
}
}
ProTip! Use n and p to navigate between commits in a pull request.