-
Notifications
You must be signed in to change notification settings - Fork 1
feat: immagine copertina aggiunta e focus sistemato #1124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| import { useState, useRef, useEffect } from 'react'; | ||
|
|
||
| /** | ||
| * Manage the activation of a semantic-ui Embed video (a fake play button shown | ||
| * over a preview/cover image) and move focus to the real video iframe as soon | ||
| * as it is rendered. | ||
| * | ||
| * When a cover image is set, the only focusable element is the fake play button; | ||
| * once activated, semantic-ui hides the placeholder and the play icon | ||
| * (display: none), which would otherwise drop focus on the <body>. Screen | ||
| * reader and keyboard users would then lose the context and not realize a video | ||
| * appeared. Controlling the `active` state lets us move focus into the freshly | ||
| * mounted iframe instead. | ||
| * | ||
| * Usage: | ||
| * const { wrapperRef, active, activate } = useVideoEmbedFocus(); | ||
| * <div ref={wrapperRef}> | ||
| * <Embed active={active} onClick={activate} ... /> | ||
| * </div> | ||
| */ | ||
| export const useVideoEmbedFocus = () => { | ||
| const wrapperRef = useRef(null); | ||
| const [active, setActive] = useState(false); | ||
|
|
||
| useEffect(() => { | ||
| if (!active || !wrapperRef.current) { | ||
| return; | ||
| } | ||
| const iframe = wrapperRef.current.querySelector('iframe'); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. non per forza c'è un tag <iframe> |
||
| if (iframe) { | ||
| iframe.setAttribute('tabindex', '0'); | ||
| iframe.focus(); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. così fa solo il focus sull'iframe sempre, e non lo fa piu sul bottone play dell'embed di youtube? |
||
| } | ||
| }, [active]); | ||
|
|
||
| const activate = () => setActive(true); | ||
|
|
||
| return { wrapperRef, active, activate }; | ||
| }; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
occhio che placeholder può essere null