Skip to content

Commit

Permalink
remove comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffreyclu committed Oct 22, 2021
1 parent d490761 commit 20d0f0a
Showing 1 changed file with 7 additions and 27 deletions.
34 changes: 7 additions & 27 deletions src/thememaker.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export default class Thememaker {

/**
*
* @returns an integer representing the number of total colors for thememaker
* @returns an integer representing the number of total colors for THEMEMAKER
*/
calculateTotalColors = () => {
return Object.keys(this.htmlElements).length;
Expand Down Expand Up @@ -166,25 +166,13 @@ export default class Thememaker {

elementArr.forEach((element) => {
colorScheme[element] = color;
// if root color is black,
// set all text elements to white
// if (colorArr[0] === "#000000") {
// if (this.isTextElement(element)) {
// colorScheme[element] = "#FFFFFF"
// } else {
// colorScheme[element] = color;
// }
// } else {
// colorScheme[element] = color;
// }
})
}

return colorScheme;
}

/**
*
* applies the color scheme
*/
applyScheme = (scheme) => {
Expand All @@ -199,10 +187,10 @@ export default class Thememaker {
schemeStyle += `${key} { color: ${scheme["p"]} !important; background-color: ${value} !important; }`;
} else {
schemeStyle += `${key} { color: ${value} !important; background-color: transparent !important; background-image: none !important; }`;
}
}
}

// hardcode thememaker UI colors
// hardcode thememaker UI colors otherwise the theme will override it 🥲
schemeStyle += "#generateSchemeButton { background-color: #FFFFFF !important; color: #000000 !important; }";
schemeStyle += "#saveSchemeButton { background-color: #FFFFFF !important; color: #000000 !important; }";
schemeStyle += "#resetSchemeButton { background-color: #FFFFFF !important; color: #000000 !important; }";
Expand All @@ -213,7 +201,7 @@ export default class Thememaker {
schemeStyle += `#schemeDetailsPanel { background-color: #FFFFFF !important; }`;
schemeStyle += `#schemeHistoryPanel { background-color: #FFFFFF !important; }`;

// rest existing scheme from head
// reset existing scheme from head
const head = document.querySelector("head");
const oldScheme = document.querySelector("#themeMaker");
if (oldScheme) {
Expand Down Expand Up @@ -253,6 +241,7 @@ export default class Thememaker {
/**
*
* @param {{}} scheme
* enqueues the passed in scheme
*/
enqueueScheme = (scheme) => {
this.schemeHistory.push(scheme);
Expand Down Expand Up @@ -393,6 +382,7 @@ export default class Thememaker {
Scheme History
</span>
`;

schemeHistoryPanel.appendChild(header);

this.schemeHistory.forEach((scheme, i) => {
Expand All @@ -410,7 +400,6 @@ export default class Thememaker {
</span>
`;
newP.onclick = applyHistory;


schemeHistoryPanel.appendChild(newP);
})
Expand All @@ -420,34 +409,25 @@ export default class Thememaker {
* click handler to generate a scheme
*/
handleGenerateScheme = async () => {
// generate a mode and a color
const seedDetails = {
rootColor: this.randomHexColor(),
colorMode: this.randomMode()
}

// save seed details in state
this.applySchemeDetails(seedDetails);

// generate a url
const colorApiUrl = this.generateColorApiUrl(seedDetails, "json");

// fetch data
const fetchedColors = await this.fetchColors(colorApiUrl);

// generate the scheme
const generatedScheme = this.generateScheme(fetchedColors);

// add the scheme to the queue;
this.enqueueScheme(generatedScheme);

// apply the scheme
this.applyScheme(generatedScheme);

// apply the details to the details panel;
this.renderSchemeDetails(generatedScheme);

// update the UI
this.updateUi();
}

Expand Down Expand Up @@ -519,4 +499,4 @@ export default class Thememaker {
this.generateUi();
this.applySavedScheme();
}
}
}

0 comments on commit 20d0f0a

Please sign in to comment.