✨(frontend) add document visible in list and openable via enter key
the document now appears in the list and can be opened using the enter key Signed-off-by: Cyril <c.gromoff@gmail.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import { Tooltip, useModal } from '@openfun/cunningham-react';
|
import { Tooltip, useModal } from '@openfun/cunningham-react';
|
||||||
import { DateTime } from 'luxon';
|
import { DateTime } from 'luxon';
|
||||||
|
import { useRouter } from 'next/router';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { css } from 'styled-components';
|
import { css } from 'styled-components';
|
||||||
|
|
||||||
@@ -21,6 +22,7 @@ type DocsGridItemProps = {
|
|||||||
|
|
||||||
export const DocsGridItem = ({ doc, dragMode = false }: DocsGridItemProps) => {
|
export const DocsGridItem = ({ doc, dragMode = false }: DocsGridItemProps) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
const router = useRouter();
|
||||||
const { isDesktop } = useResponsiveStore();
|
const { isDesktop } = useResponsiveStore();
|
||||||
const { flexLeft, flexRight } = useResponsiveDocGrid();
|
const { flexLeft, flexRight } = useResponsiveDocGrid();
|
||||||
const { spacingsTokens } = useCunninghamTheme();
|
const { spacingsTokens } = useCunninghamTheme();
|
||||||
@@ -33,6 +35,13 @@ export const DocsGridItem = ({ doc, dragMode = false }: DocsGridItemProps) => {
|
|||||||
shareModal.open();
|
shareModal.open();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleKeyDown = (e: React.KeyboardEvent) => {
|
||||||
|
if (e.key === 'Enter' || e.key === ' ') {
|
||||||
|
e.preventDefault();
|
||||||
|
void router.push(`/docs/${doc.id}`);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Box
|
<Box
|
||||||
@@ -52,6 +61,10 @@ export const DocsGridItem = ({ doc, dragMode = false }: DocsGridItemProps) => {
|
|||||||
}
|
}
|
||||||
`}
|
`}
|
||||||
className="--docs--doc-grid-item"
|
className="--docs--doc-grid-item"
|
||||||
|
onKeyDown={handleKeyDown}
|
||||||
|
aria-label={t('Open document: {{title}}', {
|
||||||
|
title: doc.title || t('Untitled document'),
|
||||||
|
})}
|
||||||
>
|
>
|
||||||
<Box
|
<Box
|
||||||
$flex={flexLeft}
|
$flex={flexLeft}
|
||||||
|
|||||||
@@ -372,6 +372,7 @@
|
|||||||
"Open the document options": "Öffnen Sie die Dokumentoptionen",
|
"Open the document options": "Öffnen Sie die Dokumentoptionen",
|
||||||
"Open the header menu": "Öffne das Kopfzeilen-Menü",
|
"Open the header menu": "Öffne das Kopfzeilen-Menü",
|
||||||
"Open document actions menu": "Dokumentaktionsmenü öffnen",
|
"Open document actions menu": "Dokumentaktionsmenü öffnen",
|
||||||
|
"Open document: {{title}}": "Dokument öffnen: {{title}}",
|
||||||
"Main content": "Hauptinhalt",
|
"Main content": "Hauptinhalt",
|
||||||
"Home content": "Startseiten-Inhalt",
|
"Home content": "Startseiten-Inhalt",
|
||||||
"Documents grid": "Dokumentenraster",
|
"Documents grid": "Dokumentenraster",
|
||||||
@@ -478,6 +479,7 @@
|
|||||||
"Cancel the deletion": "Cancel the deletion",
|
"Cancel the deletion": "Cancel the deletion",
|
||||||
"Cancel the download": "Cancel the download",
|
"Cancel the download": "Cancel the download",
|
||||||
"Open actions menu for document: {{title}}": "Open actions menu for document: {{title}}",
|
"Open actions menu for document: {{title}}": "Open actions menu for document: {{title}}",
|
||||||
|
"Open document: {{title}}": "Open document: {{title}}",
|
||||||
"Open the menu of actions for the document: {{title}}": "Open the menu of actions for the document: {{title}}",
|
"Open the menu of actions for the document: {{title}}": "Open the menu of actions for the document: {{title}}",
|
||||||
"Share with {{count}} users_one": "Share with {{count}} user",
|
"Share with {{count}} users_one": "Share with {{count}} user",
|
||||||
"Shared with {{count}} users_many": "Shared with {{count}} users",
|
"Shared with {{count}} users_many": "Shared with {{count}} users",
|
||||||
@@ -607,6 +609,7 @@
|
|||||||
"Open the document options": "Abrir las opciones del documento",
|
"Open the document options": "Abrir las opciones del documento",
|
||||||
"Open the header menu": "Abrir el menú de encabezado",
|
"Open the header menu": "Abrir el menú de encabezado",
|
||||||
"Open document actions menu": "Abrir menú de acciones del documento",
|
"Open document actions menu": "Abrir menú de acciones del documento",
|
||||||
|
"Open document: {{title}}": "Abrir documento: {{title}}",
|
||||||
"Main content": "Contenido principal",
|
"Main content": "Contenido principal",
|
||||||
"Home content": "Contenido de inicio",
|
"Home content": "Contenido de inicio",
|
||||||
"Documents grid": "Lista de documentos",
|
"Documents grid": "Lista de documentos",
|
||||||
@@ -839,6 +842,7 @@
|
|||||||
"Open the document options": "Ouvrir les options du document",
|
"Open the document options": "Ouvrir les options du document",
|
||||||
"Open the header menu": "Ouvrir le menu d'en-tête",
|
"Open the header menu": "Ouvrir le menu d'en-tête",
|
||||||
"Open document actions menu": "Ouvrir le menu d'actions du document",
|
"Open document actions menu": "Ouvrir le menu d'actions du document",
|
||||||
|
"Open document: {{title}}": "Ouvrir le document : {{title}}",
|
||||||
"Open the menu of actions for the document: {{title}}": "Ouvrir le menu des actions du document : {{title}}",
|
"Open the menu of actions for the document: {{title}}": "Ouvrir le menu des actions du document : {{title}}",
|
||||||
"Main content": "Contenu principal",
|
"Main content": "Contenu principal",
|
||||||
"Home content": "Contenu d'accueil",
|
"Home content": "Contenu d'accueil",
|
||||||
@@ -1204,6 +1208,7 @@
|
|||||||
"Open the document options": "Open document opties",
|
"Open the document options": "Open document opties",
|
||||||
"Open the header menu": "Open het hoofdmenu",
|
"Open the header menu": "Open het hoofdmenu",
|
||||||
"Open document actions menu": "Open documentactiemenu",
|
"Open document actions menu": "Open documentactiemenu",
|
||||||
|
"Open document: {{title}}": "Document openen: {{title}}",
|
||||||
"Main content": "Hoofdinhoud",
|
"Main content": "Hoofdinhoud",
|
||||||
"Home content": "Startpagina-inhoud",
|
"Home content": "Startpagina-inhoud",
|
||||||
"Documents grid": "Documentenraster",
|
"Documents grid": "Documentenraster",
|
||||||
|
|||||||
Reference in New Issue
Block a user