dark mode helpers
This commit is contained in:
parent
e00c8ea975
commit
af8eb662ef
@ -121,7 +121,9 @@ const mailgoInit = (mailgoConfig?: MailgoConfig): void => {
|
|||||||
|
|
||||||
// if dark is in config
|
// if dark is in config
|
||||||
if (config?.dark) {
|
if (config?.dark) {
|
||||||
modalMailto.classList.add("m-dark");
|
enableDarkMode(MAIL_TYPE);
|
||||||
|
} else {
|
||||||
|
disableDarkMode(MAIL_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// background
|
// background
|
||||||
@ -273,7 +275,9 @@ const mailgoInit = (mailgoConfig?: MailgoConfig): void => {
|
|||||||
|
|
||||||
// if dark is in config
|
// if dark is in config
|
||||||
if (config?.dark) {
|
if (config?.dark) {
|
||||||
modalTel.classList.add("m-dark");
|
enableDarkMode(TEL_TYPE);
|
||||||
|
} else {
|
||||||
|
disableDarkMode(TEL_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// background
|
// background
|
||||||
@ -848,19 +852,24 @@ const mailToEncoded = (encoded: string): string =>
|
|||||||
const encodeEmail = (email: string): string => btoa(email);
|
const encodeEmail = (email: string): string => btoa(email);
|
||||||
|
|
||||||
// get the correct HTMLElement from a type
|
// get the correct HTMLElement from a type
|
||||||
const getModalHTMLElement = (type: string = MAIL_TYPE) => {
|
const getModalHTMLElement = (type: string = MAIL_TYPE) =>
|
||||||
return type === TEL_TYPE ? modalTel : modalMailto;
|
type === TEL_TYPE ? modalTel : modalMailto;
|
||||||
};
|
|
||||||
|
|
||||||
// get display value
|
// get display value
|
||||||
const getModalDisplay = (ref: string = MAIL_TYPE): string => {
|
const getModalDisplay = (ref: string = MAIL_TYPE): string =>
|
||||||
return getModalHTMLElement(ref).style.display;
|
getModalHTMLElement(ref).style.display;
|
||||||
};
|
|
||||||
|
|
||||||
// get display value
|
// get display value
|
||||||
const setModalDisplay = (ref: string = MAIL_TYPE, value: string): string => {
|
const setModalDisplay = (ref: string = MAIL_TYPE, value: string): string =>
|
||||||
return (getModalHTMLElement(ref).style.display = value);
|
(getModalHTMLElement(ref).style.display = value);
|
||||||
};
|
|
||||||
|
// enable dark mode
|
||||||
|
const enableDarkMode = (type: string = MAIL_TYPE) =>
|
||||||
|
getModalHTMLElement(type).classList.add("m-dark");
|
||||||
|
|
||||||
|
// disable dark mode
|
||||||
|
const disableDarkMode = (type: string = MAIL_TYPE) =>
|
||||||
|
getModalHTMLElement(type).classList.remove("m-dark");
|
||||||
|
|
||||||
// custom composedPath if path or event.composedPath() are not defined
|
// custom composedPath if path or event.composedPath() are not defined
|
||||||
const composedPath = (
|
const composedPath = (
|
||||||
|
Loading…
x
Reference in New Issue
Block a user