mirror of
https://github.com/notion-enhancer/notion-enhancer.git
synced 2025-04-08 06:29:03 +00:00
chore(menu): remove option type demos, fix(menu): support mods without options, feat(menu): override heading autoremove
This commit is contained in:
parent
809b59ebb1
commit
0fff732fd9
@ -185,7 +185,6 @@ function Banner({ updateAvailable, isDevelopmentBuild }) {
|
||||
$sponsorship.style.display = agreedToTerms === version ? "" : "none";
|
||||
});
|
||||
|
||||
// todo: show popup if update available
|
||||
return html`<section class="notion-enhancer--menu-banner">
|
||||
${$welcome}${$sponsorship}
|
||||
</section>`;
|
||||
|
@ -22,14 +22,18 @@ const camelToSentenceCase = (string) =>
|
||||
// ignore platform-specific options
|
||||
if (opt.platforms && !opt.platforms.includes(platform)) return options;
|
||||
// replace consective headings
|
||||
const prev = options[options.length - 1];
|
||||
if (opt.type === "heading" && prev?.type === opt.type) {
|
||||
opt.autoremove ??= true;
|
||||
const prev = options[options.length - 1],
|
||||
canReplacePrev = prev?.autoremove && prev?.type === opt.type;
|
||||
if (opt.type === "heading" && canReplacePrev) {
|
||||
options[options.length - 1] = opt;
|
||||
} else options.push(opt);
|
||||
return options;
|
||||
}, []);
|
||||
// remove trailing heading
|
||||
return options.at(-1)?.type === "heading" ? options.slice(0, -1) : options;
|
||||
return options.at(-1)?.type === "heading" && options.at(-1)?.autoremove
|
||||
? options.slice(0, -1)
|
||||
: options;
|
||||
};
|
||||
|
||||
function Option({ _get, _set, ...opt }) {
|
||||
|
@ -86,7 +86,9 @@ function Sidebar({ items, categories }) {
|
||||
|
||||
for (const { title, mods } of categories) {
|
||||
const $title = html`<${SidebarHeading}>${title}<//>`,
|
||||
$mods = mods.map((mod) => [
|
||||
$mods = mods
|
||||
.filter((mod) => mod.options?.length)
|
||||
.map((mod) => [
|
||||
mod.id,
|
||||
html`<${SidebarButton} id=${mod.id}>${mod.name}<//>`,
|
||||
]);
|
||||
|
@ -33,17 +33,17 @@ function Telemetry() {
|
||||
}
|
||||
});
|
||||
|
||||
// todo: actually collect telemetry
|
||||
return html`<${Option}
|
||||
type="toggle"
|
||||
label="Telemetry"
|
||||
description=${html`If telemetry is enabled, usage data will be collected
|
||||
once a week from your device in order to better understand how and where
|
||||
the notion-enhancer is used. This data is anonymous and includes only your
|
||||
platform (${$.platform}), notion-enhancer version (${$.version}), timezone
|
||||
(${$.timezone}), and enabled mods (${$.enabledMods}). You can opt in or
|
||||
out of telemetry at any time. This setting syncs across configuration
|
||||
profiles. For more information, read the notion-enhancer's
|
||||
description=${html`If telemetry is enabled, usage data will be collected at
|
||||
a regular interval from your device in order to better understand how and
|
||||
where the notion-enhancer is used. This data is anonymous and includes
|
||||
only your platform (${$.platform}), notion-enhancer version
|
||||
(${$.version}), timezone (${$.timezone}), and enabled mods
|
||||
(${$.enabledMods}). You can opt in or out of telemetry at any time. This
|
||||
setting syncs across configuration profiles. For more information, read
|
||||
the notion-enhancer's
|
||||
<a href=${privacyPolicy} class="ml-[3px]">privacy policy</a>.`}
|
||||
...${{ _get, _set }}
|
||||
/>`;
|
||||
|
@ -103,7 +103,7 @@ const render = async () => {
|
||||
}
|
||||
for (let i = 0; i < mods.length; i++) {
|
||||
const options = mods[i].options?.filter((opt) => opt.type !== "heading");
|
||||
if (mods[i]._src === "core" || !options.length) continue;
|
||||
if (mods[i]._src === "core" || !options?.length) continue;
|
||||
const _get = () => isEnabled(mods[i].id),
|
||||
_set = async (enabled) => {
|
||||
await setEnabled(mods[i].id, enabled);
|
||||
|
@ -26,12 +26,6 @@
|
||||
"type": "heading",
|
||||
"label": "Appearance"
|
||||
},
|
||||
{
|
||||
"type": "toggle",
|
||||
"key": "toggle",
|
||||
"description": "Sets whether the notion-enhancer icon added to Notion's sidebar should be coloured or monochrome. The latter style will match the theme's icon colour for users who would like the icon to be less noticeable.",
|
||||
"value": true
|
||||
},
|
||||
{
|
||||
"type": "select",
|
||||
"key": "menuButtonIconStyle",
|
||||
@ -52,7 +46,8 @@
|
||||
},
|
||||
{
|
||||
"type": "heading",
|
||||
"label": "Advanced"
|
||||
"label": "Advanced",
|
||||
"autoremove": false
|
||||
},
|
||||
{
|
||||
"type": "toggle",
|
||||
@ -60,24 +55,6 @@
|
||||
"description": "Activates built-in debugging tools accessible through the application menu.",
|
||||
"platforms": ["darwin", "win32", "linux"],
|
||||
"value": false
|
||||
},
|
||||
{
|
||||
"type": "color",
|
||||
"key": "color",
|
||||
"description": "Activates built-in debugging tools accessible through the application menu.",
|
||||
"value": "rgb(232, 69, 93)"
|
||||
},
|
||||
{
|
||||
"type": "text",
|
||||
"key": "text",
|
||||
"description": "Activates built-in debugging tools accessible through the application menu.",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"type": "number",
|
||||
"key": "number",
|
||||
"description": "Activates built-in debugging tools accessible through the application menu.",
|
||||
"value": ""
|
||||
}
|
||||
],
|
||||
"clientStyles": ["variables.css"],
|
||||
|
@ -12,50 +12,5 @@
|
||||
"avatar": "https://dragonwocky.me/avatar.jpg"
|
||||
}
|
||||
],
|
||||
"options": [
|
||||
{
|
||||
"type": "heading",
|
||||
"label": "Hotkeys"
|
||||
},
|
||||
{
|
||||
"type": "hotkey",
|
||||
"key": "openMenuHotkey",
|
||||
"description": "Opens the notion-enhancer menu from within Notion.",
|
||||
"value": "Ctrl+Shift+,"
|
||||
},
|
||||
{
|
||||
"type": "heading",
|
||||
"label": "Appearance"
|
||||
},
|
||||
{
|
||||
"type": "select",
|
||||
"key": "menuButtonIconStyle",
|
||||
"description": "Sets whether the notion-enhancer icon added to Notion's sidebar should be coloured or monochrome. The latter style will match the theme's icon colour for users who would like the icon to be less noticeable.",
|
||||
"values": ["Colour", "Monochrome"]
|
||||
},
|
||||
{
|
||||
"type": "select",
|
||||
"key": "loadThemeOverrides",
|
||||
"description": "Loads the styling required for a theme to customise Notion's interface. Disabling this will increase client performance.",
|
||||
"values": ["Auto", "Enabled", "Disabled"]
|
||||
},
|
||||
{
|
||||
"type": "file",
|
||||
"key": "customStyles",
|
||||
"description": "Adds the styles from an uploaded .css file to Notion. Use this if you would like to customise the current theme or <a href=\"https://notion-enhancer.github.io/advanced/tweaks\">otherwise tweak Notion's appearance</a>.",
|
||||
"extensions": ["css"]
|
||||
},
|
||||
{
|
||||
"type": "heading",
|
||||
"label": "Advanced"
|
||||
},
|
||||
{
|
||||
"type": "toggle",
|
||||
"key": "debugMode",
|
||||
"description": "Activates built-in debugging tools accessible through the application menu.",
|
||||
"platforms": ["darwin", "win32", "linux"],
|
||||
"value": false
|
||||
}
|
||||
],
|
||||
"clientStyles": ["client.css"]
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user