-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(settings): nerd font feature toggeler
- Loading branch information
Showing
6 changed files
with
104 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
:root { | ||
--icon-font: 'Fira Code Nerd Font', 'Fira Code', 'Fira Sans'; | ||
} | ||
|
||
@font-face { | ||
font-family: "Fira Code Nerd Font"; | ||
font-style: normal; | ||
font-weight: 400; | ||
font-display: swap; | ||
src: url('/fonts/fira-code-nerd-regular.ttf') format('truetype'); | ||
} | ||
|
||
|
||
/* | ||
>>> BEGIN: Nerd icons | ||
*/ | ||
.desc-item[data-key="featureJournalIcon"] .form-input, | ||
.page-icon, | ||
.is-icon-active .page>.relative>.flex-row>.flex-1::before { | ||
font-family: var(--icon-font); | ||
} | ||
/* | ||
<<<< END: Nerd icons | ||
*/ | ||
|
||
|
||
/* | ||
>>> BEGIN: Props | ||
*/ | ||
.pre-block > .flex-row .editor-wrapper textarea, | ||
.page-properties, | ||
.block-properties { | ||
font-family: var(--icon-font); | ||
font-size: 0.9rem; | ||
letter-spacing: -1px; | ||
word-spacing: -1px; | ||
} | ||
/* | ||
<<<< END: Props | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
export * from './linksObserver'; | ||
|
||
export * from './pageIcons'; | ||
export * from './nerdFont'; | ||
export * from './journalIcons'; | ||
export * from './favIcons'; | ||
export * from './titleIcon'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import globalContext from './globals'; | ||
import { doc } from './DOMContainers'; | ||
|
||
import nerdFontsStyles from '../../css/nerdFont.css?inline'; | ||
|
||
export const toggleNerdFonFeature = () => { | ||
if (globalContext.pluginConfig?.featureNerdFontEnabled) { | ||
nerdFontLoad(); | ||
} else { | ||
nerdFontUnload(); | ||
} | ||
} | ||
|
||
export const nerdFontLoad = () => { | ||
if (!globalContext.pluginConfig?.featureNerdFontEnabled) { | ||
return; | ||
} | ||
setTimeout(() => { | ||
const tabsPluginIframe = doc.getElementById('logseq-tabs_iframe') as HTMLIFrameElement; | ||
if (tabsPluginIframe) { | ||
tabsPluginIframe.contentDocument?.head.insertAdjacentHTML( | ||
'beforeend', | ||
`<style id="awesomeLinks"> | ||
@font-face { | ||
font-family: "Fira Code Nerd Font"; | ||
font-style: normal; | ||
font-weight: 400; | ||
src: url('lsp://logseq.io/${globalContext.pluginID}/dist/fonts/fira-code-nerd-regular.ttf') format('truetype'); | ||
} | ||
.logseq-tab .text-xs { | ||
font-family: "Fira Code Nerd Font"; | ||
} | ||
</style>` | ||
); | ||
} | ||
logseq.provideStyle({ key: 'awLi-nerd-font-css', style: nerdFontsStyles }); | ||
}, 1000) | ||
} | ||
|
||
export const nerdFontUnload = () => { | ||
const tabsPluginIframe = doc.getElementById('logseq-tabs_iframe') as HTMLIFrameElement; | ||
if (tabsPluginIframe) { | ||
tabsPluginIframe.contentDocument?.getElementById('awesomeLinks')?.remove(); | ||
} | ||
doc.head.querySelector(`style[data-injected-style="awLi-nerd-font-css-${globalContext.pluginID}"]`)?.remove(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters