mirror of
https://github.com/zadam/trilium.git
synced 2025-12-31 19:54:25 +01:00
chore(icon_pack): generate icon declarations
This commit is contained in:
parent
93a3b29677
commit
5f1bdf7264
@ -133,5 +133,7 @@ describe("CSS generation", () => {
|
||||
|
||||
expect(css).toContain("@font-face");
|
||||
expect(css).toContain("font-family: 'trilium-icon-pack-bx' !important;");
|
||||
expect(css).toContain(".bx.bx-ball::before { content: '\\e9c2'; }");
|
||||
expect(css).toContain(".bx.bxs-party::before { content: '\\ec92'; }");
|
||||
});
|
||||
});
|
||||
|
||||
@ -62,17 +62,22 @@ export function determineBestFontAttachment(iconPackNote: BNote) {
|
||||
return null;
|
||||
}
|
||||
|
||||
export function generateCss(processedIconPack: ProcessResult) {
|
||||
export function generateCss({ manifest, fontAttachmentId, fontMime }: ProcessResult) {
|
||||
const iconDeclarations: string[] = [];
|
||||
for (const [ key, mapping ] of Object.entries(manifest.icons)) {
|
||||
iconDeclarations.push(`.${manifest.prefix}.${key}::before { content: '\\${mapping.charCodeAt(0).toString(16)}' }`);
|
||||
}
|
||||
|
||||
return `\
|
||||
@font-face {
|
||||
font-family: 'trilium-icon-pack-${processedIconPack.manifest.prefix}';
|
||||
font-family: 'trilium-icon-pack-${manifest.prefix}';
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
src: url('/api/attachments/${processedIconPack.fontAttachmentId}/download') format('${MIME_TO_CSS_FORMAT_MAPPINGS[processedIconPack.fontMime]}');
|
||||
src: url('/api/attachments/${fontAttachmentId}/download') format('${MIME_TO_CSS_FORMAT_MAPPINGS[fontMime]}');
|
||||
}
|
||||
|
||||
.${processedIconPack.manifest.prefix} {
|
||||
font-family: 'trilium-icon-pack-${processedIconPack.manifest.prefix}' !important;
|
||||
.${manifest.prefix} {
|
||||
font-family: 'trilium-icon-pack-${manifest.prefix}' !important;
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
font-variant: normal;
|
||||
@ -83,5 +88,7 @@ export function generateCss(processedIconPack: ProcessResult) {
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
|
||||
${iconDeclarations.join("\n")}
|
||||
`;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user