DEV: convert keyboard-shortcuts-help to gjs (#29831)

This commit is contained in:
Joffrey JAFFEUX 2024-11-19 23:25:02 +01:00 committed by GitHub
parent ad034a5947
commit a8ca82b11f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 35 additions and 29 deletions

View File

@ -1,5 +1,8 @@
import Component from "@glimmer/component";
import { concat } from "@ember/helper";
import { service } from "@ember/service";
import { htmlSafe } from "@ember/template";
import DModal from "discourse/components/d-modal";
import { extraKeyboardShortcutsHelp } from "discourse/lib/keyboard-shortcuts";
import { translateModKey } from "discourse/lib/utilities";
import { i18n } from "discourse-i18n";
@ -353,4 +356,36 @@ export default class KeyboardShortcutsHelp extends Component {
});
return shortcuts;
}
<template>
<DModal
@title={{i18n "keyboard_shortcuts_help.title"}}
@closeModal={{@closeModal}}
class="keyboard-shortcuts-modal -max"
>
<:body>
<div id="keyboard-shortcuts-help">
<div class="keyboard-shortcuts-help__container">
<span tabindex="0"></span>
{{! A11Y, allows keyboard users to scroll modal body }}
{{#each-in this.shortcuts as |category shortcutCategory|}}
<section
class="shortcut-category span-{{shortcutCategory.count}}
shortcut-category-{{category}}"
>
<h2>{{i18n
(concat "keyboard_shortcuts_help." category ".title")
}}</h2>
<ul>
{{#each-in shortcutCategory.shortcuts as |name shortcut|}}
<li>{{htmlSafe shortcut}}</li>
{{/each-in}}
</ul>
</section>
{{/each-in}}
</div>
</div>
</:body>
</DModal>
</template>
}

View File

@ -1,29 +0,0 @@
<DModal
@title={{i18n "keyboard_shortcuts_help.title"}}
@closeModal={{@closeModal}}
class="keyboard-shortcuts-modal -max"
>
<:body>
<div id="keyboard-shortcuts-help">
<div class="keyboard-shortcuts-help__container">
<span tabindex="0"></span>
{{! A11Y, allows keyboard users to scroll modal body }}
{{#each-in this.shortcuts as |category shortcutCategory|}}
<section
class="shortcut-category span-{{shortcutCategory.count}}
shortcut-category-{{category}}"
>
<h2>{{i18n
(concat "keyboard_shortcuts_help." category ".title")
}}</h2>
<ul>
{{#each-in shortcutCategory.shortcuts as |name shortcut|}}
<li>{{html-safe shortcut}}</li>
{{/each-in}}
</ul>
</section>
{{/each-in}}
</div>
</div>
</:body>
</DModal>