Done.js
1 month ago
Integrations.js
1 month ago
PremiumFeatures.js
1 month ago
UserInfo.js
1 month ago
Welcome.js
1 month ago
Welcome.js
123 lines
| 1 | import { useState, useEffect } from "react"; |
| 2 | import { Button, Text, Title, Container } from "@bsf/force-ui"; |
| 3 | import { ChevronRight, Check, Play, X } from "lucide-react"; |
| 4 | |
| 5 | const { __ } = wp.i18n; |
| 6 | |
| 7 | const VIDEO_ID = "7ibtk_KTgCw"; |
| 8 | const THUMBNAIL_URL = `https://img.youtube.com/vi/${VIDEO_ID}/maxresdefault.jpg`; |
| 9 | |
| 10 | const HIGHLIGHTS = [ |
| 11 | __("Embed YouTube, Vimeo, Bunny.net, self-hosted videos, and audio", "presto-player"), |
| 12 | __("Customize controls, branding, and chapter markers", "presto-player"), |
| 13 | __("Capture leads with opt-in gates and in-video CTAs", "presto-player"), |
| 14 | __("Works with Gutenberg, Elementor, Divi, and major LMS plugins", "presto-player"), |
| 15 | ]; |
| 16 | |
| 17 | const Welcome = ({ goToNextStep }) => { |
| 18 | const [isVideoOpen, setIsVideoOpen] = useState(false); |
| 19 | |
| 20 | useEffect(() => { |
| 21 | if (!isVideoOpen) return; |
| 22 | const handleKeyDown = (e) => { |
| 23 | if (e.key === "Escape") setIsVideoOpen(false); |
| 24 | }; |
| 25 | document.addEventListener("keydown", handleKeyDown); |
| 26 | return () => document.removeEventListener("keydown", handleKeyDown); |
| 27 | }, [isVideoOpen]); |
| 28 | |
| 29 | return ( |
| 30 | <> |
| 31 | <Container direction="column" gap="lg" className="gap-6"> |
| 32 | <Container direction="column" gap="xs"> |
| 33 | <Title |
| 34 | size="lg" |
| 35 | tag="h2" |
| 36 | title={__("Welcome to Presto Player", "presto-player")} |
| 37 | className="text-[30px] leading-[38px]" |
| 38 | /> |
| 39 | <Text size={16} weight={500}> |
| 40 | {__("The Professional Video Player for WordPress.", "presto-player")} |
| 41 | </Text> |
| 42 | </Container> |
| 43 | |
| 44 | <div |
| 45 | className="cursor-pointer group" |
| 46 | onClick={() => setIsVideoOpen(true)} |
| 47 | role="button" |
| 48 | aria-label={__("Play introduction video", "presto-player")} |
| 49 | tabIndex={0} |
| 50 | onKeyDown={(e) => { |
| 51 | if (e.key === "Enter" || e.key === " ") { |
| 52 | e.preventDefault(); |
| 53 | setIsVideoOpen(true); |
| 54 | } |
| 55 | }} |
| 56 | > |
| 57 | <div className="relative w-full overflow-hidden rounded-xl"> |
| 58 | <img |
| 59 | src={THUMBNAIL_URL} |
| 60 | alt={__("Presto Player Introduction", "presto-player")} |
| 61 | className="w-full h-auto object-cover block" |
| 62 | /> |
| 63 | <div className="absolute inset-0 bg-black bg-opacity-0 group-hover:bg-opacity-10 transition-all duration-200" /> |
| 64 | <div className="absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-16 h-16 flex items-center justify-center bg-white bg-opacity-90 rounded-full shadow-lg group-hover:scale-110 transition-transform duration-200"> |
| 65 | <Play className="size-7 text-brand-primary-600 ml-1 fill-current" /> |
| 66 | </div> |
| 67 | </div> |
| 68 | </div> |
| 69 | |
| 70 | <Container direction="column" gap="xs"> |
| 71 | {HIGHLIGHTS.map((text, index) => ( |
| 72 | <Container key={index} direction="row" align="center" gap="xs"> |
| 73 | <Check className="size-4 text-icon-interactive flex-shrink-0" /> |
| 74 | <Text size={14} weight={600} color="secondary"> |
| 75 | {text} |
| 76 | </Text> |
| 77 | </Container> |
| 78 | ))} |
| 79 | </Container> |
| 80 | |
| 81 | <hr className="border-t border-solid border-border-subtle border-b-0 m-0 w-full" /> |
| 82 | |
| 83 | <Container direction="row" justify="start" align="center"> |
| 84 | <Button |
| 85 | className="px-4 w-max" |
| 86 | iconPosition="right" |
| 87 | icon={<ChevronRight />} |
| 88 | onClick={goToNextStep} |
| 89 | > |
| 90 | {__("Let's Get Started", "presto-player")} |
| 91 | </Button> |
| 92 | </Container> |
| 93 | </Container> |
| 94 | |
| 95 | { isVideoOpen && ( |
| 96 | <div |
| 97 | className="fixed inset-0 flex items-center justify-center bg-black bg-opacity-70 cursor-pointer w-screen z-[999999]" |
| 98 | onClick={ () => setIsVideoOpen( false ) } |
| 99 | > |
| 100 | <div className="text-white absolute top-4 right-4 flex items-center gap-2"> |
| 101 | <span className="text-sm font-medium">{ __( 'Esc', 'presto-player' ) }</span> |
| 102 | <X size={ 20 } className="cursor-pointer" onClick={ () => setIsVideoOpen( false ) } /> |
| 103 | </div> |
| 104 | <div |
| 105 | className="relative rounded-lg shadow-lg w-4/5 cursor-default" |
| 106 | onClick={ ( e ) => e.stopPropagation() } |
| 107 | > |
| 108 | <iframe |
| 109 | className="w-full lg:h-188 sm:h-120 h-60 rounded-lg border-0" |
| 110 | src={ `https://www.youtube-nocookie.com/embed/${VIDEO_ID}?autoplay=1` } |
| 111 | title={ __( 'Presto Player Introduction', 'presto-player' ) } |
| 112 | allow="autoplay; encrypted-media" |
| 113 | allowFullScreen |
| 114 | /> |
| 115 | </div> |
| 116 | </div> |
| 117 | ) } |
| 118 | </> |
| 119 | ); |
| 120 | }; |
| 121 | |
| 122 | export default Welcome; |
| 123 |