plugins icon indicating copy to clipboard operation
plugins copied to clipboard

🧩 logseq.App.onThemeModeChanged

Open utterances-bot opened this issue 2 years ago • 1 comments

https://plugins-doc.logseq.com/logseq/App/onThemeModeChanged

utterances-bot avatar May 31 '23 04:05 utterances-bot

Get theme color from DOM

let background; //background-color
let color; //color
  const rootThemeColor = () => {
    const root = parent.document.querySelector(":root");
    if (root) {
      const rootStyles = getComputedStyle(root);
      background = rootStyles.getPropertyValue("--ls-block-properties-background-color") || "#ffffff";
      color = rootStyles.getPropertyValue("--ls-primary-text-color") || "#000000";
    }
  };
  rootThemeColor();
  logseq.App.onThemeModeChanged(() => { rootThemeColor(); });

  //Credit: YU000jp

https://github.com/YU000jp/logseq-plugin-weekdays-and-weekends/blob/34e65b3a0f53062938e513110c15641a39a8112d/src/index.ts#L17

YU000jp avatar May 31 '23 04:05 YU000jp