mirror of
https://github.com/notion-enhancer/notion-enhancer.git
synced 2025-04-09 15:09:02 +00:00
tweak: responsive columns breakpoint (%)
This commit is contained in:
parent
6aacd075fb
commit
4fa312c19b
@ -10,7 +10,7 @@ import { fmt, web, registry, components } from '../../api/_.mjs';
|
|||||||
import { notifications } from './launcher.mjs';
|
import { notifications } from './launcher.mjs';
|
||||||
const profileDB = await registry.profileDB();
|
const profileDB = await registry.profileDB();
|
||||||
|
|
||||||
export const cards = {
|
export const modComponents = {
|
||||||
preview: (url) => web.html`<img
|
preview: (url) => web.html`<img
|
||||||
class="mod-preview"
|
class="mod-preview"
|
||||||
src="${web.escape(url)}"
|
src="${web.escape(url)}"
|
||||||
@ -57,7 +57,7 @@ export const cards = {
|
|||||||
export const options = {
|
export const options = {
|
||||||
toggle: async (mod, opt) => {
|
toggle: async (mod, opt) => {
|
||||||
const checked = await profileDB.get([mod.id, opt.key], opt.value),
|
const checked = await profileDB.get([mod.id, opt.key], opt.value),
|
||||||
$toggle = blocks.toggle(opt.label, checked),
|
$toggle = modComponents.toggle(opt.label, checked),
|
||||||
$tooltip = web.html`${await components.feather('info', { class: 'input-tooltip' })}`,
|
$tooltip = web.html`${await components.feather('info', { class: 'input-tooltip' })}`,
|
||||||
$label = $toggle.children[0],
|
$label = $toggle.children[0],
|
||||||
$input = $toggle.children[1];
|
$input = $toggle.children[1];
|
||||||
|
@ -11,7 +11,7 @@ import './styles.mjs';
|
|||||||
|
|
||||||
import { env, fs, storage, registry, web, components } from '../../api/_.mjs';
|
import { env, fs, storage, registry, web, components } from '../../api/_.mjs';
|
||||||
import { notifications } from './launcher.mjs';
|
import { notifications } from './launcher.mjs';
|
||||||
import { cards, options } from './components.mjs';
|
import { modComponents, options } from './components.mjs';
|
||||||
|
|
||||||
const db = await registry.db('a6621988-551d-495a-97d8-3c568bca2e9e'),
|
const db = await registry.db('a6621988-551d-495a-97d8-3c568bca2e9e'),
|
||||||
profileName = await registry.profileName(),
|
profileName = await registry.profileName(),
|
||||||
@ -200,7 +200,7 @@ const _$modListCache = {},
|
|||||||
},
|
},
|
||||||
mod: async (mod) => {
|
mod: async (mod) => {
|
||||||
const $mod = web.html`<div class="mod" data-id="${web.escape(mod.id)}"></div>`,
|
const $mod = web.html`<div class="mod" data-id="${web.escape(mod.id)}"></div>`,
|
||||||
$toggle = cards.toggle('', await registry.enabled(mod.id));
|
$toggle = modComponents.toggle('', await registry.enabled(mod.id));
|
||||||
$toggle.addEventListener('change', async (event) => {
|
$toggle.addEventListener('change', async (event) => {
|
||||||
if (event.target.checked && mod.tags.includes('theme')) {
|
if (event.target.checked && mod.tags.includes('theme')) {
|
||||||
const mode = mod.tags.includes('light') ? 'light' : 'dark',
|
const mode = mod.tags.includes('light') ? 'light' : 'dark',
|
||||||
@ -229,8 +229,8 @@ const _$modListCache = {},
|
|||||||
}
|
}
|
||||||
$mod.className = 'mod-selected';
|
$mod.className = 'mod-selected';
|
||||||
const fragment = [
|
const fragment = [
|
||||||
web.render(cards.title(mod.name), cards.version(mod.version)),
|
web.render(modComponents.title(mod.name), modComponents.version(mod.version)),
|
||||||
cards.tags(mod.tags),
|
modComponents.tags(mod.tags),
|
||||||
await generators.options(mod),
|
await generators.options(mod),
|
||||||
];
|
];
|
||||||
web.render(web.empty($options), ...fragment);
|
web.render(web.empty($options), ...fragment);
|
||||||
@ -240,7 +240,7 @@ const _$modListCache = {},
|
|||||||
web.render(
|
web.render(
|
||||||
$mod,
|
$mod,
|
||||||
mod.preview
|
mod.preview
|
||||||
? cards.preview(
|
? modComponents.preview(
|
||||||
mod.preview.startsWith('http')
|
mod.preview.startsWith('http')
|
||||||
? mod.preview
|
? mod.preview
|
||||||
: fs.localPath(`repo/${mod._dir}/${mod.preview}`)
|
: fs.localPath(`repo/${mod._dir}/${mod.preview}`)
|
||||||
@ -248,10 +248,10 @@ const _$modListCache = {},
|
|||||||
: '',
|
: '',
|
||||||
web.render(
|
web.render(
|
||||||
web.html`<div class="mod-body"></div>`,
|
web.html`<div class="mod-body"></div>`,
|
||||||
web.render(cards.title(mod.name), cards.version(mod.version)),
|
web.render(modComponents.title(mod.name), modComponents.version(mod.version)),
|
||||||
cards.tags(mod.tags),
|
modComponents.tags(mod.tags),
|
||||||
cards.description(mod.description),
|
modComponents.description(mod.description),
|
||||||
cards.authors(mod.authors),
|
modComponents.authors(mod.authors),
|
||||||
mod.environments.includes(env.name) && !registry.core.includes(mod.id)
|
mod.environments.includes(env.name) && !registry.core.includes(mod.id)
|
||||||
? $toggle
|
? $toggle
|
||||||
: ''
|
: ''
|
||||||
|
@ -16,10 +16,16 @@ export default async function (api, db) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const responsiveBreakpoint = await db.get(['tweak.responsive_breakpoint']),
|
const responsiveBreakpointPx = await db.get(['tweak.responsive_breakpoint_px']),
|
||||||
|
responsiveBreakpointPercent =
|
||||||
|
screen.width * 0.01 * (await db.get(['tweak.responsive_breakpoint_percent'])),
|
||||||
addResponsiveBreakpoint = () => {
|
addResponsiveBreakpoint = () => {
|
||||||
document.body.classList.remove('enhancer--tweak-responsive_breakpoint');
|
document.body.classList.remove('enhancer--tweak-responsive_breakpoint');
|
||||||
if (window.innerWidth <= responsiveBreakpoint) {
|
console.log(responsiveBreakpointPercent, window.innerWidth);
|
||||||
|
if (
|
||||||
|
window.innerWidth <= responsiveBreakpointPx ||
|
||||||
|
window.innerWidth <= responsiveBreakpointPercent
|
||||||
|
) {
|
||||||
document.body.classList.add('enhancer--tweak-responsive_breakpoint');
|
document.body.classList.add('enhancer--tweak-responsive_breakpoint');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -28,11 +28,18 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "number",
|
"type": "number",
|
||||||
"key": "tweak.responsive_breakpoint",
|
"key": "tweak.responsive_breakpoint_px",
|
||||||
"label": "responsive columns breakpoint (px)",
|
"label": "responsive columns breakpoint (px)",
|
||||||
"tooltip": "the **width in pixels below which in-page columns are resized** to appear full-width to reduce content squishing",
|
"tooltip": "the **width in pixels below which in-page columns are resized** to appear full-width to reduce content squishing",
|
||||||
"value": 600
|
"value": 600
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "number",
|
||||||
|
"key": "tweak.responsive_breakpoint_percent",
|
||||||
|
"label": "responsive columns breakpoint (%)",
|
||||||
|
"tooltip": "the **percentage of the screen below which in-page columns are resized to appear full-width** to reduce content squishing",
|
||||||
|
"value": 30
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "toggle",
|
"type": "toggle",
|
||||||
"key": "tweak.normalise_table_scroll",
|
"key": "tweak.normalise_table_scroll",
|
||||||
|
Loading…
Reference in New Issue
Block a user