refactor(frontend): make terminology of cheatsheet more clear

Also add additional documentation to explain how cheatsheets work

Signed-off-by: Philip Molares <philip.molares@udo.edu>
This commit is contained in:
Philip Molares 2023-06-28 22:44:09 +02:00
parent 81927b88f2
commit 7a365acdb9
11 changed files with 61 additions and 45 deletions

View file

@ -9,19 +9,40 @@ export interface CheatsheetExtensionComponentProps {
setContent: (dispatcher: string | ((prevState: string) => string)) => void
}
export type CheatsheetExtension = CheatsheetEntry | CheatsheetGroup
export type CheatsheetExtension = CheatsheetSingleEntry | CheatsheetEntryWithTopics
export const isCheatsheetGroup = (extension: CheatsheetExtension | undefined): extension is CheatsheetGroup => {
return (extension as CheatsheetGroup)?.entries !== undefined
/**
* Determine if a given {@link CheatsheetExtension} is a {@link CheatsheetEntryWithTopics} or just a {@link CheatsheetSingleEntry}.
*
* @param extension The extension in question
* @return boolean
*/
export const hasCheatsheetTopics = (
extension: CheatsheetExtension | undefined
): extension is CheatsheetEntryWithTopics => {
return (extension as CheatsheetEntryWithTopics)?.topics !== undefined
}
export interface CheatsheetGroup {
/**
* This is an entry with just a name and a bunch of different topics to discuss.
*
* e.g 'basics.headlines' with the topics 'hashtag' and 'equal'
*/
export interface CheatsheetEntryWithTopics {
i18nKey: string
categoryI18nKey?: string
entries: CheatsheetEntry[]
topics: CheatsheetSingleEntry[]
}
export interface CheatsheetEntry {
/**
* This is an entry that describes something completely.
*
* In the translations you'll find both 'description' containing an explanation and 'example' containing a demonstration in markdown under the i18nKey.
* If this entry is a topic of some other entry the i18nKey needs to be prefixed with the i18nKey of the other entry.
*
* e.g 'basics.basicFormatting'
*/
export interface CheatsheetSingleEntry {
i18nKey: string
categoryI18nKey?: string
cheatsheetExtensionComponent?: React.FC<CheatsheetExtensionComponentProps>