Skip to content

Commit

Permalink
Unique namespace for content script css (#7)
Browse files Browse the repository at this point in the history
* Unique namespace for content script css

* Version
  • Loading branch information
dedoussis committed Oct 16, 2022
1 parent 4e74571 commit 055974c
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 21 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "icloud-hide-my-email-chrome-extension",
"version": "0.0.1",
"version": "1.0.0",
"description": "Unofficial chromium extension to support iCloud's Hide My Email feature.",
"license": "MIT",
"author": "dedoussis",
Expand Down
2 changes: 1 addition & 1 deletion src/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "iCloud Hide My Email",
"description": "Unofficial chromium extension to support iCloud's Hide My Email feature.",
"version": "0.0.3",
"version": "1.0.0",
"manifest_version": 3,
"background": { "service_worker": "background.bundle.js" },
"action": {
Expand Down
20 changes: 19 additions & 1 deletion src/pages/Content/index.css
Original file line number Diff line number Diff line change
@@ -1 +1,19 @@
@tailwind utilities;
.d1691f0f-b8f0-495e-9ffb-fe4e6f84b518-button {
@apply bg-sky-400 text-white w-full rounded p-2 my-1 font-sans font-medium;
}

.d1691f0f-b8f0-495e-9ffb-fe4e6f84b518-hover-button {
@apply hover:bg-sky-500;
}

.d1691f0f-b8f0-495e-9ffb-fe4e6f84b518-cursor-not-allowed {
@apply cursor-not-allowed;
}

.d1691f0f-b8f0-495e-9ffb-fe4e6f84b518-cursor-progress {
@apply cursor-progress;
}

.d1691f0f-b8f0-495e-9ffb-fe4e6f84b518-cursor-pointer {
@apply cursor-pointer;
}
33 changes: 15 additions & 18 deletions src/pages/Content/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ const emailInputElements = document.querySelectorAll<HTMLInputElement>(
);

const LOADING_COPY = `Hide My Email — Loading...`;
const STYLE_CLASS_PREFIX = 'd1691f0f-b8f0-495e-9ffb-fe4e6f84b518';

const className = (shortName: string): string =>
`${STYLE_CLASS_PREFIX}-${shortName}`;

const ELEMENT_ID_NAMESPACE = uuidv4();

Expand All @@ -27,13 +31,13 @@ const disableButton = (
): void => {
btn.innerHTML = copy;
btn.setAttribute('disabled', 'true');
btn.classList.remove('hover:bg-sky-500');
btn.classList.forEach((className) => {
if (className.startsWith('cursor-')) {
btn.classList.remove(className);
btn.classList.remove(className('hover-button'));
btn.classList.forEach((name) => {
if (name.startsWith(className('cursor-'))) {
btn.classList.remove(name);
}
});
btn.classList.add(cursorClass);
btn.classList.add(className(cursorClass));
};

const enableButton = (
Expand All @@ -43,13 +47,13 @@ const enableButton = (
): void => {
btn.innerHTML = copy;
btn.removeAttribute('disabled');
btn.classList.add('hover:bg-sky-500');
btn.classList.forEach((className) => {
if (className.startsWith('cursor-')) {
btn.classList.remove(className);
btn.classList.add(className('hover-button'));
btn.classList.forEach((name) => {
if (name.startsWith(className('cursor-'))) {
btn.classList.remove(name);
}
});
btn.classList.add(cursorClass);
btn.classList.add(className(cursorClass));
};

const makeInputElementWithButton = (
Expand All @@ -59,14 +63,7 @@ const makeInputElementWithButton = (
const btnElementId = `${ELEMENT_ID_NAMESPACE}-${uuidv4()}`;
btnElement.setAttribute('id', btnElementId);
btnElement.setAttribute('type', 'button');
btnElement.classList.add('bg-sky-400');
btnElement.classList.add('text-white');
btnElement.classList.add('w-full');
btnElement.classList.add('rounded');
btnElement.classList.add('p-2');
btnElement.classList.add('my-1');
btnElement.classList.add('font-sans');
btnElement.classList.add('font-medium');
btnElement.classList.add(className('button'));

disableButton(btnElement, 'cursor-not-allowed', LOADING_COPY);

Expand Down

0 comments on commit 055974c

Please sign in to comment.