diff --git a/src/app/components/dropdown/dropdown.html b/src/app/components/dropdown/dropdown.html
index a5faeb0..17a0789 100644
--- a/src/app/components/dropdown/dropdown.html
+++ b/src/app/components/dropdown/dropdown.html
@@ -7,11 +7,12 @@
@if (isOpen()) {
-
+
@for (option of normalizedOptions(); track option.value; let i = $index) {
- = 0 ? dropdownId + '-option-' + focusedIndex() : null",
+ '[attr.aria-label]': 'ariaLabel()',
'[class.open]': 'isOpen()',
'tabindex': '0',
'(click)': 'toggle()',
@@ -30,6 +33,7 @@ export interface DropdownOption {
export class Dropdown {
options = input>([]);
placeholder = input('Select an option');
+ ariaLabel = input(undefined);
icon = input();
value = model(null);
selectionChange = output();
@@ -37,6 +41,9 @@ export class Dropdown {
isOpen = signal(false);
focusedIndex = signal(-1);
+ private static nextId = 0;
+ dropdownId = `dropdown-${Dropdown.nextId++}`;
+
constructor(private el: ElementRef) {}
normalizedOptions = computed(() => {
@@ -96,7 +103,10 @@ export class Dropdown {
this.toggle();
return;
}
- this.focusedIndex.update(i => (i + 1) % this.normalizedOptions().length);
+ this.focusedIndex.update(i => {
+ if (i === -1) return 0;
+ return (i + 1) % this.normalizedOptions().length;
+ });
}
onArrowUp(event: Event) {
@@ -105,7 +115,10 @@ export class Dropdown {
this.toggle();
return;
}
- this.focusedIndex.update(i => (i - 1 + this.normalizedOptions().length) % this.normalizedOptions().length);
+ this.focusedIndex.update(i => {
+ if (i <= 0) return this.normalizedOptions().length - 1;
+ return i - 1;
+ });
}
@HostListener('document:click', ['$event'])
diff --git a/src/app/components/switch/switch.html b/src/app/components/switch/switch.html
index 8b754f8..5e0374a 100644
--- a/src/app/components/switch/switch.html
+++ b/src/app/components/switch/switch.html
@@ -1 +1 @@
-
+
diff --git a/src/app/components/switch/switch.ts b/src/app/components/switch/switch.ts
index 2e45c54..f7714c7 100644
--- a/src/app/components/switch/switch.ts
+++ b/src/app/components/switch/switch.ts
@@ -1,4 +1,4 @@
-import { Component, input, model, output } from '@angular/core'
+import { Component, input, model, output } from '@angular/core';
@Component({
selector: 'switch',
@@ -6,28 +6,28 @@ import { Component, input, model, output } from '@angular/core'
templateUrl: './switch.html',
styleUrl: './switch.scss',
host: {
- 'role': 'switch',
- 'tabindex': '0',
+ role: 'switch',
+ tabindex: '0',
'[attr.aria-checked]': 'isActive()',
'[class.active]': 'isActive()',
'[class.reduce-motion]': 'reduceMotion()',
'(click)': 'onClick()',
'(keydown.enter)': 'onClick()',
- '(keydown.space)': 'onSpaceDown($event)'
- }
+ '(keydown.space)': 'onSpaceDown($event)',
+ },
})
export class Switch {
isActive = model(false);
reduceMotion = input(
typeof window !== 'undefined'
? window.matchMedia('(prefers-reduced-motion: reduce)').matches
- : false
+ : false,
);
- toggle = output()
+ toggle = output();
onClick(): void {
- this.isActive.update(value => !value)
- this.onToggle()
+ this.isActive.update((value) => !value);
+ this.onToggle();
}
onSpaceDown(event: Event): void {
@@ -36,6 +36,6 @@ export class Switch {
}
onToggle(): void {
- this.toggle.emit(this.isActive())
+ this.toggle.emit(this.isActive());
}
}
diff --git a/src/styles.scss b/src/styles.scss
index cefa5a4..f13860e 100644
--- a/src/styles.scss
+++ b/src/styles.scss
@@ -1,8 +1,9 @@
-C@import url('https://cdn.jsdelivr.net/npm/nanumsquareneo@0.0.5/nanumsquareneo.css');
+@import url('https://cdn.jsdelivr.net/npm/nanumsquareneo@0.0.5/nanumsquareneo.css');
@import url('https://cdn.jsdelivr.net/gh/wanteddev/wanted-sans@v1.0.1/packages/wanted-sans/fonts/webfonts/variable/split/WantedSansVariable.min.css');
+@import url("https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/static/pretendard-jp-dynamic-subset.min.css");
body {
- font-family: 'NanumSquareNeo', 'Wanted Sans Variable', sans-serif;
+ font-family: 'NanumSquareNeo', 'Wanted Sans Variable', 'Pretendard JP', sans-serif;
font-weight: 500;
margin: 0;
}