Skip to content

Commit 781df11

Browse files
committed
add dynamic font preview - font buttons display in their own font family
1 parent f9c242c commit 781df11

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

src/components/forms/fonts-form/fonts-form.component.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Component, computed, inject } from '@angular/core';
22
import { CommonModule } from '@angular/common';
33
import { FormsModule } from '@angular/forms';
4-
import { FontPresetsService } from '../../../services/font-presets.service';
4+
import { FontPresetsService, FontPreset } from '../../../services/font-presets.service';
55
import { NumberInputComponent } from '../../shared/number-input/number-input.component';
66
import { VersionBadgeComponent } from '../../shared/version-badge/version-badge.component';
77
import { SliderInputComponent } from '../../shared/slider-input/slider-input.component';
@@ -27,11 +27,13 @@ import { KittyVersionService } from '../../../services/kitty-version.service';
2727
<button
2828
type="button"
2929
(click)="selectFont(font.family)"
30+
(mouseenter)="fontPresetsService.loadWebFont(font.family)"
3031
[class.bg-kitty-primary]="fonts().font_family === font.family"
3132
[class.text-kitty-dark]="fonts().font_family === font.family"
3233
[class.bg-kitty-surface-light]="fonts().font_family !== font.family"
3334
[class.text-kitty-text]="fonts().font_family !== font.family"
34-
class="px-3 py-2 rounded-lg text-xs font-mono hover:bg-kitty-primary hover:text-kitty-dark transition-colors border border-kitty-border"
35+
class="px-3 py-2 rounded-lg text-xs hover:bg-kitty-primary hover:text-kitty-dark transition-colors border border-kitty-border"
36+
[style.font-family]="getFontFamily(font)"
3537
[title]="font.description"
3638
>{{ font.name }}</button>
3739
}
@@ -47,11 +49,13 @@ import { KittyVersionService } from '../../../services/kitty-version.service';
4749
<button
4850
type="button"
4951
(click)="selectFont(font.family)"
52+
(mouseenter)="fontPresetsService.loadWebFont(font.family)"
5053
[class.bg-kitty-primary]="fonts().font_family === font.family"
5154
[class.text-kitty-dark]="fonts().font_family === font.family"
5255
[class.bg-kitty-surface-light]="fonts().font_family !== font.family"
5356
[class.text-kitty-text]="fonts().font_family !== font.family"
54-
class="px-2 py-1.5 rounded text-xs font-mono hover:bg-kitty-primary hover:text-kitty-dark transition-colors border border-kitty-border"
57+
class="px-2 py-1.5 rounded text-xs hover:bg-kitty-primary hover:text-kitty-dark transition-colors border border-kitty-border"
58+
[style.font-family]="getFontFamily(font)"
5559
[title]="font.description"
5660
>{{ font.name }}</button>
5761
}
@@ -336,6 +340,10 @@ export class FontsFormComponent {
336340
this.helper.updateField('font_family', family);
337341
}
338342

343+
getFontFamily(font: FontPreset): string {
344+
return `"${font.family}", monospace`;
345+
}
346+
339347
setFontFeatures(value: string): void {
340348
const features = value.split('\n').filter(l => l.trim());
341349
this.helper.updateField('font_features', features);

0 commit comments

Comments
 (0)