-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
33 changed files
with
700 additions
and
469 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
35 changes: 35 additions & 0 deletions
35
apps/frontend/src/app/directives/font-size-lerp.directive.ts
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,35 @@ | ||
import { Directive, HostBinding, Input, OnChanges } from '@angular/core'; | ||
|
||
/** | ||
* Doing this automatically is so annoying, and requires fucking with the DOM | ||
* more than I like. | ||
* | ||
* There's some Angular directives out there that supposedly do it, but | ||
* I couldn't get them working, and I don't like doing this kind of dynamic | ||
* sizing anyway. | ||
* | ||
* https://github.com/sollenne/angular-fittext | ||
* https://github.com/thisloke/ng2-fittext | ||
*/ | ||
@Directive({ selector: '[fontSizeLerp]', standalone: true }) | ||
export class FontSizeLerpDirective implements OnChanges { | ||
@Input('fontSizeLerp') options: { | ||
chars: number; | ||
maxChars: number; | ||
startAt: number; | ||
baseRem: number; | ||
minRem: number; | ||
}; | ||
|
||
@HostBinding('style.font-size') fontSize: string; | ||
|
||
ngOnChanges() { | ||
const { chars, maxChars, startAt, baseRem, minRem } = this.options; | ||
let val = baseRem; | ||
if (chars > startAt) { | ||
const k = (chars - startAt) / (maxChars - startAt); | ||
val -= (baseRem - minRem) * k; | ||
} | ||
this.fontSize = `${val}rem`; | ||
} | ||
} |
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
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
Oops, something went wrong.