mirror of
https://github.com/notion-enhancer/notion-enhancer.git
synced 2025-04-10 15:39:01 +00:00
feat(indent-guides): alternating indentation guide colours
This commit is contained in:
parent
e4d335919d
commit
9f8d9030ae
src
@ -37,9 +37,11 @@ const shouldLoadThemeOverrides = async (api, db) => {
|
|||||||
const { html } = api,
|
const { html } = api,
|
||||||
customStyles = (await db.get("customStyles"))?.content;
|
customStyles = (await db.get("customStyles"))?.content;
|
||||||
if (!customStyles) return;
|
if (!customStyles) return;
|
||||||
return document.head.append(html`<style>
|
const $customStyles = html`<style
|
||||||
${customStyles}
|
id="__custom"
|
||||||
</style>`);
|
innerHTML=${customStyles}
|
||||||
|
></style>`;
|
||||||
|
return document.head.append($customStyles);
|
||||||
};
|
};
|
||||||
|
|
||||||
const insertMenu = async (api, db) => {
|
const insertMenu = async (api, db) => {
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
body {
|
body {
|
||||||
--guide--style: solid;
|
--guide--style: solid;
|
||||||
--guide--color: var(--theme--fg-border);
|
--guide--color: var(--theme--fg-border);
|
||||||
|
--guide--opacity: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* add indent guides to nested blocks */
|
/* add indent guides to nested blocks */
|
||||||
@ -28,6 +29,7 @@ body {
|
|||||||
top: var(--guide--offset);
|
top: var(--guide--offset);
|
||||||
margin-inline-start: var(--guide--indent);
|
margin-inline-start: var(--guide--indent);
|
||||||
border-left: 1px var(--guide--style) var(--guide--color);
|
border-left: 1px var(--guide--style) var(--guide--color);
|
||||||
|
opacity: var(--guide--opacity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,6 +61,7 @@ body {
|
|||||||
height: 100%;
|
height: 100%;
|
||||||
margin-inline-start: var(--guide--indent);
|
margin-inline-start: var(--guide--indent);
|
||||||
border-left: 1px var(--guide--style) var(--guide--color);
|
border-left: 1px var(--guide--style) var(--guide--color);
|
||||||
|
opacity: var(--guide--opacity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,63 +6,70 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
export default async function (api, db) {
|
export default async function (api, db) {
|
||||||
const lineType = await db.get("lineType"),
|
const { html } = api,
|
||||||
|
guideStyle = await db.get("guideStyle"),
|
||||||
rainbowMode = await db.get("rainbowMode");
|
rainbowMode = await db.get("rainbowMode");
|
||||||
document.body.style.setProperty("--guide--style", lineType.toLowerCase());
|
document.body.style.setProperty("--guide--style", guideStyle.toLowerCase());
|
||||||
|
|
||||||
// switch (await db.get(["style"])) {
|
const nestedTargets = [],
|
||||||
// case "dashed":
|
outlineTargets = [];
|
||||||
// style = "dashed";
|
for (const [listType, selectors] of [
|
||||||
// break;
|
["to-doList", [".notion-to_do-block"]],
|
||||||
// case "dotted":
|
["bulletedList", [".notion-bulleted_list-block"]],
|
||||||
// style = "dotted";
|
["numberedList", [".notion-numbered_list-block"]],
|
||||||
// break;
|
["toggleList", [".notion-toggle-block"]],
|
||||||
// case "soft":
|
[
|
||||||
// opacity = 0.25;
|
"toggleHeadings",
|
||||||
// break;
|
[
|
||||||
// case "rainbow":
|
".notion-header-block",
|
||||||
// opacity = 0.7;
|
".notion-sub_header-block",
|
||||||
// rainbow = true;
|
".notion-sub_sub_header-block",
|
||||||
// break;
|
],
|
||||||
// }
|
],
|
||||||
|
]) {
|
||||||
|
if (await db.get(listType)) nestedTargets.push(...selectors);
|
||||||
|
}
|
||||||
|
if (await db.get("tableOfContents"))
|
||||||
|
outlineTargets.push(".notion-table_of_contents-block");
|
||||||
|
if (await db.get("outliner"))
|
||||||
|
outlineTargets.push(".notion-enhancer--outliner-heading");
|
||||||
|
|
||||||
// const colors = ['red', 'pink', 'purple', 'blue', 'green', 'yellow'];
|
let css = `${[...nestedTargets, ...outlineTargets].join(",")} {
|
||||||
// colors.push(...colors, ...colors, ...colors, 'gray');
|
--guide--opacity: 1;
|
||||||
|
}`;
|
||||||
// for (const listType of ['bulleted_list', 'numbered_list', 'to_do', 'toggle']) {
|
if (rainbowMode) {
|
||||||
// if (!(await db.get([listType]))) continue;
|
const selector = `:is(${nestedTargets.join(",")})`,
|
||||||
// css += `
|
opacity = `--guide--opacity: 0.5;`,
|
||||||
// .notion-page-content .notion-${listType}-block > div > div:last-child::before {
|
colours = [
|
||||||
// border-left: 1px ${style} var(--indentation_lines--color, currentColor);
|
"red",
|
||||||
// opacity: ${opacity};
|
"pink",
|
||||||
// }`;
|
"purple",
|
||||||
|
"blue",
|
||||||
// if (rainbow) {
|
"green",
|
||||||
// for (let i = 0; i < colors.length; i++) {
|
"yellow",
|
||||||
// css += `
|
"orange",
|
||||||
// .notion-page-content ${`.notion-${listType}-block `.repeat(i + 1)}
|
"brown",
|
||||||
// > div > div:last-child::before {
|
];
|
||||||
// --indentation_lines--color: var(--theme--text_${colors[i]});
|
colours.push(...colours, ...colours, ...colours, "gray");
|
||||||
// }`;
|
for (let i = 0; i < colours.length; i++) {
|
||||||
// }
|
css += `${(selector + " ").repeat(i + 1)} {
|
||||||
// }
|
--guide--color: var(--theme--fg-${colours[i]});
|
||||||
// }
|
${opacity}
|
||||||
|
}`;
|
||||||
// if (await db.get(['toggle_header'])) {
|
}
|
||||||
// css += `
|
css += `
|
||||||
// .notion-page-content [class$=header-block] > div > div > div:last-child::before {
|
.notion-table_of_contents-block [contenteditable="false"] a
|
||||||
// border-left: 1px ${style} var(--indentation_lines--color, currentColor);
|
> div[style*="margin-left: 24px"],
|
||||||
// opacity: ${opacity};
|
.notion-enhancer--outliner-heading.pl-\\[36px\\] {
|
||||||
// }`;
|
--guide--color: var(--theme--fg-${colours[0]});
|
||||||
|
${opacity}
|
||||||
// if (rainbow) {
|
}
|
||||||
// for (let i = 0; i < colors.length; i++) {
|
.notion-table_of_contents-block [contenteditable="false"] a
|
||||||
// css += `
|
> div[style*="margin-left: 48px"],
|
||||||
// .notion-page-content ${`[class$=header-block] `.repeat(i + 1)}
|
.notion-enhancer--outliner-heading.pl-\\[54px\\] {
|
||||||
// > div > div > div:last-child::before{
|
--guide--color: var(--theme--fg-${colours[1]});
|
||||||
// --indentation_lines--color: var(--theme--text_${colors[i]});
|
${opacity}
|
||||||
// }`;
|
}`;
|
||||||
// }
|
}
|
||||||
// }
|
document.head.append(html`<style innerHTML=${css}></style>`);
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
@ -20,8 +20,8 @@
|
|||||||
"options": [
|
"options": [
|
||||||
{
|
{
|
||||||
"type": "select",
|
"type": "select",
|
||||||
"key": "lineType",
|
"key": "guideStyle",
|
||||||
"description": "The line style to use for indent guides.",
|
"description": "The type of line to use for indent guides.",
|
||||||
"values": ["Solid", "Dashed", "Dotted"]
|
"values": ["Solid", "Dashed", "Dotted"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user