mirror of
https://github.com/suitenumerique/meet.git
synced 2026-08-29 03:37:17 +00:00
♻️(refactor) apply caption text size to subtitles
Use accessibilityStore.captionTextSize in Transcription component.
This commit is contained in:
@@ -10,6 +10,7 @@ and this project adheres to
|
|||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
|
- ♿️(frontend) Caption text size setting for accessibility #1062
|
||||||
- ♿️(frontend) sync html lang attribute with i18n for screen readers #1111
|
- ♿️(frontend) sync html lang attribute with i18n for screen readers #1111
|
||||||
- ♿️(frontend) improve MoreLink a11y and UX on home page #1112
|
- ♿️(frontend) improve MoreLink a11y and UX on home page #1112
|
||||||
- ♿(frontend) improve chat toast a11y for screen readers #1109
|
- ♿(frontend) improve chat toast a11y for screen readers #1109
|
||||||
|
|||||||
@@ -3,24 +3,23 @@ import { css } from '@/styled-system/css'
|
|||||||
import { useMemo } from 'react'
|
import { useMemo } from 'react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { useSnapshot } from 'valtio'
|
import { useSnapshot } from 'valtio'
|
||||||
import { accessibilityStore } from '@/stores/accessibility'
|
import {
|
||||||
import type { CaptionTextSize } from '@/stores/accessibility'
|
accessibilityStore,
|
||||||
|
type CaptionTextSize,
|
||||||
const CAPTION_TEXT_SIZE_OPTIONS: CaptionTextSize[] = [
|
CAPTION_TEXT_SIZE_OPTIONS,
|
||||||
'small',
|
} from '@/stores/accessibility'
|
||||||
'medium',
|
|
||||||
'large',
|
|
||||||
]
|
|
||||||
|
|
||||||
export const CaptionsSettings = () => {
|
export const CaptionsSettings = () => {
|
||||||
const { t } = useTranslation('settings')
|
const { t } = useTranslation('settings', {
|
||||||
|
keyPrefix: 'accessibility.captions',
|
||||||
|
})
|
||||||
const snap = useSnapshot(accessibilityStore)
|
const snap = useSnapshot(accessibilityStore)
|
||||||
|
|
||||||
const captionTextSizeItems = useMemo(
|
const captionTextSizeItems = useMemo(
|
||||||
() =>
|
() =>
|
||||||
CAPTION_TEXT_SIZE_OPTIONS.map((size) => ({
|
CAPTION_TEXT_SIZE_OPTIONS.map((size) => ({
|
||||||
value: size,
|
value: size,
|
||||||
label: t(`accessibility.captions.textSize.options.${size}`),
|
label: t(`textSize.options.${size}`),
|
||||||
})),
|
})),
|
||||||
[t]
|
[t]
|
||||||
)
|
)
|
||||||
@@ -33,11 +32,11 @@ export const CaptionsSettings = () => {
|
|||||||
marginBottom: '0.5rem',
|
marginBottom: '0.5rem',
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
{t('accessibility.captions.heading')}
|
{t('heading')}
|
||||||
</H>
|
</H>
|
||||||
<Field
|
<Field
|
||||||
type="select"
|
type="select"
|
||||||
label={t('accessibility.captions.textSize.label')}
|
label={t('textSize.label')}
|
||||||
items={captionTextSizeItems}
|
items={captionTextSizeItems}
|
||||||
selectedKey={snap.captionTextSize}
|
selectedKey={snap.captionTextSize}
|
||||||
onSelectionChange={(key) => {
|
onSelectionChange={(key) => {
|
||||||
|
|||||||
@@ -8,6 +8,25 @@ import { useRoomContext } from '@livekit/components-react'
|
|||||||
import { getParticipantColor } from '@/features/rooms/utils/getParticipantColor'
|
import { getParticipantColor } from '@/features/rooms/utils/getParticipantColor'
|
||||||
import { getParticipantName } from '@/features/rooms/utils/getParticipantName'
|
import { getParticipantName } from '@/features/rooms/utils/getParticipantName'
|
||||||
import { Participant, RoomEvent } from 'livekit-client'
|
import { Participant, RoomEvent } from 'livekit-client'
|
||||||
|
import { useSnapshot } from 'valtio'
|
||||||
|
import {
|
||||||
|
accessibilityStore,
|
||||||
|
CAPTION_TEXT_SIZE_OPTIONS,
|
||||||
|
type CaptionTextSize,
|
||||||
|
} from '@/stores/accessibility'
|
||||||
|
|
||||||
|
const FONT_SIZE_CONFIG: Record<
|
||||||
|
CaptionTextSize,
|
||||||
|
{ fontSize: string; lineHeight: string }
|
||||||
|
> = {
|
||||||
|
small: { fontSize: '0.875rem', lineHeight: '1.2rem' },
|
||||||
|
medium: { fontSize: '1.5rem', lineHeight: '1.7rem' },
|
||||||
|
large: { fontSize: '2.25rem', lineHeight: '2.5rem' },
|
||||||
|
}
|
||||||
|
|
||||||
|
const CAPTION_FONT_SIZES = Object.fromEntries(
|
||||||
|
CAPTION_TEXT_SIZE_OPTIONS.map((size) => [size, FONT_SIZE_CONFIG[size]])
|
||||||
|
) as Record<CaptionTextSize, { fontSize: string; lineHeight: string }>
|
||||||
|
|
||||||
export interface TranscriptionSegment {
|
export interface TranscriptionSegment {
|
||||||
id: string
|
id: string
|
||||||
@@ -73,8 +92,10 @@ const useTranscriptionState = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const Transcription = ({ row }: { row: TranscriptionRow }) => {
|
const Transcription = ({ row }: { row: TranscriptionRow }) => {
|
||||||
|
const { captionTextSize } = useSnapshot(accessibilityStore)
|
||||||
const participantColor = getParticipantColor(row.participant)
|
const participantColor = getParticipantColor(row.participant)
|
||||||
const participantName = getParticipantName(row.participant)
|
const participantName = getParticipantName(row.participant)
|
||||||
|
const { fontSize, lineHeight } = CAPTION_FONT_SIZES[captionTextSize]
|
||||||
|
|
||||||
const getDisplayText = (row: TranscriptionRow): string => {
|
const getDisplayText = (row: TranscriptionRow): string => {
|
||||||
return row.segments
|
return row.segments
|
||||||
@@ -116,10 +137,9 @@ const Transcription = ({ row }: { row: TranscriptionRow }) => {
|
|||||||
</Text>
|
</Text>
|
||||||
<p
|
<p
|
||||||
className={css({
|
className={css({
|
||||||
fontSize: '1.5rem',
|
|
||||||
lineHeight: '1.7rem',
|
|
||||||
fontWeight: '400',
|
fontWeight: '400',
|
||||||
})}
|
})}
|
||||||
|
style={{ fontSize, lineHeight }}
|
||||||
>
|
>
|
||||||
{displayText}
|
{displayText}
|
||||||
</p>
|
</p>
|
||||||
@@ -198,7 +218,6 @@ export const Subtitles = () => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return rows
|
return rows
|
||||||
}, [transcriptionSegments])
|
}, [transcriptionSegments])
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,12 @@ import { deserializeToProxyMap } from '@/utils/valtio'
|
|||||||
|
|
||||||
export type CaptionTextSize = 'small' | 'medium' | 'large'
|
export type CaptionTextSize = 'small' | 'medium' | 'large'
|
||||||
|
|
||||||
|
export const CAPTION_TEXT_SIZE_OPTIONS: CaptionTextSize[] = [
|
||||||
|
'small',
|
||||||
|
'medium',
|
||||||
|
'large',
|
||||||
|
]
|
||||||
|
|
||||||
type AccessibilityState = {
|
type AccessibilityState = {
|
||||||
announceReactions: boolean
|
announceReactions: boolean
|
||||||
captionTextSize: CaptionTextSize
|
captionTextSize: CaptionTextSize
|
||||||
@@ -19,7 +25,7 @@ function getAccessibilityState(): AccessibilityState {
|
|||||||
const stored = localStorage.getItem(STORAGE_KEYS.ACCESSIBILITY)
|
const stored = localStorage.getItem(STORAGE_KEYS.ACCESSIBILITY)
|
||||||
if (stored) {
|
if (stored) {
|
||||||
const parsed = JSON.parse(stored)
|
const parsed = JSON.parse(stored)
|
||||||
const validCaptionSizes: CaptionTextSize[] = ['small', 'medium', 'large']
|
const validCaptionSizes = CAPTION_TEXT_SIZE_OPTIONS
|
||||||
const captionTextSize = validCaptionSizes.includes(parsed.captionTextSize)
|
const captionTextSize = validCaptionSizes.includes(parsed.captionTextSize)
|
||||||
? parsed.captionTextSize
|
? parsed.captionTextSize
|
||||||
: DEFAULT_STATE.captionTextSize
|
: DEFAULT_STATE.captionTextSize
|
||||||
|
|||||||
Reference in New Issue
Block a user