mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-12-03 06:26:41 +00:00
Improve keyboard and screen reader support (#4761)
Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
"@gitbook/icons": patch
|
||||
---
|
||||
|
||||
Add a skip link, keyboard navigation between content tabs, focusable table of contents toggles, and hide decorative icons from assistive technologies.
|
||||
@@ -1,8 +1,7 @@
|
||||
'use client';
|
||||
|
||||
import React from 'react';
|
||||
|
||||
import { getCodeTextFromId } from './utils';
|
||||
import { useCopyToClipboard } from '@/components/hooks';
|
||||
import { Button } from '@/components/primitives';
|
||||
import { t, useLanguage } from '@/intl/client';
|
||||
import { type ClassValue, tcls } from '@/lib/tailwind';
|
||||
@@ -15,41 +14,30 @@ export function CopyCodeButton(props: { codeId: string; style: ClassValue }) {
|
||||
const { codeId, style } = props;
|
||||
|
||||
const language = useLanguage();
|
||||
const [copied, setCopied] = React.useState(false);
|
||||
|
||||
React.useEffect(() => {
|
||||
if (!copied) {
|
||||
return;
|
||||
}
|
||||
|
||||
const timeout = setTimeout(() => {
|
||||
setCopied(false);
|
||||
}, 1000);
|
||||
|
||||
return () => {
|
||||
clearTimeout(timeout);
|
||||
};
|
||||
}, [copied]);
|
||||
const { copied, copy } = useCopyToClipboard();
|
||||
|
||||
const onClick = () => {
|
||||
const codeText = getCodeTextFromId(codeId);
|
||||
if (codeText === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
navigator.clipboard.writeText(codeText);
|
||||
|
||||
setCopied(true);
|
||||
copy(codeText);
|
||||
};
|
||||
|
||||
return (
|
||||
<Button
|
||||
size="xsmall"
|
||||
variant="secondary"
|
||||
onClick={onClick}
|
||||
className={tcls(style, 'translate-y-0!', 'print:hidden')}
|
||||
>
|
||||
{t(language, copied ? 'code_copied' : 'code_copy')}
|
||||
</Button>
|
||||
<>
|
||||
<Button
|
||||
size="xsmall"
|
||||
variant="secondary"
|
||||
onClick={onClick}
|
||||
className={tcls(style, 'translate-y-0!', 'print:hidden')}
|
||||
>
|
||||
{t(language, copied ? 'code_copied' : 'code_copy')}
|
||||
</Button>
|
||||
{/* A label swap on the focused button isn't announced, the live region is. */}
|
||||
<span role="status" className="sr-only">
|
||||
{copied ? t(language, 'code_copied') : null}
|
||||
</span>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import React from 'react';
|
||||
import { Icon } from '@gitbook/icons';
|
||||
|
||||
import { type PromptActionId, setPromptAction, usePromptAction } from './promptAction';
|
||||
import { useCopyToClipboard } from '@/components/hooks';
|
||||
import {
|
||||
Button,
|
||||
ButtonGroup,
|
||||
@@ -27,25 +28,10 @@ export function PromptActions(props: { prompt: string; openInAIProviders: boolea
|
||||
const { prompt, openInAIProviders } = props;
|
||||
const language = useLanguage();
|
||||
const selectedAction = usePromptAction();
|
||||
const [copied, setCopied] = React.useState(false);
|
||||
|
||||
React.useEffect(() => {
|
||||
if (!copied) {
|
||||
return;
|
||||
}
|
||||
|
||||
const timeout = setTimeout(() => {
|
||||
setCopied(false);
|
||||
}, COPIED_MESSAGE_DURATION);
|
||||
|
||||
return () => {
|
||||
clearTimeout(timeout);
|
||||
};
|
||||
}, [copied]);
|
||||
const { copied, copy } = useCopyToClipboard(COPIED_MESSAGE_DURATION);
|
||||
|
||||
const copyPrompt = () => {
|
||||
navigator.clipboard.writeText(prompt);
|
||||
setCopied(true);
|
||||
copy(prompt);
|
||||
};
|
||||
|
||||
// The pick follows the visitor from site to site, so fall back to copying wherever the agent
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
import { describe, expect, it } from 'bun:test';
|
||||
|
||||
import { getNextTabIndex } from './DynamicTabs';
|
||||
|
||||
describe('getNextTabIndex', () => {
|
||||
it('moves with the arrow keys and wraps around', () => {
|
||||
expect(getNextTabIndex('ArrowRight', 0, 3)).toBe(1);
|
||||
expect(getNextTabIndex('ArrowRight', 2, 3)).toBe(0);
|
||||
expect(getNextTabIndex('ArrowLeft', 0, 3)).toBe(2);
|
||||
});
|
||||
|
||||
it('jumps to the first and last tab', () => {
|
||||
expect(getNextTabIndex('Home', 2, 3)).toBe(0);
|
||||
expect(getNextTabIndex('End', 0, 3)).toBe(2);
|
||||
});
|
||||
|
||||
it('mirrors the arrows in right-to-left', () => {
|
||||
expect(getNextTabIndex('ArrowLeft', 0, 3, true)).toBe(1);
|
||||
expect(getNextTabIndex('ArrowRight', 0, 3, true)).toBe(2);
|
||||
});
|
||||
|
||||
it('ignores other keys and an unknown tab', () => {
|
||||
expect(getNextTabIndex('Enter', 0, 3)).toBeNull();
|
||||
expect(getNextTabIndex('ArrowRight', -1, 3)).toBeNull();
|
||||
});
|
||||
});
|
||||
@@ -151,10 +151,15 @@ const TabItemList = memo(function TabItemList(props: {
|
||||
}).filter((x) => x !== undefined),
|
||||
[overflowing, tabs]
|
||||
);
|
||||
// Roving tabindex: one tab stop for the strip, the active tab when it isn't in the overflow menu.
|
||||
const visibleTabs = tabs.filter((tab) => !overflowing.has(getTabButtonId(tab.id)));
|
||||
const focusableTabId =
|
||||
visibleTabs.find((tab) => tab.id === activeTabId)?.id ?? visibleTabs[0]?.id ?? null;
|
||||
return (
|
||||
<div
|
||||
ref={containerRef}
|
||||
role="tablist"
|
||||
onKeyDown={moveFocusBetweenTabs}
|
||||
className={tcls(
|
||||
'group/tabs',
|
||||
'overflow-hidden',
|
||||
@@ -182,6 +187,7 @@ const TabItemList = memo(function TabItemList(props: {
|
||||
key={tab.id}
|
||||
ref={itemRef}
|
||||
isActive={tab.id === activeTabId}
|
||||
isFocusable={tab.id === focusableTabId}
|
||||
isMeasuring={isMeasuring}
|
||||
tab={tab}
|
||||
onSelect={onSelect}
|
||||
@@ -241,16 +247,18 @@ function TabsDropdownMenu(props: {
|
||||
const TabItem = memo(function TabItem(props: {
|
||||
ref: React.Ref<HTMLButtonElement>;
|
||||
isActive: boolean;
|
||||
isFocusable: boolean;
|
||||
isMeasuring: boolean;
|
||||
tab: TabsItem;
|
||||
onSelect: (tabId: string) => void;
|
||||
}) {
|
||||
const { ref, tab, isActive, isMeasuring, onSelect } = props;
|
||||
const { ref, tab, isActive, isFocusable, isMeasuring, onSelect } = props;
|
||||
return (
|
||||
<TabButton
|
||||
ref={ref}
|
||||
role="tab"
|
||||
aria-selected={isActive}
|
||||
tabIndex={isFocusable ? 0 : -1}
|
||||
aria-controls={tab.id}
|
||||
id={getTabButtonId(tab.id)}
|
||||
title={tab.title}
|
||||
@@ -343,6 +351,55 @@ function TabButton(
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Arrow keys, Home and End move focus between the tabs of a tablist; Enter or Space then selects.
|
||||
*/
|
||||
function moveFocusBetweenTabs(event: React.KeyboardEvent<HTMLElement>) {
|
||||
const current = event.target instanceof HTMLElement ? event.target : null;
|
||||
if (current?.getAttribute('role') !== 'tab') {
|
||||
return;
|
||||
}
|
||||
const tabs = Array.from(
|
||||
event.currentTarget.querySelectorAll<HTMLElement>('[role="tab"]:not([disabled])')
|
||||
);
|
||||
const index = tabs.indexOf(current);
|
||||
const isRTL = getComputedStyle(event.currentTarget).direction === 'rtl';
|
||||
const next = getNextTabIndex(event.key, index, tabs.length, isRTL);
|
||||
if (next === null) {
|
||||
return;
|
||||
}
|
||||
event.preventDefault();
|
||||
tabs[next]?.focus();
|
||||
}
|
||||
|
||||
/**
|
||||
* Index of the tab to focus for a key press, or null when the key doesn't move focus.
|
||||
*/
|
||||
export function getNextTabIndex(
|
||||
key: string,
|
||||
index: number,
|
||||
count: number,
|
||||
isRTL = false
|
||||
): number | null {
|
||||
if (index < 0 || count === 0) {
|
||||
return null;
|
||||
}
|
||||
const forward = isRTL ? 'ArrowLeft' : 'ArrowRight';
|
||||
const backward = isRTL ? 'ArrowRight' : 'ArrowLeft';
|
||||
switch (key) {
|
||||
case forward:
|
||||
return (index + 1) % count;
|
||||
case backward:
|
||||
return (index - 1 + count) % count;
|
||||
case 'Home':
|
||||
return 0;
|
||||
case 'End':
|
||||
return count - 1;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the ID for a tab button.
|
||||
*/
|
||||
|
||||
@@ -9,7 +9,7 @@ interface HeaderLinksProps {
|
||||
|
||||
export async function HeaderLinks({ children, style }: HeaderLinksProps) {
|
||||
return (
|
||||
<div
|
||||
<nav
|
||||
className={tcls(
|
||||
'header-links',
|
||||
'@4xl:[&>.button+.button]:-ml-2 z-20 ml-auto flex min-w-9 shrink grow @7xl:grow-0 items-center justify-end @4xl:gap-x-6 gap-x-4',
|
||||
@@ -17,6 +17,6 @@ export async function HeaderLinks({ children, style }: HeaderLinksProps) {
|
||||
)}
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
</nav>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import { PageCover } from './PageCover';
|
||||
import { PageFooterNavigation } from './PageFooterNavigation';
|
||||
import { PageHeader } from './PageHeader';
|
||||
import { PreservePageLayout } from './PreservePageLayout';
|
||||
import { MAIN_CONTENT_ID } from '@/components/layout';
|
||||
import { getSpaceLanguage } from '@/intl/server';
|
||||
import { t } from '@/intl/translate';
|
||||
import type { GitBookSiteContext } from '@/lib/context';
|
||||
@@ -103,6 +104,7 @@ export async function PageBody(props: {
|
||||
/>
|
||||
) : null}
|
||||
<main
|
||||
id={MAIN_CONTENT_ID}
|
||||
// Comments on the whole page target anywhere in it that isn't a block.
|
||||
{...(withCommentAnchors ? { 'data-comment-page': '' } : {})}
|
||||
className={tcls(
|
||||
|
||||
@@ -22,6 +22,7 @@ import {
|
||||
useSpaceBasePath,
|
||||
} from '../SpaceLayout/SpaceLayoutContext';
|
||||
import { TrackPageViewEvent } from '@/components/Insights';
|
||||
import { MAIN_CONTENT_ID } from '@/components/layout';
|
||||
import { t, tString, useLanguage } from '@/intl/client';
|
||||
import { tcls } from '@/lib/tailwind';
|
||||
|
||||
@@ -102,6 +103,7 @@ export function SitePageNotFound() {
|
||||
<CurrentPageProvider page={null}>
|
||||
<div className="lg:has-sidebar:-ml-84 w-full">
|
||||
<main
|
||||
id={MAIN_CONTENT_ID}
|
||||
className={tcls(
|
||||
// `page-no-toc` hides the TOC (like PageBody), and `layout-wide` takes the
|
||||
// now-empty sidebar out of flow so the content stays centered on all layouts.
|
||||
|
||||
@@ -12,6 +12,7 @@ import { CurrentContentProvider } from '../hooks';
|
||||
import { InsightsProvider, VisitorProvider } from '../Insights';
|
||||
import { CONTAINER_STYLE } from '../layout';
|
||||
import { NavigationLoader } from '../primitives/NavigationLoader';
|
||||
import { SkipToContent } from '../primitives/SkipToContent';
|
||||
import { SearchContainer, getSearchBaseProps } from '../Search';
|
||||
import {
|
||||
SiteSectionList,
|
||||
@@ -131,6 +132,7 @@ export function SpaceLayout(props: SpaceLayoutProps) {
|
||||
|
||||
return (
|
||||
<SpaceLayoutServerContext {...props}>
|
||||
<SkipToContent />
|
||||
<Announcement context={context} />
|
||||
<Header withTopHeader={withTopHeader} variants={variants} context={context} />
|
||||
<NavigationLoader />
|
||||
|
||||
@@ -26,6 +26,7 @@ export function ToggleableLinkItem(
|
||||
isActive || pathnames.some((pathname) => currentPagePath.startsWith(`${pathname}/`));
|
||||
const [isOpen, setIsOpen] = React.useState(defaultIsOpen);
|
||||
const hasBeenToggled = useRef(false);
|
||||
const linkId = React.useId();
|
||||
|
||||
// Update the visibility of the children if one of the descendants becomes active.
|
||||
React.useEffect(() => {
|
||||
@@ -60,10 +61,16 @@ export function ToggleableLinkItem(
|
||||
}
|
||||
|
||||
return (
|
||||
<DescendantsRenderer descendants={descendants} isOpen={isOpen} setIsOpen={handleToggle}>
|
||||
<DescendantsRenderer
|
||||
descendants={descendants}
|
||||
isOpen={isOpen}
|
||||
setIsOpen={handleToggle}
|
||||
labelledBy={linkId}
|
||||
>
|
||||
{({ descendants, toggler }) => (
|
||||
<>
|
||||
<LinkItem
|
||||
id={linkId}
|
||||
href={href}
|
||||
insights={insights}
|
||||
isActive={isActive}
|
||||
@@ -88,12 +95,12 @@ export function ToggleableLinkItem(
|
||||
}
|
||||
|
||||
function LinkItem(
|
||||
props: Pick<LinkProps, 'href' | 'insights' | 'children'> & {
|
||||
props: Pick<LinkProps, 'href' | 'insights' | 'children' | 'id'> & {
|
||||
isActive: boolean;
|
||||
onActiveClick?: () => void;
|
||||
}
|
||||
) {
|
||||
const { isActive, href, insights, children, onActiveClick } = props;
|
||||
const { id, isActive, href, insights, children, onActiveClick } = props;
|
||||
|
||||
const handleClick = (event: React.MouseEvent<HTMLAnchorElement>) => {
|
||||
if (isActive && onActiveClick) {
|
||||
@@ -104,6 +111,7 @@ function LinkItem(
|
||||
|
||||
return (
|
||||
<Link
|
||||
id={id}
|
||||
data-active={isActive}
|
||||
href={href}
|
||||
insights={insights}
|
||||
@@ -123,18 +131,21 @@ function DescendantsRenderer(props: {
|
||||
descendants: React.ReactNode;
|
||||
isOpen: boolean;
|
||||
setIsOpen: React.Dispatch<React.SetStateAction<boolean>>;
|
||||
/** Id of the link the toggle belongs to, used as its accessible name. */
|
||||
labelledBy: string;
|
||||
children: (renderProps: {
|
||||
descendants: React.ReactNode;
|
||||
toggler: React.ReactNode;
|
||||
}) => React.ReactNode;
|
||||
}) {
|
||||
const { descendants, isOpen, setIsOpen } = props;
|
||||
const { descendants, isOpen, setIsOpen, labelledBy } = props;
|
||||
|
||||
return props.children({
|
||||
toggler: (
|
||||
<Toggler
|
||||
isLinkActive={isOpen}
|
||||
isOpen={isOpen}
|
||||
labelledBy={labelledBy}
|
||||
onToggle={() => {
|
||||
setIsOpen((prev) => !prev);
|
||||
}}
|
||||
@@ -144,8 +155,13 @@ function DescendantsRenderer(props: {
|
||||
});
|
||||
}
|
||||
|
||||
function Toggler(props: { isLinkActive: boolean; isOpen: boolean; onToggle: () => void }) {
|
||||
const { isOpen, onToggle } = props;
|
||||
function Toggler(props: {
|
||||
isLinkActive: boolean;
|
||||
isOpen: boolean;
|
||||
labelledBy: string;
|
||||
onToggle: () => void;
|
||||
}) {
|
||||
const { isOpen, labelledBy, onToggle } = props;
|
||||
return (
|
||||
<Button
|
||||
icon={
|
||||
@@ -164,9 +180,12 @@ function Toggler(props: { isLinkActive: boolean; isOpen: boolean; onToggle: () =
|
||||
size="xsmall"
|
||||
iconOnly
|
||||
variant="blank"
|
||||
aria-hidden="true" // The button has no label or focus so hiding it from screen readers.
|
||||
className="-my-0.5 -mr-1 ml-auto min-h-6 min-w-6 text-current hover:bg-tint-base"
|
||||
tabIndex={-1} // Prevent focus on the button since it's already inside a clickable link that performs the same toggle action.
|
||||
// Named after its page and focusable: the link only toggles on the current page, so
|
||||
// this is the only keyboard way to expand another page's children.
|
||||
aria-labelledby={labelledBy}
|
||||
aria-expanded={isOpen}
|
||||
// Cancels the Button's expanded highlight: an open chevron must look like a closed one.
|
||||
className="-my-0.5 -mr-1 ml-auto min-h-6 min-w-6 text-current hover:bg-tint-base aria-expanded:bg-transparent aria-expanded:text-current aria-expanded:hover:bg-tint-hover"
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -10,3 +10,4 @@ export * from './useNow';
|
||||
export * from './useListOverflow';
|
||||
export * from './useCurrentPageMetadata';
|
||||
export * from './useBackToSpace';
|
||||
export * from './useCopyToClipboard';
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
'use client';
|
||||
|
||||
import React from 'react';
|
||||
|
||||
/**
|
||||
* Copy text to the clipboard and expose a `copied` flag that resets after `duration`.
|
||||
* The flag is only set once the write succeeded.
|
||||
*/
|
||||
export function useCopyToClipboard(duration = 1000) {
|
||||
const [copied, setCopied] = React.useState(false);
|
||||
|
||||
React.useEffect(() => {
|
||||
if (!copied) {
|
||||
return;
|
||||
}
|
||||
const timeout = setTimeout(() => setCopied(false), duration);
|
||||
return () => clearTimeout(timeout);
|
||||
}, [copied, duration]);
|
||||
|
||||
const copy = React.useCallback(async (text: string) => {
|
||||
try {
|
||||
await navigator.clipboard.writeText(text);
|
||||
setCopied(true);
|
||||
} catch {
|
||||
// Clipboard access can be denied (permissions, insecure context): don't claim success.
|
||||
setCopied(false);
|
||||
}
|
||||
}, []);
|
||||
|
||||
return { copied, copy };
|
||||
}
|
||||
@@ -50,3 +50,6 @@ export const SIDE_COLUMN_WITHOUT_HEADER_AND_COVER: ClassValue = [
|
||||
'top-[240px]',
|
||||
'h-[calc(100vh-240px)]',
|
||||
];
|
||||
|
||||
/** Id of the `<main>` landmark, target of the skip link. */
|
||||
export const MAIN_CONTENT_ID = 'gitbook-main-content';
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
'use client';
|
||||
|
||||
import { MAIN_CONTENT_ID } from '../layout';
|
||||
import { tString, useLanguage } from '@/intl/client';
|
||||
|
||||
/**
|
||||
* Link shown on keyboard focus to jump over the header and navigation.
|
||||
*/
|
||||
export function SkipToContent() {
|
||||
const language = useLanguage();
|
||||
return (
|
||||
<a
|
||||
href={`#${MAIN_CONTENT_ID}`}
|
||||
className="sr-only focus:not-sr-only focus:fixed focus:left-2 focus:top-2 focus:z-50 focus:rounded-md focus:bg-tint-base focus:px-4 focus:py-2 focus:text-sm focus:text-tint-strong focus:shadow-lg focus:ring-2 focus:ring-primary"
|
||||
>
|
||||
{tString(language, 'skip_to_content')}
|
||||
</a>
|
||||
);
|
||||
}
|
||||
@@ -10,6 +10,7 @@ export const ar: TranslationLanguage = {
|
||||
switch_to_light_theme: 'التبديل إلى السمة الفاتحة',
|
||||
switch_to_system_theme: 'التبديل إلى سمة النظام',
|
||||
search: 'بحث',
|
||||
skip_to_content: 'تخطي إلى المحتوى',
|
||||
clear: 'مسح',
|
||||
table_filtered_by_selection: 'يطابق الاختيار: ${1}',
|
||||
table_clear_selection: 'مسح الاختيار',
|
||||
|
||||
@@ -10,6 +10,7 @@ export const bg: TranslationLanguage = {
|
||||
switch_to_light_theme: 'Превключване към светла тема',
|
||||
switch_to_system_theme: 'Превключване към системната тема',
|
||||
search: 'Търсене',
|
||||
skip_to_content: 'Към съдържанието',
|
||||
clear: 'Изчистване',
|
||||
table_filtered_by_selection: 'Съответства на избора: ${1}',
|
||||
table_clear_selection: 'Изчисти избора',
|
||||
|
||||
@@ -10,6 +10,7 @@ export const cs: TranslationLanguage = {
|
||||
switch_to_light_theme: 'Přepnout na světlý motiv',
|
||||
switch_to_system_theme: 'Přepnout na systémový motiv',
|
||||
search: 'Hledat',
|
||||
skip_to_content: 'Přejít k obsahu',
|
||||
clear: 'Vymazat',
|
||||
table_filtered_by_selection: 'Odpovídá výběru: ${1}',
|
||||
table_clear_selection: 'Zrušit výběr',
|
||||
|
||||
@@ -10,6 +10,7 @@ export const da: TranslationLanguage = {
|
||||
switch_to_light_theme: 'Skift til lyst tema',
|
||||
switch_to_system_theme: 'Skift til systemtema',
|
||||
search: 'Søg',
|
||||
skip_to_content: 'Spring til indhold',
|
||||
clear: 'Ryd',
|
||||
table_filtered_by_selection: 'Matcher valg: ${1}',
|
||||
table_clear_selection: 'Ryd valg',
|
||||
|
||||
@@ -10,6 +10,7 @@ export const de: TranslationLanguage = {
|
||||
switch_to_light_theme: 'Zum hellen Modus wechseln',
|
||||
switch_to_system_theme: 'Zum Systemmodus wechseln',
|
||||
search: 'Suche',
|
||||
skip_to_content: 'Zum Inhalt springen',
|
||||
clear: 'Löschen',
|
||||
table_filtered_by_selection: 'Entspricht Auswahl: ${1}',
|
||||
table_clear_selection: 'Auswahl zurücksetzen',
|
||||
|
||||
@@ -10,6 +10,7 @@ export const el: TranslationLanguage = {
|
||||
switch_to_light_theme: 'Αλλαγή σε φωτεινό θέμα',
|
||||
switch_to_system_theme: 'Αλλαγή στο θέμα συστήματος',
|
||||
search: 'Αναζήτηση',
|
||||
skip_to_content: 'Μετάβαση στο περιεχόμενο',
|
||||
clear: 'Εκκαθάριση',
|
||||
table_filtered_by_selection: 'Ταιριάζει με την επιλογή: ${1}',
|
||||
table_clear_selection: 'Εκκαθάριση επιλογής',
|
||||
|
||||
@@ -8,6 +8,7 @@ export const en = {
|
||||
switch_to_light_theme: 'Switch to light theme',
|
||||
switch_to_system_theme: 'Switch to system theme',
|
||||
search: 'Search',
|
||||
skip_to_content: 'Skip to content',
|
||||
clear: 'Clear',
|
||||
table_filtered_by_selection: 'Matches selection: ${1}',
|
||||
table_clear_selection: 'Clear selection',
|
||||
|
||||
@@ -10,6 +10,7 @@ export const es: TranslationLanguage = {
|
||||
switch_to_light_theme: 'Cambiar a tema claro',
|
||||
switch_to_system_theme: 'Cambiar a tema del sistema',
|
||||
search: 'Buscar',
|
||||
skip_to_content: 'Saltar al contenido',
|
||||
clear: 'Limpiar',
|
||||
table_filtered_by_selection: 'Coincide con la selección: ${1}',
|
||||
table_clear_selection: 'Borrar selección',
|
||||
|
||||
@@ -10,6 +10,7 @@ export const et: TranslationLanguage = {
|
||||
switch_to_light_theme: 'Lülitu heledale teemale',
|
||||
switch_to_system_theme: 'Lülitu süsteemi teemale',
|
||||
search: 'Otsi',
|
||||
skip_to_content: 'Liigu sisu juurde',
|
||||
clear: 'Tühjenda',
|
||||
table_filtered_by_selection: 'Vastab valikule: ${1}',
|
||||
table_clear_selection: 'Tühjenda valik',
|
||||
|
||||
@@ -10,6 +10,7 @@ export const fi: TranslationLanguage = {
|
||||
switch_to_light_theme: 'Vaihda vaaleaan teemaan',
|
||||
switch_to_system_theme: 'Vaihda järjestelmän teemaan',
|
||||
search: 'Haku',
|
||||
skip_to_content: 'Siirry sisältöön',
|
||||
clear: 'Tyhjennä',
|
||||
table_filtered_by_selection: 'Vastaa valintaa: ${1}',
|
||||
table_clear_selection: 'Tyhjennä valinta',
|
||||
|
||||
@@ -10,6 +10,7 @@ export const fr: TranslationLanguage = {
|
||||
switch_to_light_theme: 'Activer le thème clair',
|
||||
switch_to_system_theme: 'Utiliser le thème du système',
|
||||
search: 'Rechercher',
|
||||
skip_to_content: 'Aller au contenu',
|
||||
clear: 'Effacer',
|
||||
table_filtered_by_selection: 'Correspond à la sélection : ${1}',
|
||||
table_clear_selection: 'Effacer la sélection',
|
||||
|
||||
@@ -10,6 +10,7 @@ export const he: TranslationLanguage = {
|
||||
switch_to_light_theme: 'מעבר לערכת נושא בהירה',
|
||||
switch_to_system_theme: 'מעבר לערכת הנושא של המערכת',
|
||||
search: 'חיפוש',
|
||||
skip_to_content: 'דילוג לתוכן',
|
||||
clear: 'ניקוי',
|
||||
table_filtered_by_selection: 'תואם לבחירה: ${1}',
|
||||
table_clear_selection: 'נקה בחירה',
|
||||
|
||||
@@ -10,6 +10,7 @@ export const hi: TranslationLanguage = {
|
||||
switch_to_light_theme: 'लाइट थीम पर जाएं',
|
||||
switch_to_system_theme: 'सिस्टम थीम पर जाएं',
|
||||
search: 'खोजें',
|
||||
skip_to_content: 'सामग्री पर जाएं',
|
||||
clear: 'साफ करें',
|
||||
table_filtered_by_selection: 'चयन से मेल खाता है: ${1}',
|
||||
table_clear_selection: 'चयन साफ़ करें',
|
||||
|
||||
@@ -10,6 +10,7 @@ export const hr: TranslationLanguage = {
|
||||
switch_to_light_theme: 'Prebaci na svijetlu temu',
|
||||
switch_to_system_theme: 'Prebaci na temu sustava',
|
||||
search: 'Pretraži',
|
||||
skip_to_content: 'Preskoči na sadržaj',
|
||||
clear: 'Očisti',
|
||||
table_filtered_by_selection: 'Odgovara odabiru: ${1}',
|
||||
table_clear_selection: 'Očisti odabir',
|
||||
|
||||
@@ -10,6 +10,7 @@ export const hu: TranslationLanguage = {
|
||||
switch_to_light_theme: 'Váltás világos témára',
|
||||
switch_to_system_theme: 'Váltás rendszer témára',
|
||||
search: 'Keresés',
|
||||
skip_to_content: 'Ugrás a tartalomra',
|
||||
clear: 'Törlés',
|
||||
table_filtered_by_selection: 'Megfelel a kijelölésnek: ${1}',
|
||||
table_clear_selection: 'Kijelölés törlése',
|
||||
|
||||
@@ -10,6 +10,7 @@ export const id: TranslationLanguage = {
|
||||
switch_to_light_theme: 'Beralih ke tema terang',
|
||||
switch_to_system_theme: 'Beralih ke tema sistem',
|
||||
search: 'Cari',
|
||||
skip_to_content: 'Lewati ke konten',
|
||||
clear: 'Bersihkan',
|
||||
table_filtered_by_selection: 'Sesuai pilihan: ${1}',
|
||||
table_clear_selection: 'Hapus pilihan',
|
||||
|
||||
@@ -10,6 +10,7 @@ export const it: TranslationLanguage = {
|
||||
switch_to_light_theme: 'Passa al tema chiaro',
|
||||
switch_to_system_theme: 'Passa al tema di sistema',
|
||||
search: 'Cerca',
|
||||
skip_to_content: 'Vai al contenuto',
|
||||
clear: 'Cancella',
|
||||
table_filtered_by_selection: 'Corrisponde alla selezione: ${1}',
|
||||
table_clear_selection: 'Cancella selezione',
|
||||
|
||||
@@ -10,6 +10,7 @@ export const ja: TranslationLanguage = {
|
||||
switch_to_light_theme: 'ライトテーマに切り替え',
|
||||
switch_to_system_theme: 'システムのテーマに切り替え',
|
||||
search: '検索',
|
||||
skip_to_content: 'コンテンツへスキップ',
|
||||
clear: 'クリア',
|
||||
table_filtered_by_selection: '選択に一致: ${1}',
|
||||
table_clear_selection: '選択をクリア',
|
||||
|
||||
@@ -10,6 +10,7 @@ export const ko: TranslationLanguage = {
|
||||
switch_to_light_theme: '라이트 테마로 전환',
|
||||
switch_to_system_theme: '시스템 테마로 전환',
|
||||
search: '검색',
|
||||
skip_to_content: '본문으로 건너뛰기',
|
||||
clear: '지우기',
|
||||
table_filtered_by_selection: '선택과 일치: ${1}',
|
||||
table_clear_selection: '선택 지우기',
|
||||
|
||||
@@ -10,6 +10,7 @@ export const lt: TranslationLanguage = {
|
||||
switch_to_light_theme: 'Perjungti į šviesią temą',
|
||||
switch_to_system_theme: 'Perjungti į sistemos temą',
|
||||
search: 'Ieškoti',
|
||||
skip_to_content: 'Pereiti prie turinio',
|
||||
clear: 'Išvalyti',
|
||||
table_filtered_by_selection: 'Atitinka pasirinkimą: ${1}',
|
||||
table_clear_selection: 'Išvalyti pasirinkimą',
|
||||
|
||||
@@ -10,6 +10,7 @@ export const lv: TranslationLanguage = {
|
||||
switch_to_light_theme: 'Pārslēgt uz gaišo motīvu',
|
||||
switch_to_system_theme: 'Pārslēgt uz sistēmas motīvu',
|
||||
search: 'Meklēt',
|
||||
skip_to_content: 'Pāriet uz saturu',
|
||||
clear: 'Notīrīt',
|
||||
table_filtered_by_selection: 'Atbilst izvēlei: ${1}',
|
||||
table_clear_selection: 'Notīrīt izvēli',
|
||||
|
||||
@@ -10,6 +10,7 @@ export const ms: TranslationLanguage = {
|
||||
switch_to_light_theme: 'Tukar kepada tema cerah',
|
||||
switch_to_system_theme: 'Tukar kepada tema sistem',
|
||||
search: 'Cari',
|
||||
skip_to_content: 'Langkau ke kandungan',
|
||||
clear: 'Kosongkan',
|
||||
table_filtered_by_selection: 'Sepadan dengan pilihan: ${1}',
|
||||
table_clear_selection: 'Kosongkan pilihan',
|
||||
|
||||
@@ -10,6 +10,7 @@ export const nl: TranslationLanguage = {
|
||||
switch_to_light_theme: 'Schakel over naar lichte modus',
|
||||
switch_to_system_theme: 'Schakel over naar systeemmodus',
|
||||
search: 'Zoeken',
|
||||
skip_to_content: 'Naar inhoud',
|
||||
clear: 'Wissen',
|
||||
table_filtered_by_selection: 'Komt overeen met selectie: ${1}',
|
||||
table_clear_selection: 'Selectie wissen',
|
||||
|
||||
@@ -10,6 +10,7 @@ export const no: TranslationLanguage = {
|
||||
switch_to_light_theme: 'Bytt til lyst tema',
|
||||
switch_to_system_theme: 'Bytt til systemtema',
|
||||
search: 'Søk',
|
||||
skip_to_content: 'Hopp til innhold',
|
||||
clear: 'Tøm',
|
||||
table_filtered_by_selection: 'Samsvarer med valg: ${1}',
|
||||
table_clear_selection: 'Fjern valg',
|
||||
|
||||
@@ -10,6 +10,7 @@ export const pl: TranslationLanguage = {
|
||||
switch_to_light_theme: 'Przełącz na jasny motyw',
|
||||
switch_to_system_theme: 'Przełącz na motyw systemowy',
|
||||
search: 'Szukaj',
|
||||
skip_to_content: 'Przejdź do treści',
|
||||
clear: 'Wyczyść',
|
||||
table_filtered_by_selection: 'Zgodne z wyborem: ${1}',
|
||||
table_clear_selection: 'Wyczyść wybór',
|
||||
|
||||
@@ -10,6 +10,7 @@ export const pt_br: TranslationLanguage = {
|
||||
switch_to_light_theme: 'Mudar para modo claro',
|
||||
switch_to_system_theme: 'Mudar para configuração do sistema',
|
||||
search: 'Buscar',
|
||||
skip_to_content: 'Pular para o conteúdo',
|
||||
clear: 'Limpar',
|
||||
table_filtered_by_selection: 'Corresponde à seleção: ${1}',
|
||||
table_clear_selection: 'Limpar seleção',
|
||||
|
||||
@@ -10,6 +10,7 @@ export const pt: TranslationLanguage = {
|
||||
switch_to_light_theme: 'Mudar para o tema claro',
|
||||
switch_to_system_theme: 'Mudar para o tema do sistema',
|
||||
search: 'Pesquisar',
|
||||
skip_to_content: 'Saltar para o conteúdo',
|
||||
clear: 'Limpar',
|
||||
table_filtered_by_selection: 'Corresponde à seleção: ${1}',
|
||||
table_clear_selection: 'Limpar seleção',
|
||||
|
||||
@@ -10,6 +10,7 @@ export const ro: TranslationLanguage = {
|
||||
switch_to_light_theme: 'Comută la tema luminoasă',
|
||||
switch_to_system_theme: 'Comută la tema sistemului',
|
||||
search: 'Caută',
|
||||
skip_to_content: 'Salt la conținut',
|
||||
clear: 'Șterge',
|
||||
table_filtered_by_selection: 'Se potrivește cu selecția: ${1}',
|
||||
table_clear_selection: 'Șterge selecția',
|
||||
|
||||
@@ -10,6 +10,7 @@ export const ru: TranslationLanguage = {
|
||||
switch_to_light_theme: 'Переключиться на светлую тему',
|
||||
switch_to_system_theme: 'Переключиться на системную тему',
|
||||
search: 'Поиск',
|
||||
skip_to_content: 'Перейти к содержимому',
|
||||
clear: 'Очистить',
|
||||
table_filtered_by_selection: 'Соответствует выбору: ${1}',
|
||||
table_clear_selection: 'Очистить выбор',
|
||||
|
||||
@@ -10,6 +10,7 @@ export const sk: TranslationLanguage = {
|
||||
switch_to_light_theme: 'Prepnúť na svetlý motív',
|
||||
switch_to_system_theme: 'Prepnúť na systémový motív',
|
||||
search: 'Hľadať',
|
||||
skip_to_content: 'Preskočiť na obsah',
|
||||
clear: 'Vymazať',
|
||||
table_filtered_by_selection: 'Zodpovedá výberu: ${1}',
|
||||
table_clear_selection: 'Zrušiť výber',
|
||||
|
||||
@@ -10,6 +10,7 @@ export const sl: TranslationLanguage = {
|
||||
switch_to_light_theme: 'Preklopi na svetlo temo',
|
||||
switch_to_system_theme: 'Preklopi na sistemsko temo',
|
||||
search: 'Išči',
|
||||
skip_to_content: 'Preskoči na vsebino',
|
||||
clear: 'Počisti',
|
||||
table_filtered_by_selection: 'Ustreza izbiri: ${1}',
|
||||
table_clear_selection: 'Počisti izbiro',
|
||||
|
||||
@@ -10,6 +10,7 @@ export const sv: TranslationLanguage = {
|
||||
switch_to_light_theme: 'Byt till ljust tema',
|
||||
switch_to_system_theme: 'Byt till systemtema',
|
||||
search: 'Sök',
|
||||
skip_to_content: 'Hoppa till innehåll',
|
||||
clear: 'Rensa',
|
||||
table_filtered_by_selection: 'Matchar val: ${1}',
|
||||
table_clear_selection: 'Rensa val',
|
||||
|
||||
@@ -10,6 +10,7 @@ export const th: TranslationLanguage = {
|
||||
switch_to_light_theme: 'เปลี่ยนเป็นธีมสว่าง',
|
||||
switch_to_system_theme: 'เปลี่ยนเป็นธีมของระบบ',
|
||||
search: 'ค้นหา',
|
||||
skip_to_content: 'ข้ามไปยังเนื้อหา',
|
||||
clear: 'ล้าง',
|
||||
table_filtered_by_selection: 'ตรงกับการเลือก: ${1}',
|
||||
table_clear_selection: 'ล้างการเลือก',
|
||||
|
||||
@@ -10,6 +10,7 @@ export const tr: TranslationLanguage = {
|
||||
switch_to_light_theme: 'Açık temaya geç',
|
||||
switch_to_system_theme: 'Sistem temasına geç',
|
||||
search: 'Ara',
|
||||
skip_to_content: 'İçeriğe geç',
|
||||
clear: 'Temizle',
|
||||
table_filtered_by_selection: 'Seçimle eşleşiyor: ${1}',
|
||||
table_clear_selection: 'Seçimi temizle',
|
||||
|
||||
@@ -10,6 +10,7 @@ export const uk: TranslationLanguage = {
|
||||
switch_to_light_theme: 'Перемкнути на світлу тему',
|
||||
switch_to_system_theme: 'Перемкнути на системну тему',
|
||||
search: 'Пошук',
|
||||
skip_to_content: 'Перейти до вмісту',
|
||||
clear: 'Очистити',
|
||||
table_filtered_by_selection: 'Відповідає вибору: ${1}',
|
||||
table_clear_selection: 'Очистити вибір',
|
||||
|
||||
@@ -10,6 +10,7 @@ export const vi: TranslationLanguage = {
|
||||
switch_to_light_theme: 'Chuyển sang giao diện sáng',
|
||||
switch_to_system_theme: 'Chuyển sang giao diện hệ thống',
|
||||
search: 'Tìm kiếm',
|
||||
skip_to_content: 'Chuyển đến nội dung',
|
||||
clear: 'Xóa',
|
||||
table_filtered_by_selection: 'Khớp với lựa chọn: ${1}',
|
||||
table_clear_selection: 'Xóa lựa chọn',
|
||||
|
||||
@@ -10,6 +10,7 @@ export const yue: TranslationLanguage = {
|
||||
switch_to_light_theme: '切換到淺色主題',
|
||||
switch_to_system_theme: '切換到系統主題',
|
||||
search: '搜尋',
|
||||
skip_to_content: '跳至內容',
|
||||
clear: '清除',
|
||||
table_filtered_by_selection: '符合選擇:${1}',
|
||||
table_clear_selection: '清除選擇',
|
||||
|
||||
@@ -10,6 +10,7 @@ export const zh_tw: TranslationLanguage = {
|
||||
switch_to_light_theme: '切換至淺色主題',
|
||||
switch_to_system_theme: '切換至系統主題',
|
||||
search: '搜尋',
|
||||
skip_to_content: '跳至內容',
|
||||
clear: '清除',
|
||||
table_filtered_by_selection: '符合選擇:${1}',
|
||||
table_clear_selection: '清除選擇',
|
||||
|
||||
@@ -10,6 +10,7 @@ export const zh: TranslationLanguage = {
|
||||
switch_to_light_theme: '切换到浅色主题',
|
||||
switch_to_system_theme: '切换到系统主题',
|
||||
search: '搜索',
|
||||
skip_to_content: '跳转到内容',
|
||||
clear: '清除',
|
||||
table_filtered_by_selection: '符合选择:${1}',
|
||||
table_clear_selection: '清除选择',
|
||||
|
||||
@@ -53,11 +53,14 @@ export const Icon = React.forwardRef(function Icon(
|
||||
const [iconStyle, icon] = getIconStyle(propIconStyle, propIcon);
|
||||
const source = context.iconSources?.[getInlineIconSourceKey(iconStyle, icon)];
|
||||
const maskId = React.useId();
|
||||
// Icons are decorative unless the caller names them; the control they sit in carries the name.
|
||||
const isDecorative = !rest['aria-label'] && !rest['aria-labelledby'] && !rest.role;
|
||||
|
||||
if (source) {
|
||||
return (
|
||||
<svg
|
||||
ref={ref}
|
||||
aria-hidden={isDecorative ? true : undefined}
|
||||
{...rest}
|
||||
viewBox={source.viewBox}
|
||||
fill="currentColor"
|
||||
@@ -77,6 +80,7 @@ export const Icon = React.forwardRef(function Icon(
|
||||
return (
|
||||
<svg
|
||||
ref={ref}
|
||||
aria-hidden={isDecorative ? true : undefined}
|
||||
{...rest}
|
||||
style={{
|
||||
...(size ? { width: size, height: size } : {}),
|
||||
@@ -84,7 +88,6 @@ export const Icon = React.forwardRef(function Icon(
|
||||
}}
|
||||
className={`gb-icon ${className}`}
|
||||
>
|
||||
<title>{icon}</title>
|
||||
<defs>
|
||||
<mask
|
||||
id={maskId}
|
||||
|
||||
Reference in New Issue
Block a user