Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: yoyurec/logseq-awesome-ui
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v2.3.3
Choose a base ref
...
head repository: yoyurec/logseq-awesome-ui
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v2.3.4
Choose a head ref
  • 2 commits
  • 5 files changed
  • 2 contributors

Commits on Oct 19, 2023

  1. Copy the full SHA
    4c200bf View commit details
  2. chore(release): 2.3.4 [skip ci]

    ## [2.3.4](v2.3.3...v2.3.4) (2023-10-19)
    
    ### Bug Fixes
    
    * **agenda:** agenda plugin checking ([4c200bf](4c200bf))
    semantic-release-bot committed Oct 19, 2023
    Copy the full SHA
    4cb2975 View commit details
Showing with 66 additions and 45 deletions.
  1. +7 −0 CHANGELOG.md
  2. +1 −1 package.json
  3. +53 −39 src/modules/extPlugins/calendar/calendar.ts
  4. +3 −3 src/plugin/plugin.ts
  5. +2 −2 src/plugin/settings.ts
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## [2.3.4](https://github.com/yoyurec/logseq-awesome-ui/compare/v2.3.3...v2.3.4) (2023-10-19)


### Bug Fixes

* **agenda:** agenda plugin checking ([4c200bf](https://github.com/yoyurec/logseq-awesome-ui/commit/4c200bfc17abb599f87ec6f4d61a2dc27871d8f9))

## [2.3.3](https://github.com/yoyurec/logseq-awesome-ui/compare/v2.3.2...v2.3.3) (2023-10-17)


2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "logseq-awesome-ui",
"description": "Reworked, simplified, fixed and pumped-up Logseq! Layout, components, etc...",
"version": "2.3.3",
"version": "2.3.4",
"author": "yoyurec <yoyurec@gmail.com>",
"main": "dist/index.html",
"scripts": {
92 changes: 53 additions & 39 deletions src/modules/extPlugins/calendar/calendar.ts
Original file line number Diff line number Diff line change
@@ -3,37 +3,63 @@ import { root, doc, globals } from '../../globals/globals';
import calendarStyles from './calendar.css?inline';

let sidebarCalendarButton: HTMLElement | null = null;
let agendaPlugin: HTMLElement | null = null;

const calendarPagePath = '/page/calendar'

export const menuCalendarToggle = () => {
export const calendarToggle = () => {
if (globals.pluginConfig.menuCalendar) {
menuCalendarLoad();
calendarLoad();
} else {
menuCalendarUnload();
calendarUnload();
}
}

export const menuCalendarLoad = () => {
export const calendarLoad = () => {
addCalendarButtonToSidebar();

// Agenda plugin integration
loadAgenda();
}

export const calendarUnload = () => {
doc.head.querySelector(`style[data-injected-style^="--awUi-calendar-css"]`)?.remove();
doc.querySelector('.nav-header .calendar-nav')?.remove();
}

const addCalendarButtonToSidebar = () => {
const journalsButton = doc.querySelector('.nav-header .journals-nav');
const calendarButtonHTML = `
<div class="calendar-nav">
<a href="#${calendarPagePath}" class="item group flex items-center text-sm font-medium rounded-md" id="--awUi-calendar-menu">
<span class="ui__icon ti ls-icon-calendar-time">
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="20" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" viewBox="0 0 24 24"><path stroke="none" d="M0 0h24v24H0z"></path><path d="M11 21H6a2 2 0 0 1-2-2V7a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v3.5M16 3v4M8 3v4M4 11h11"></path><path d="M17.8 20.8 15.6 22a.4.4 0 0 1-.5-.5l.4-2.4-1.8-1.7a.4.4 0 0 1 .2-.6l2.5-.4 1-2.2a.4.4 0 0 1 .8 0l1 2.2 2.5.4a.4.4 0 0 1 .2.6L20 19.1l.4 2.4a.4.4 0 0 1-.5.5l-2.2-1.2z"></path></svg>
</span>
<span class="flex-1">Calendar</span>
</a>
</div>
`;
journalsButton?.insertAdjacentHTML('afterend', calendarButtonHTML);
}

const loadAgenda = () => {
const agendaPluginIframe = doc.getElementById('logseq-agenda_iframe') as HTMLElement;
if (!agendaPluginIframe) {
console.log('AwesomeUi: agenda plugin not found!');
return;
}

// add Agenda popup styles
logseq.provideStyle({ key: '--awUi-calendar-css', style: calendarStyles });
// show on 1st load

// show on 1st load if opened page is "#calendar"
if (window.parent.location.hash.toLowerCase() === `#${calendarPagePath}`) {
setTimeout(() => {
showAgendaPlugin();
}, 1000);
}

agendaPlugin = doc.getElementById('logseq-agenda_lsp_main') as HTMLElement;
if (!agendaPlugin) {
console.log('AwesomeUi: agenda plugin not found!');
return;
}
updateAgendaPopupSizeOnSidebarsToggle();

sidebarCalendarButton = doc.getElementById('--awUi-calendar-menu');
const leftSidebartoggleBtn = doc.getElementById('left-menu');
leftSidebartoggleBtn!.addEventListener('click', setSidebarWidthVar);
logseq.App.onRouteChanged(({ path }) => {
if (globals.pluginConfig.menuCalendar) {
if (path.toLowerCase() === calendarPagePath) {
@@ -43,23 +69,26 @@ export const menuCalendarLoad = () => {
}
}
});
}

const updateAgendaPopupSizeOnSidebarsToggle = () => {
// left sidebar
sidebarCalendarButton = doc.getElementById('--awUi-calendar-menu');
const leftSidebartoggleBtn = doc.getElementById('left-menu');
leftSidebartoggleBtn!.addEventListener('click', setAgendaPopupCSSVars);

// right sidebar
logseq.App.onSidebarVisibleChanged(() => {
setSidebarWidthVar();
setAgendaPopupCSSVars();
});
}

export const menuCalendarUnload = () => {
doc.head.querySelector(`style[data-injected-style^="--awUi-calendar-css"]`)?.remove();
doc.querySelector('.nav-header .calendar-nav')?.remove();
}


const showAgendaPlugin = async () => {
setSidebarWidthVar();
if (agendaPlugin && sidebarCalendarButton) {
setAgendaPopupCSSVars();
if (sidebarCalendarButton) {
await logseq.App.invokeExternalPlugin('logseq-agenda.models.show');
sidebarCalendarButton.classList.add('active');
// unfocus iframe to fix hotkeys navigation
setTimeout(() => {
doc.getElementById('logseq-agenda_iframe')?.blur();
}, 150);
@@ -71,22 +100,7 @@ const hideAgendaPlugin = () => {
sidebarCalendarButton?.classList.remove('active');
}

const addCalendarButtonToSidebar = () => {
const journalsButton = doc.querySelector('.nav-header .journals-nav');
const calendarButtonHTML = `
<div class="calendar-nav">
<a href="#${calendarPagePath}" class="item group flex items-center text-sm font-medium rounded-md" id="--awUi-calendar-menu">
<span class="ui__icon ti ls-icon-calendar-time">
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="20" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" viewBox="0 0 24 24"><path stroke="none" d="M0 0h24v24H0z"></path><path d="M11 21H6a2 2 0 0 1-2-2V7a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v3.5M16 3v4M8 3v4M4 11h11"></path><path d="M17.8 20.8 15.6 22a.4.4 0 0 1-.5-.5l.4-2.4-1.8-1.7a.4.4 0 0 1 .2-.6l2.5-.4 1-2.2a.4.4 0 0 1 .8 0l1 2.2 2.5.4a.4.4 0 0 1 .2.6L20 19.1l.4 2.4a.4.4 0 0 1-.5.5l-2.2-1.2z"></path></svg>
</span>
<span class="flex-1">Calendar</span>
</a>
</div>
`;
journalsButton?.insertAdjacentHTML('afterend', calendarButtonHTML);
}

const setSidebarWidthVar = () => {
const setAgendaPopupCSSVars = () => {
setTimeout(() => {
let leftSidebarWidth;
if (doc.getElementById('left-sidebar')?.classList.contains('is-open')) {
6 changes: 3 additions & 3 deletions src/plugin/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { doc, body, globals } from '../modules/globals/globals';

import { menuCalendarToggle, menuCalendarUnload } from '../modules/extPlugins/calendar/calendar';
import { calendarToggle, calendarUnload } from '../modules/extPlugins/calendar/calendar';
import { setFeaturesCSSVars } from '../modules/features/features';
import { headerLoad, headerUnload } from '../modules/header/headerVariant';
import { searchStyleToggle, searchStyleUnload } from '../modules/header/searchStyle';
@@ -71,7 +71,7 @@ const runStuff = () => {
setFeaturesCSSVars();
compactSidebarMenuToggle();
hideRightSidebarToolbarToggle();
menuCalendarToggle();
calendarToggle();
headerLoad();
navigationPositionLoad();
searchStyleToggle();
@@ -86,7 +86,7 @@ const stopStuff = () => {
compactSidebarMenuUnload();
hideRightSidebarToolbarUnload();
rightSidebarUnload();
menuCalendarUnload();
calendarUnload();
headerUnload();
navigationPositionUnload();
searchStyleUnload();
4 changes: 2 additions & 2 deletions src/plugin/settings.ts
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ import { globals } from '../modules/globals/globals';

import { settingsConfig } from './settingsConfig';
import { headerVariantToggle } from '../modules/header/headerVariant';
import { menuCalendarToggle } from '../modules/extPlugins/calendar/calendar';
import { calendarToggle } from '../modules/extPlugins/calendar/calendar';
import { compactSidebarMenuToggle } from '../modules/sidebars/compactSidebarMenu/compactSidebarMenu';
import { setFeaturesCSSVars } from '../modules/features/features';
import { hideRightSidebarToolbarToggle } from '../modules/sidebars/hideRightSidebarToolbar/hideRightSidebarToolbar';
@@ -52,7 +52,7 @@ export const onSettingsChangedCallback = (settings: LSPluginBaseInfo['settings']
searchStyleToggle();
}
if (settingsChangedKey.includes('menuCalendar')) {
menuCalendarToggle();
calendarToggle();
}
if (settingsChangedKey.includes('compactSidebarMenu')) {
compactSidebarMenuToggle();