From 0b0f5cee373c29173278a0b7f3b0707e191d0df0 Mon Sep 17 00:00:00 2001 From: TZGyn Date: Wed, 24 Jul 2024 23:33:18 +0800 Subject: [PATCH] update select label + added global functions for String type --- frontend/src/app.d.ts | 4 +++ .../components/ui/select/select-item.svelte | 34 +++++++++---------- frontend/src/lib/utils.ts | 9 +++++ 3 files changed, 29 insertions(+), 18 deletions(-) diff --git a/frontend/src/app.d.ts b/frontend/src/app.d.ts index e2cf130..56235ab 100644 --- a/frontend/src/app.d.ts +++ b/frontend/src/app.d.ts @@ -109,6 +109,10 @@ declare global { } } } + interface String { + removeUnderscores(): string + capitalize(): string + } } export {} diff --git a/frontend/src/lib/components/ui/select/select-item.svelte b/frontend/src/lib/components/ui/select/select-item.svelte index 2cd00a7..a1ee270 100644 --- a/frontend/src/lib/components/ui/select/select-item.svelte +++ b/frontend/src/lib/components/ui/select/select-item.svelte @@ -1,16 +1,16 @@ - + on:pointermove> + - - {label || value} - + diff --git a/frontend/src/lib/utils.ts b/frontend/src/lib/utils.ts index aee0a8c..159b301 100644 --- a/frontend/src/lib/utils.ts +++ b/frontend/src/lib/utils.ts @@ -69,3 +69,12 @@ export const flyAndScale = ( easing: cubicOut, } } + +// this works because its imported in the root layout by other components +String.prototype.removeUnderscores = function () { + return this.replace(/_/g, ' ') +} + +String.prototype.capitalize = function () { + return this.charAt(0).toUpperCase() + this.slice(1) +}