Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/shaggy-clocks-rule.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"gitbook": patch
---

Improve screen reader accessibility for hints
10 changes: 10 additions & 0 deletions packages/gitbook/src/components/DocumentView/Hint.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { Icon, type IconName } from '@gitbook/icons';

import { type ClassValue, tcls } from '@/lib/tailwind';

import { getSpaceLanguage, tString } from '@/intl/server';
import { languages } from '@/intl/translations';
import { Block, type BlockProps } from './Block';
import { Blocks } from './Blocks';
import { getBlockTextStyle } from './spacing';
Expand All @@ -18,6 +20,12 @@ export function Hint({
const firstLine = getBlockTextStyle(firstNode);
const hasHeading = ['heading-1', 'heading-2', 'heading-3'].includes(firstNode.type);

const language = contextProps.context.contentContext
? getSpaceLanguage(contextProps.context.contentContext)
: languages.en;

const label = tString(language, `hint_${block.data.style}`);

return (
<div
className={tcls(
Expand All @@ -38,6 +46,8 @@ export function Hint({

style
)}
aria-label={label}
role="note"
>
<div
className={tcls(
Expand Down
4 changes: 4 additions & 0 deletions packages/gitbook/src/intl/translations/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,8 @@ export const de = {
tool_call_skipped: 'Übersprungen "${1}"',
scroll_back: 'Zurück scrollen',
scroll_further: 'Weiter scrollen',
hint_info: 'Information',
hint_warning: 'Warnung',
hint_danger: 'Gefahr',
hint_success: 'Erfolg',
};
4 changes: 4 additions & 0 deletions packages/gitbook/src/intl/translations/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,8 @@ export const en = {
tool_call_skipped: 'Skipped "${1}"',
scroll_back: 'Scroll back',
scroll_further: 'Scroll further',
hint_info: 'Information',
hint_warning: 'Warning',
hint_danger: 'Danger',
hint_success: 'Success',
};
4 changes: 4 additions & 0 deletions packages/gitbook/src/intl/translations/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,8 @@ export const es: TranslationLanguage = {
tool_call_skipped: 'Omitido "${1}"',
scroll_back: 'Desplazar hacia atrás',
scroll_further: 'Desplazar más',
hint_info: 'Información',
hint_warning: 'Advertencia',
hint_danger: 'Peligro',
hint_success: 'Éxito',
};
4 changes: 4 additions & 0 deletions packages/gitbook/src/intl/translations/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,8 @@ export const fr = {
tool_call_skipped: 'Ignoré "${1}"',
scroll_back: "Défiler vers l'arrière",
scroll_further: 'Défiler plus loin',
hint_info: 'Information',
hint_warning: 'Avertissement',
hint_danger: 'Danger',
hint_success: 'Succès',
};
4 changes: 4 additions & 0 deletions packages/gitbook/src/intl/translations/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,8 @@ export const ja: TranslationLanguage = {
tool_call_skipped: '"${1}" をスキップしました',
scroll_back: '戻る',
scroll_further: '進む',
hint_info: '情報',
hint_warning: '警告',
hint_danger: '危険',
hint_success: '成功',
};
4 changes: 4 additions & 0 deletions packages/gitbook/src/intl/translations/nl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,8 @@ export const nl: TranslationLanguage = {
tool_call_skipped: '"${1}" overgeslagen',
scroll_back: 'Terug scrollen',
scroll_further: 'Verder scrollen',
hint_info: 'Informatie',
hint_warning: 'Waarschuwing',
hint_danger: 'Gevaar',
hint_success: 'Succes',
};
4 changes: 4 additions & 0 deletions packages/gitbook/src/intl/translations/no.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,8 @@ export const no: TranslationLanguage = {
tool_call_skipped: 'Hoppet over "${1}"',
scroll_back: 'Rull tilbake',
scroll_further: 'Rull videre',
hint_info: 'Informasjon',
hint_warning: 'Advarsel',
hint_danger: 'Fare',
hint_success: 'Suksess',
};
4 changes: 4 additions & 0 deletions packages/gitbook/src/intl/translations/pt-br.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,8 @@ export const pt_br = {
tool_call_skipped: 'Pulado "${1}"',
scroll_back: 'Rolar para trás',
scroll_further: 'Rolar para frente',
hint_info: 'Informação',
hint_warning: 'Aviso',
hint_danger: 'Perigo',
hint_success: 'Sucesso',
};
4 changes: 4 additions & 0 deletions packages/gitbook/src/intl/translations/ru.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,8 @@ export const ru = {
tool_call_skipped: 'Пропущен "${1}"',
scroll_back: 'Прокрутить назад',
scroll_further: 'Прокрутить дальше',
hint_info: 'Информация',
hint_warning: 'Предупреждение',
hint_danger: 'Опасность',
hint_success: 'Успех',
};
4 changes: 4 additions & 0 deletions packages/gitbook/src/intl/translations/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,8 @@ export const zh: TranslationLanguage = {
tool_call_skipped: '已跳过 "${1}"',
scroll_back: '向后滚动',
scroll_further: '向前滚动',
hint_info: '信息',
hint_warning: '警告',
hint_danger: '危险',
hint_success: '成功',
};