Improve Accessibility by Improve Level Card Button Label

This commit is contained in:
copecone committed 2026-05-04 00:10:04 +09:00
1 parent 214dfb498e
commit e01e628d94
6 files changed
+40 -10

No files matched your search

@@ -13,10 +13,10 @@
</section> </section>
<section class="buttons"> <section class="buttons">
<button [aria-label]="translation.common.preview"> <button [aria-label]="previewButtonLabel()">
<div class="material-symbols-outlined icon-40 button-icon">play_arrow</div> <div class="material-symbols-outlined icon-40 button-icon">play_arrow</div>
</button> </button>
<button [aria-label]="translation.common.download"> <button [aria-label]="downloadButtonLabel()">
<div class="material-symbols-outlined icon-40 button-icon">download</div> <div class="material-symbols-outlined icon-40 button-icon">download</div>
</button> </button>
</section> </section>
+16 -2
View File
@@ -7,15 +7,29 @@ import { TranslationService } from '../../services/translation.service';
templateUrl: './level-card.html', templateUrl: './level-card.html',
styleUrl: './level-card.scss', styleUrl: './level-card.scss',
host: { host: {
tabindex: '0', role: 'article',
}, },
}) })
export class LevelCard { export class LevelCard {
protected translation = inject(TranslationService).translation; private translationSvc = inject(TranslationService);
protected translation = this.translationSvc.translation;
artist = input.required<string>(); artist = input.required<string>();
trackName = input.required<string>(); trackName = input.required<string>();
creator = input<string[]>([]); creator = input<string[]>([]);
creatorString = computed(() => this.creator().join(' & ')); creatorString = computed(() => this.creator().join(' & '));
previewButtonLabel = computed(() =>
this.translationSvc.interpolate(this.translation.levelCard.preview, {
artist: this.artist(),
trackName: this.trackName(),
}),
);
downloadButtonLabel = computed(() =>
this.translationSvc.interpolate(this.translation.levelCard.download, {
creator: this.creatorString()
}),
);
} }
+4 -2
View File
@@ -22,8 +22,10 @@ export const EN = {
close: 'Close', close: 'Close',
save: 'Save', save: 'Save',
skipToContent: 'Skip to main content', skipToContent: 'Skip to main content',
preview: 'Soundtrack Preview', },
download: 'Download', levelCard: {
preview: '{{trackName}} by {{artist}} Preview',
download: "{{creator}}'s Level Download",
}, },
}; };
+4 -2
View File
@@ -24,7 +24,9 @@ export const JP: Translation = {
close: '閉じる', close: '閉じる',
save: '保存', save: '保存',
skipToContent: '本文へスキップ', skipToContent: '本文へスキップ',
preview: '楽曲プレビュー', },
download: 'ダウンロード', levelCard: {
preview: '{{artist}}の{{trackName}} プレビュー',
download: '{{creator}}のレベルをダウンロード',
}, },
}; };
+4 -2
View File
@@ -24,7 +24,9 @@ export const KR: Translation = {
close: '닫기', close: '닫기',
save: '저장', save: '저장',
skipToContent: '본문으로 건너뛰기', skipToContent: '본문으로 건너뛰기',
preview: '곡 프리뷰', },
download: '다운로드', levelCard: {
preview: '{{artist}}의 {{trackName}} 미리듣기',
download: `{{creator}}의 레벨 다운로드`,
}, },
}; };
+10
View File
@@ -29,4 +29,14 @@ export class TranslationService {
readonly translation = new Proxy({} as Translation, { readonly translation = new Proxy({} as Translation, {
get: (_, prop) => this._translation()[prop as keyof Translation] get: (_, prop) => this._translation()[prop as keyof Translation]
}); });
/**
* 문자열 내의 플레이스홀더(예: {{name}})를 실제 값으로 치환합니다.
*/
interpolate(text: string, params: Record<string, string | number>): string {
return Object.entries(params).reduce(
(acc, [key, value]) => acc.replace(new RegExp(`{{${key}}}`, 'g'), String(value)),
text
);
}
} }