投稿時間:2023-05-23 19:30:14 RSSフィード2023-05-23 19:00 分まとめ(36件)

カテゴリー等 サイト名等 記事タイトル・トレンドワード等 リンクURL 頻出ワード・要約等/検索ボリューム 登録日
IT ITmedia 総合記事一覧 [ITmedia News] 富士通、コンビニ交付システムを一斉点検へ 最大で6月4日まで 証明書発行は利用不可に https://www.itmedia.co.jp/news/articles/2305/23/news190.html itmedia 2023-05-23 18:49:00
IT ITmedia 総合記事一覧 [ITmedia News] 任天堂、「Wii U」の修理サービスを終了へ 部品在庫がなくなるまで対応 販売から10年超で https://www.itmedia.co.jp/news/articles/2305/23/news188.html itmedia 2023-05-23 18:34:00
AWS lambdaタグが付けられた新着投稿 - Qiita 【データ基盤構築/AWS】IAMのPassRoleで権限を渡すこととロールにポリシーアタッチして権限を渡すことの違い https://qiita.com/Ayumu-y/items/ea586360151775769aac passrole 2023-05-23 18:53:02
python Pythonタグが付けられた新着投稿 - Qiita 【Paiza問題集】標準出力メニュー/n*nの2次元配列の表示 https://qiita.com/norma2627/items/da3bd35ca64c1dfa0fc6 paiza 2023-05-23 18:17:32
python Pythonタグが付けられた新着投稿 - Qiita ポーカーをコンピュータと対戦できるプログラムを書いてみた https://qiita.com/ryo_yasuda/items/f7d0c77ffb164d9d6f86 開発 2023-05-23 18:00:21
js JavaScriptタグが付けられた新着投稿 - Qiita Falcorのインストール方法 https://qiita.com/omo_taku/items/1dfd3b367a55bddb53b1 qiita 2023-05-23 18:57:16
js JavaScriptタグが付けられた新着投稿 - Qiita 【初心者】React,Next.jsの門をたたくために利用した教材の共有 https://qiita.com/ryosuke-horie/items/7599bca808c6f0a6e5b4 phplaravel 2023-05-23 18:33:41
js JavaScriptタグが付けられた新着投稿 - Qiita [Vue.js]Vue-multiselectで綺麗なセレクトボックスを秒で実装する https://qiita.com/miya_shu/items/2f0116b51bb677611840 vuejs 2023-05-23 18:11:30
js JavaScriptタグが付けられた新着投稿 - Qiita [備忘録] jsで任意のulにliを追加する方法 https://qiita.com/kurama_/items/64c248fb8a596f276835 tdocumentgetelementbyidli 2023-05-23 18:09:50
Linux Ubuntuタグが付けられた新着投稿 - Qiita Dockerコンテナ内で「E: Unable to locate package 」と表示された https://qiita.com/naotwu/items/fb6e302d538f43cd0c5a docker 2023-05-23 18:41:48
AWS AWSタグが付けられた新着投稿 - Qiita 【データ基盤構築/AWS】IAMのPassRoleで権限を渡すこととロールにポリシーアタッチして権限を渡すことの違い https://qiita.com/Ayumu-y/items/ea586360151775769aac passrole 2023-05-23 18:53:02
AWS AWSタグが付けられた新着投稿 - Qiita SageMakerを用いたPytorchとビルトインパターンでのAIモデル実装比較 https://qiita.com/tammy2/items/64b814b2517fccef6732 pytorch 2023-05-23 18:22:25
Docker dockerタグが付けられた新着投稿 - Qiita Dockerコンテナ内で「E: Unable to locate package 」と表示された https://qiita.com/naotwu/items/fb6e302d538f43cd0c5a docker 2023-05-23 18:41:48
技術ブログ Developers.IO Lambda 関数で Secrets Manager から直接データを取るようにしてみた https://dev.classmethod.jp/articles/try-to-get-direct-from-secrets-manager/ awscdk 2023-05-23 09:28:08
技術ブログ Developers.IO 評価の土台 – キャリア志向の把握 https://dev.classmethod.jp/articles/base-of-evaluation-career/ 人事評価 2023-05-23 09:10:17
技術ブログ Developers.IO [レポート] Looker StudioからLookerへの移行で『スタディサプリ』の事業支援とガバナンス強化の両方を改善 #GoogleCloudDay https://dev.classmethod.jp/articles/report-google-cloud-day-23-tour-migration-looker-studio-to-looker/ looker 2023-05-23 09:10:04
技術ブログ Developers.IO CloudFormationでS3バケットに複数のバケットポリシーを割り当てようとした際の挙動 https://dev.classmethod.jp/articles/attach-multiple-bucket-policy-by-cloudformation/ cloudformation 2023-05-23 09:05:51
海外TECH DEV Community How to Build a Modal Video Component with Tailwind CSS and Vue https://dev.to/cruip_com/how-to-build-a-modal-video-component-with-tailwind-css-and-vue-aih How to Build a Modal Video Component with Tailwind CSS and Vue Live Demo Download Welcome to the third and final part of our series on How to Build a Video Modal Component In this tutorial we will create a fully functional video modal component using Vue and Tailwind CSS complete with TypeScript support Please note that we won t cover the step by step process of setting up a Vue app However we highly recommend using Vite as a build tool as it makes creating a Vue app effortless with a simple command in the Terminal After you ve set up your app the next step is to install Tailwind CSS and import the Tailwind directives into your CSS file If you need inspiration you can check out how we previously built this component in Talent a recruitment website template and Docs a documentation website template Let s get started We ll be using a single file component and naming it ModalVideo vue lt script setup lang ts gt lt script gt lt template gt lt div gt lt The button gt lt The backdrop layer gt lt The modal video gt lt div gt lt template gt Within the template tag we will include the three essential elements required to create our component the button backdrop and modal housing the video Define the modal initial stateWe need to establish the initial state of our modal that can either be open or closed and we ll accomplish this by using a boolean ref that has a default value of false i e closed We ll then assign this ref to the variable modalOpen lt script setup lang ts gt import ref from vue const modalOpen ref lt boolean gt false lt script gt lt template gt lt div gt lt The button gt lt The backdrop layer gt lt The modal video gt lt div gt lt template gt Toggling the modal stateNow when a user clicks on the thumbnail we want modalOpen to change to true Vue provides v on directives that allow us to listen to DOM events and execute some JavaScript when they re triggered In this case we ll be using the v on click directive or click in its shortened version to change the modalOpen state upon clicking lt script setup lang ts gt import ref from vue const modalOpen ref lt boolean gt false lt script gt lt template gt lt div gt lt The button gt lt button class relative flex justify center items center focus outline none focus visible ring focus visible ring indigo rounded xl group click modalOpen true aria label Watch the video gt lt img class rounded xl shadow xl transition shadow duration ease in out src assets modal video thumb jpg width height alt Modal video thumbnail gt lt Play icon gt lt svg class absolute pointer events none group hover scale transition transform duration ease in out xmlns lt width height gt lt circle class fill white cx cy r fill opacity gt lt path class fill indigo drop shadow xl d M a l A Va l A Vc Z gt lt svg gt lt button gt lt The backdrop layer gt lt The modal video gt lt div gt lt template gt Handling modal visibility and adding enter leave transitionsAt this point we need to link the modal s visibility to the modalOpen variable state and display it when true while hiding it when false Additionally we want the modal with the video to enter smoothly with a scale up transition and exit with a scale down Although Vue provides a built in Transition component to accomplish this we prefer using the Headless UI library because it offers a Dialog component that s readily available and fully accessible Let s install the Headless UI for Vue version using the command npm install headlessui vue in the terminal and import the required components into our component file which we ll use as follows lt script setup lang ts gt import ref from vue import Dialog DialogPanel TransitionRoot TransitionChild from headlessui vue const modalOpen ref lt boolean gt false lt script gt lt template gt lt div gt lt The button gt lt button class relative flex justify center items center focus outline none focus visible ring focus visible ring indigo rounded xl group click modalOpen true aria label Watch the video gt lt img class rounded xl shadow xl transition shadow duration ease in out src assets modal video thumb jpg width height alt Modal video thumbnail gt lt Play icon gt lt svg class absolute pointer events none group hover scale transition transform duration ease in out xmlns lt width height gt lt circle class fill white cx cy r fill opacity gt lt path class fill indigo drop shadow xl d M a l A Va l A Vc Z gt lt svg gt lt button gt lt TransitionRoot show modalOpen as template gt lt Dialog close modalOpen false gt lt Modal backdrop gt lt TransitionChild className fixed inset z bg black bg opacity transition opacity enter transition ease out duration enterFrom opacity enterTo opacity leave transition ease out duration leaveFrom opacity leaveTo opacity aria hidden true gt lt End Modal backdrop gt lt Modal dialog gt lt TransitionChild className fixed inset z flex p enter transition ease out duration enterFrom opacity scale enterTo opacity scale leave transition ease out duration leaveFrom opacity scale leaveTo opacity scale gt lt div class max w xl mx auto h full flex items center gt lt DialogPanel class w full max h full rounded xl shadow xl aspect video bg black overflow hidden gt lt video loop controls gt lt source src assets video mp width height type video mp gt Your browser does not support the video tag lt video gt lt DialogPanel gt lt div gt lt TransitionChild gt lt End Modal dialog gt lt Dialog gt lt TransitionRoot gt lt div gt lt template gt If you read our previous article on creating a video modal with Next js you may have noticed that the structure of this component is quite similar but with some small differences We have a TransitionRoot component that contains both the backdrop and the modal which can receive the modal s state through the show property and transmit it to the two TransitionChild components The TransitionChild components use the enter enterFrom enterTo leave leaveFrom and leaveTo properties to define the CSS classes that define the entrance and exit transitions The Dialog component provides a close event listener that allows us to set the modalOpen variable to false when clicking outside the dialog element or pressing the escape key By doing so the modal will automatically close Although the component is fully functional at this point some adjustments may still be necessary For example we may want the video to start playing automatically when the modal is opened Let s see how to do it k Playing the video automatically when the modal opensTo start we need to reference the video element so that we can initiate playback This is done using a ref Then leveraging the power of the Composition API we can use a watcher that detects any changes in the modalOpen variable This watcher will play the videoRef automatically when it appears in the DOM Thanks to TypeScript we can check the existence of videoRef with a single line of code watch videoRef gt videoRef value play Finally we can use the initialFocus property provided by the Dialog component to give focus to the video when the modal is opened And here s the final code lt script setup lang ts gt import ref from vue import Dialog DialogPanel TransitionRoot TransitionChild from headlessui vue const modalOpen ref lt boolean gt false const videoRef ref lt HTMLVideoElement null gt null watch videoRef gt videoRef value play lt script gt lt template gt lt div gt lt The button gt lt button class relative flex justify center items center focus outline none focus visible ring focus visible ring indigo rounded xl group click modalOpen true aria label Watch the video gt lt img class rounded xl shadow xl transition shadow duration ease in out src assets modal video thumb jpg width height alt Modal video thumbnail gt lt Play icon gt lt svg class absolute pointer events none group hover scale transition transform duration ease in out xmlns lt width height gt lt circle class fill white cx cy r fill opacity gt lt path class fill indigo drop shadow xl d M a l A Va l A Vc Z gt lt svg gt lt button gt lt TransitionRoot show modalOpen as template gt lt Dialog initialFocus videoRef close modalOpen false gt lt Modal backdrop gt lt TransitionChild className fixed inset z bg black bg opacity transition opacity enter transition ease out duration enterFrom opacity enterTo opacity leave transition ease out duration leaveFrom opacity leaveTo opacity aria hidden true gt lt End Modal backdrop gt lt Modal dialog gt lt TransitionChild className fixed inset z flex p enter transition ease out duration enterFrom opacity scale enterTo opacity scale leave transition ease out duration leaveFrom opacity scale leaveTo opacity scale gt lt div class max w xl mx auto h full flex items center gt lt DialogPanel class w full max h full rounded xl shadow xl aspect video bg black overflow hidden gt lt video ref videoRef loop controls gt lt source src assets video mp width height type video mp gt Your browser does not support the video tag lt video gt lt DialogPanel gt lt div gt lt TransitionChild gt lt End Modal dialog gt lt Dialog gt lt TransitionRoot gt lt div gt lt template gt You can import and use the completed component in another component by using lt ModalVideo gt Now let s explore how to modify the component to make it reusable by allowing for different thumbnails and videos to be passed in Making the modal video component reusableThe properties we want to pass to the ModalVideo component are The source attribute src of the thumbnail image The dimensions of the thumbnail image The alternative text alt for the thumbnail image The source attribute src of the video The dimensions of the video lt ModalVideo thumb VideoThumb thumbWidth thumbHeight video VideoSrc videoWidth videoHeight gt Let s now go back to the ModalVideo vue file and list the properties also defining an object with a TypeScript interface interface Props thumb string thumbWidth number thumbHeight number video string videoWidth number videoHeight number const props defineProps lt Props gt ConclusionsSo here is the final result of the Modal Video component built using Vue TypeScript and Tailwind CSS lt script setup lang ts gt import ref watch from vue import Dialog DialogPanel TransitionRoot TransitionChild from headlessui vue const modalOpen ref lt boolean gt false const videoRef ref lt HTMLVideoElement null gt null watch videoRef gt videoRef value play interface Props thumb string thumbWidth number thumbHeight number video string videoWidth number videoHeight number const props defineProps lt Props gt lt script gt lt template gt lt div gt lt Video thumbnail gt lt button class relative flex justify center items center focus outline none focus visible ring focus visible ring indigo rounded xl group click modalOpen true aria label Watch the video gt lt img class rounded xl shadow xl transition shadow duration ease in out src props thumb width props thumbWidth height props thumbHeight alt Modal video thumbnail gt lt Play icon gt lt svg class absolute pointer events none group hover scale transition transform duration ease in out xmlns lt width height gt lt circle class fill white cx cy r fill opacity gt lt path class fill indigo drop shadow xl d M a l A Va l A Vc Z gt lt svg gt lt button gt lt End Video thumbnail gt lt TransitionRoot show modalOpen as template gt lt Dialog initialFocus videoRef close modalOpen false gt lt Modal backdrop gt lt TransitionChild className fixed inset z bg black bg opacity transition opacity enter transition ease out duration enterFrom opacity enterTo opacity leave transition ease out duration leaveFrom opacity leaveTo opacity aria hidden true gt lt End Modal backdrop gt lt Modal dialog gt lt TransitionChild className fixed inset z flex p enter transition ease out duration enterFrom opacity scale enterTo opacity scale leave transition ease out duration leaveFrom opacity scale leaveTo opacity scale gt lt div class max w xl mx auto h full flex items center gt lt DialogPanel class w full max h full rounded xl shadow xl aspect video bg black overflow hidden gt lt video ref videoRef loop controls gt lt source src props video width props videoWidth height props videoHeight type video mp gt Your browser does not support the video tag lt video gt lt DialogPanel gt lt div gt lt TransitionChild gt lt End Modal dialog gt lt Dialog gt lt TransitionRoot gt lt div gt lt template gt As we discussed in the first and second parts of this series you can use this component in a variety of ways e g product tours app presentations etc as it works well with any type of website landing page or web app If you re interested in learning how to build this component in Alpine js and Next js check out the first and second parts of the series How to Build a Modal Video Component with Tailwind CSS and Alpine js How to Build a Modal Video Component with Tailwind CSS and Next js 2023-05-23 09:30:29
海外TECH DEV Community How to Build a Modal Video Component with Tailwind CSS and Next.js https://dev.to/cruip_com/how-to-build-a-modal-video-component-with-tailwind-css-and-nextjs-5io How to Build a Modal Video Component with Tailwind CSS and Next js Live Demo Download Welcome to the second part of the series of How to Build a Video Modal Component with Tailwind CSS In the previous part we learned how to create a modal video component using Tailwind CSS and Alpine js In this article we will level up the game and show you how to create a reusable component for Next js using TypeScript Before we dive in it s important to note that we won t be covering how to get started with Next js We recommend referring to the official documentation for that Instead we ll focus on building the component using Next js with the App Router app and React Server Components If you re interested in seeing how we previously built some modal video components in Next js we suggest checking out Tidy an elegant HTML website template and Appy a mobile web design template Let s start by sketching out our component by creating a file called modal video tsx and defining the function to export use client export default function ModalVideo return lt div gt The button The backdrop layer The modal video lt div gt For the structure we are using the same HTML structure we created before with Tailwind CSS remembering to replace the class attributes with className to ensure compatibility with React Additionally we use the use client directive at the top of the file and before any imports because we know that this component requires client side interactivity Define the modal initial state with useStateNow let s define the initial state of the modal whether it should be open or closed We can achieve this by using the useState hook from React and setting the initial state to false By setting the initial state of the modal we ensure that it s closed by default Later we ll create a function that updates the state of the modal when a user interacts with it This way the modal will only appear when a user clicks on the thumbnail use client export default function ModalVideo const modalOpen setModalOpen useState lt boolean gt false return lt div gt The button The backdrop layer The modal video lt div gt Toggling the modal stateNow that we ve defined the initial state of the modal let s move on to toggling its state To achieve this add the button markup to our component and include an onClick event that changes the modalOpen state variable to true By doing this we ll trigger the modal to open when the user clicks on the thumbnail use client import Image from next image import VideoThumb from public modal video thumb jpg export default function ModalVideo const modalOpen setModalOpen useState lt boolean gt false return lt div gt The button lt button className relative flex justify center items center focus outline none focus visible ring focus visible ring indigo rounded xl group onClick gt setModalOpen true aria label Watch the video gt lt Image className rounded xl shadow xl transition shadow duration ease in out src VideoThumb width height priority alt Modal video thumbnail gt Play icon lt svg className absolute pointer events none group hover scale transition transform duration ease in out xmlns width height gt lt circle className fill white cx cy r fillOpacity gt lt path className fill indigo drop shadow xl d M a l A Va l A Vc Z gt lt svg gt lt button gt The backdrop layer The modal video lt div gt Handling modal visibility and adding enter leave transitionsNow that we can toggle the modal state we need to make sure that the visibility of the backdrop layer and the modal video are linked to the modalOpen state variable Additionally we want to add enter and leave transitions every time the modal is opened or closed One option is to use the React Transition Group library to achieve this but we should also handle accessibility and integrate the component with functions that close the modal when the backdrop layer is clicked or the escape key is pressed Alternatively we can use a pre built UI component that handles all of this for us Headless UI Headless UI is a library of fully accessible UI components made by the creators of Tailwind CSS It includes a bunch of ready to use components including menu popover tabs dialog and more To get started with Headless UI first install it using the simple Terminal command npm install headlessui react latest Once installed import the Dialog and Transition components and define the structure of the backdrop layer and the modal video as shown in the following example use client import useState Fragment from react import Dialog Transition from headlessui react import Image from next image export default function ModalVideo const modalOpen setModalOpen useState lt boolean gt false return lt div gt The button lt button className relative flex justify center items center focus outline none focus visible ring focus visible ring indigo rounded xl group onClick gt setModalOpen true aria label Watch the video gt lt Image className rounded xl shadow xl transition shadow duration ease in out src thumb width thumbWidth height thumbHeight priority alt Modal video thumbnail gt Play icon lt svg className absolute pointer events none group hover scale transition transform duration ease in out xmlns width height gt lt circle className fill white cx cy r fillOpacity gt lt path className fill indigo drop shadow xl d M a l A Va l A Vc Z gt lt svg gt lt button gt lt Transition show modalOpen as Fragment gt lt Dialog onClose gt setModalOpen false gt The backdrop layer lt Transition Child className fixed inset z bg black bg opacity transition opacity enter transition ease out duration enterFrom opacity enterTo opacity leave transition ease out duration leaveFrom opacity leaveTo opacity aria hidden true gt The modal video lt Transition Child className fixed inset z flex p enter transition ease out duration enterFrom opacity scale enterTo opacity scale leave transition ease out duration leaveFrom opacity scale leaveTo opacity scale gt lt div className max w xl mx auto h full flex items center gt lt Dialog Panel className w full max h full rounded xl shadow xl aspect video bg black overflow hidden gt lt video width height loop controls gt lt source src video mp type video mp gt Your browser does not support the video tag lt video gt lt Dialog Panel gt lt div gt lt Transition Child gt lt Dialog gt lt Transition gt lt div gt The Transition component is a part of the Headless UI library that allows you to animate content based on its visibility When the modalOpen state variable is set to true the Transition component will show the content wrapped inside it This is done by passing the modalOpen variable to the show property The Transition component has two Transition Child components that wrap the backdrop and modal video separately Each Transition Child component has its own set of properties to define how it should appear and disappear when the modal opens and closes These properties are defined in the following properties enter Defines the CSS transition property when the component is entering enterFrom Defines the starting state of the transition when the component is entering enterTo Defines the ending state of the transition when the component is entering leave Defines the CSS transition property when the component is leaving leaveFrom Defines the starting state of the transition when the component is leaving leaveTo Defines the ending state of the transition when the component is leaving Next we have the Dialog component which includes an onClose callback that triggers when the user clicks outside the Dialog Panel or presses the escape key We ll use this callback to set the modalOpen state to false At this point our modal video is fully functional The final step is to ensure that the video plays automatically when the modal is opened Let s take a look at how we can achieve this Playing the video automatically when the modal opensUnlike the Alpine js example we showed in the previous article in Next js the modal content gets unmounted when the modal is closed For this reason we don t need to worry about pausing the video when the modal is closed and we ll only focus on starting the video when it opens To do this we need to reference the video and tell it to start playing We can t use the usual useEffect React hook because the video is inside a component that gets unmounted when the modal closes and the ref would return null Instead we ll use the afterEnter callback in the Transition component This callback runs after the modal has finished opening so we can access the video element through the ref and tell it to play use client import useState useRef Fragment from react import Dialog Transition from headlessui react import Image from next image export default function ModalVideo const modalOpen setModalOpen useState lt boolean gt false return lt div gt The button lt button className relative flex justify center items center focus outline none focus visible ring focus visible ring indigo rounded xl group onClick gt setModalOpen true aria label Watch the video gt lt Image className rounded xl shadow xl transition shadow duration ease in out src thumb width thumbWidth height thumbHeight priority alt Modal video thumbnail gt Play icon lt svg className absolute pointer events none group hover scale transition transform duration ease in out xmlns width height gt lt circle className fill white cx cy r fillOpacity gt lt path className fill indigo drop shadow xl d M a l A Va l A Vc Z gt lt svg gt lt button gt lt Transition show modalOpen as Fragment afterEnter gt videoRef current play gt lt Dialog initialFocus videoRef onClose gt setModalOpen false gt The backdrop layer lt Transition Child className fixed inset z bg black bg opacity transition opacity enter transition ease out duration enterFrom opacity enterTo opacity leave transition ease out duration leaveFrom opacity leaveTo opacity aria hidden true gt The modal video lt Transition Child className fixed inset z flex p enter transition ease out duration enterFrom opacity scale enterTo opacity scale leave transition ease out duration leaveFrom opacity scale leaveTo opacity scale gt lt div className max w xl mx auto h full flex items center gt lt Dialog Panel className w full max h full rounded xl shadow xl aspect video bg black overflow hidden gt lt video ref videoRef width height loop controls gt lt source src video mp type video mp gt Your browser does not support the video tag lt video gt lt Dialog Panel gt lt div gt lt Transition Child gt lt Dialog gt lt Transition gt lt div gt Lastly to ensure that the video element is focused when the modal is opened we can pass the videoRef to the Dialog s initialFocus property With that the modal video component is now complete and can be imported and used in another component like this lt ModalVideo gt If you only need to use the component once in your app then you re good to go But if you want to reuse it with different thumbnail images and videos a few more adjustments may be necessary Making the modal video component reusableTo ensure that the ModalVideo component is reusable we should pass the following properties as props to it The source attribute src of the thumbnail image The dimensions of the thumbnail image The alternative text alt for the thumbnail image The source attribute src of the video The dimensions of the video lt ModalVideo thumb VideoThumb thumbWidth thumbHeight thumbAlt Modal video thumbnail video video mp videoWidth videoHeight gt We can then read these props by listing their names in the function component To ensure that the props are properly structured we ll also define an object with a TypeScript interface interface ModalVideoProps thumb StaticImageData thumbWidth number thumbHeight number thumbAlt string video string videoWidth number videoHeight number export default function ModalVideo thumb thumbWidth thumbHeight thumbAlt video videoWidth videoHeight ModalVideoProps ConclusionsAnd here s the final result of the modal video component built with Next js TypeScript and Tailwind CSS use client import useState useRef Fragment from react import type StaticImageData from next image import Dialog Transition from headlessui react import Image from next image interface ModalVideoProps thumb StaticImageData thumbWidth number thumbHeight number thumbAlt string video string videoWidth number videoHeight number export default function ModalVideo thumb thumbWidth thumbHeight thumbAlt video videoWidth videoHeight ModalVideoProps const modalOpen setModalOpen useState lt boolean gt false const videoRef useRef lt HTMLVideoElement gt null return lt div gt Video thumbnail lt button className relative flex justify center items center focus outline none focus visible ring focus visible ring indigo rounded xl group onClick gt setModalOpen true aria label Watch the video gt lt Image className rounded xl shadow xl transition shadow duration ease in out src thumb width thumbWidth height thumbHeight priority alt thumbAlt gt Play icon lt svg className absolute pointer events none group hover scale transition transform duration ease in out xmlns width height gt lt circle className fill white cx cy r fillOpacity gt lt path className fill indigo drop shadow xl d M a l A Va l A Vc Z gt lt svg gt lt button gt End Video thumbnail lt Transition show modalOpen as Fragment afterEnter gt videoRef current play gt lt Dialog initialFocus videoRef onClose gt setModalOpen false gt Modal backdrop lt Transition Child className fixed inset z bg black bg opacity transition opacity enter transition ease out duration enterFrom opacity enterTo opacity leave transition ease out duration leaveFrom opacity leaveTo opacity aria hidden true gt End Modal backdrop Modal dialog lt Transition Child className fixed inset z flex p enter transition ease out duration enterFrom opacity scale enterTo opacity scale leave transition ease out duration leaveFrom opacity scale leaveTo opacity scale gt lt div className max w xl mx auto h full flex items center gt lt Dialog Panel className w full max h full rounded xl shadow xl aspect video bg black overflow hidden gt lt video ref videoRef width videoWidth height videoHeight loop controls gt lt source src video type video mp gt Your browser does not support the video tag lt video gt lt Dialog Panel gt lt div gt lt Transition Child gt End Modal dialog lt Dialog gt lt Transition gt lt div gt The nice thing about this component is that by passing props for the thumbnail and the video you can easily use it in different parts of your application If you re interested in learning how to build this component in other stacks here are the links to the first and third parts of the series How to Build a Modal Video Component with Tailwind CSS and Alpine jsHow to Build a Modal Video Component with Tailwind CSS and Vue js 2023-05-23 09:30:24
海外TECH DEV Community How to Build a Modal Video with HTML, Tailwind CSS and Alpine.js https://dev.to/cruip_com/how-to-build-a-modal-video-with-html-tailwind-css-and-alpinejs-40n5 How to Build a Modal Video with HTML Tailwind CSS and Alpine js Live Demo Download Modal video components are increasingly used in modern web design because they allow for quickly watching a video without leaving the page and focusing on the content without too many distractions We have implemented this type of component in many of our templates for example in Open Pro a SaaS website template and Simple a simple website template and we can guarantee that our customers have greatly appreciated their use As you may have guessed in this tutorial we will learn how to create a modal video component using two powerful front end tools Tailwind CSS and Alpine js By combining the power of Tailwind CSS and Alpine js we can create a sleek and functional modal video component for every type of web application Are you ready Let s get started Assuming you haven t set up your environment yet let s create a simple HTML page and import Tailwind CSS and Alpine js via the CDN Although this is not the recommended approach for production websites it s okay for our experiment lt DOCTYPE html gt lt html lang en gt lt head gt lt meta charset utf gt lt title gt Modal Video lt title gt lt meta name viewport content width device width initial scale gt lt link rel preconnect href gt lt link rel preconnect href crossorigin gt lt link href wght amp display swap rel stylesheet gt lt script src gt lt script gt lt script defer src x x dist cdn min js gt lt script gt lt script gt tailwind config theme extend fontFamily inter Inter sans serif lt script gt lt head gt lt body class font inter antialiased h screen px py md py gt lt div class h full flex flex col justify center gt lt main class my gt lt div class w full max w xl mx auto gt lt div class flex justify center gt lt Modal video gt lt div gt lt div gt lt main gt lt div gt lt body gt lt html gt Create the modal video structure with HTML and Tailwind CSSThe first step is to create the HTML structure for the modal video using Tailwind CSS classes to style the elements This includes the following The button This is the clickable element that triggers the opening of the modal The button contains a thumbnail image of the video and a play button icon We have also added ARIA attributes for accessibility The backdrop layer This is the dark background that appears behind the modal when it is open It covers the entire screen and is partially transparent to allow the background to be visible The modal video This is the actual video that plays in the modal It is positioned in the center of the screen lt The button gt lt button class relative flex justify center items center focus outline none focus visible ring focus visible ring indigo rounded xl group click modalOpen true aria controls modal aria label Watch the video gt lt img class rounded xl shadow xl transition shadow duration ease in out src video modal thumb jpg width height alt Modal video thumbnail gt lt Play icon gt lt svg class absolute pointer events none group hover scale transition transform duration ease in out xmlns width height gt lt circle class fill white cx cy r fill opacity gt lt path class fill indigo drop shadow xl d M a l A Va l A Vc Z gt lt svg gt lt button gt lt The backdrop layer gt lt div class fixed inset z bg black bg opacity transition opacity gt lt div gt lt The modal video gt lt div id modal class fixed inset z flex p role dialog aria modal true gt lt div class max w xl mx auto h full flex items center gt lt div class w full max h full rounded xl shadow xl aspect video bg black overflow hidden gt lt video width height loop controls gt lt source src video mp type video mp gt Your browser does not support the video tag lt video gt lt div gt lt div gt lt div gt Define the modal initial state with Alpine jsThe next step is to define the initial state of the modal using Alpine js This involves creating an x data attribute on a parent element and assigning it an object with properties that represent the state of the modal In this case we want to create a property called modalOpen with an initial value of false This sets the initial state of the modal to be closed and allows us to toggle its state later lt div x data modalOpen false gt lt The button gt lt The backdrop layer gt lt The modal video gt lt div gt Then we need to bind the visibility of the modal and its backdrop to the modalOpen state We use the x show directive on both the backdrop and the modal to tell Alpine when to show or hide these elements based on the modalOpen state So we hide them when the state is false and show them when it s true lt div x data modalOpen false gt lt The button gt lt button gt lt The backdrop layer gt lt div x show modalOpen gt lt The modal video gt lt div x show modalOpen gt lt div gt Toggling the modal stateNow we need to add an event listener to the button element that toggles the modalOpen property when the button is clicked This is done using the click directive shorthand x on click When the button is clicked the value of modalOpen is changed to true which triggers the display of the backdrop layer and the modal video lt div x data modalOpen false gt lt The button gt lt button click modalOpen true gt lt The backdrop layer gt lt div x show modalOpen gt lt The modal video gt lt div x show modalOpen gt lt div gt Cool Now we want to change modalOpen to false and close the modal when clicking outside the modal dialog or when pressing the ESC key To achieve this we use the click outside and keydown escape window directives on the div which contains the video lt div x data modalOpen false gt lt The button gt lt button click modalOpen true gt lt The backdrop layer gt lt div x show modalOpen gt lt The modal video gt lt div x show modalOpen gt lt div class max w xl mx auto h full flex items center gt lt div class w full max h full rounded xl shadow xl aspect video bg black overflow hidden click outside modalOpen false keydown escape window modalOpen false gt lt video width height loop controls gt lt source src video mp type video mp gt Your browser does not support the video tag lt video gt lt div gt lt div gt lt div gt lt div gt Great We can now toggle the modal open and closed However we want to make the experience smoother by adding transitions between the states of the modal Adding enter and leave transitionsTraditionally implementing transitions between when an element is shown or hidden can be challenging But Alpine js provides a x transition utility that makes it easy to apply transition effects Since the x transition directive is already well documented I won t go into detail about how it works here Instead let s see how we can use this powerful feature in conjunction with Tailwind CSS to create a scale up transition effect on entering the modal and scale down effect when exiting the modal lt div x data modalOpen false gt lt The button gt lt button click modalOpen true gt lt The backdrop layer gt lt div x show modalOpen x transition enter transition ease out duration x transition enter start opacity x transition enter end opacity x transition leave transition ease out duration x transition leave start opacity x transition leave end opacity gt lt The modal video gt lt div x show modalOpen x transition enter transition ease out duration x transition enter start opacity scale x transition enter end opacity scale x transition leave transition ease out duration x transition leave start opacity scale x transition leave end opacity scale gt lt div gt Controlling video playback with modal state changesTo enhance the user experience it s important to automatically pause the video when the modal is closed and resume it when the modal is opened again This can be achieved by listening for changes in the modalOpen state and playing or pausing the video accordingly Fortunately Alpine js provides a handy watch method that enables us to accomplish this lt video x init watch modalOpen value gt value el play el pause width height loop controls gt lt source src video mp type video mp gt lt video gt Final TouchesOur component is almost complete but we need to make some final adjustments to ensure it s fully accessible and prevent any content from flickering on page load Improving AccessibilityTo make our modal fully accessible we assign the role dialog aria modal true and an id that corresponds to the aria controls attribute assigned to the button element This indicates that the button is capable of controlling the dialog Since the button doesn t have any text to describe its content we add the aria label Watch the video attribute We also want to remove the button s outline on click while maintaining accessibility requirements For this we add some Tailwind CSS classes that remove the outline on click focus outline none and enable focus for keyboard users focus visible ring focus visible ring indigo Additionally we assign the aria hidden true attribute to the backdrop to indicate that it s purely decorative Preventing hidden content from flickering on page loadBy default the modal is hidden on page load but there s a moment during navigation when Alpine js isn t fully loaded on the page As a result any elements that are supposed to be hidden will flicker on page load To avoid this we can use the x cloak directive to hide the elements that should be hidden by default in our case the backdrop and the modal and add the Tailwind CSS class amp x cloak hidden that sets a display none rule to a parent tag ConclusionsAnd here s the final result of the modal video component that we developed together ready to be included in any web app website or landing page lt div class amp x cloak hidden x data modalOpen false gt lt Video thumbnail gt lt button class relative flex justify center items center focus outline none focus visible ring focus visible ring indigo rounded xl group click modalOpen true aria controls modal aria label Watch the video gt lt img class rounded xl shadow xl transition shadow duration ease in out src video modal thumb jpg width height alt Modal video thumbnail gt lt Play icon gt lt svg class absolute pointer events none group hover scale transition transform duration ease in out xmlns width height gt lt circle class fill white cx cy r fill opacity gt lt path class fill indigo drop shadow xl d M a l A Va l A Vc Z gt lt svg gt lt button gt lt End Video thumbnail gt lt Modal backdrop gt lt div class fixed inset z bg black bg opacity transition opacity x show modalOpen x transition enter transition ease out duration x transition enter start opacity x transition enter end opacity x transition leave transition ease out duration x transition leave start opacity x transition leave end opacity aria hidden true x cloak gt lt div gt lt End Modal backdrop gt lt Modal dialog gt lt div id modal class fixed inset z flex p role dialog aria modal true x show modalOpen x transition enter transition ease out duration x transition enter start opacity scale x transition enter end opacity scale x transition leave transition ease out duration x transition leave start opacity scale x transition leave end opacity scale x cloak gt lt div class max w xl mx auto h full flex items center gt lt div class w full max h full rounded xl shadow xl aspect video bg black overflow hidden click outside modalOpen false keydown escape window modalOpen false gt lt video x init watch modalOpen value gt value el play el pause width height loop controls gt lt source src video mp type video mp gt Your browser does not support the video tag lt video gt lt div gt lt div gt lt div gt lt End Modal dialog gt lt div gt It looks pretty cool doesn t it The effectiveness of the Tailwind CSS and Alpine js is unmatched for this type of development but in case you were looking for the same tutorial in other stacks did you know that it is also available in Next js and Vue If you re interested you can find the links below How to Build a Modal Video Component with Tailwind CSS and Next js How to Build a Modal Video Component with Tailwind CSS and Vue js 2023-05-23 09:30:12
海外TECH DEV Community lizod - spiritual successor of zod less than 1kb https://dev.to/mizchi/lizod-spiritual-successor-of-zod-less-than-1kb-4i67 lizod spiritual successor of zod less than kb Translated with www DeepL com Translator Original Japanese version is lightweight zod hence lizod You can use npm install lizod S tl drThe build size of zod is getting in the way of various frontends and Cloudflare Workers I ve created a zod like validator that discards the method chain and all the useful utilities lizod is less than kb compared to zod s kbIt works Pick validators for treeshakeimport any array boolean const enum intersection null number object opt regexp string symbol undefined union void type Infer type Validator from lizod const validate object name string age number familyName opt string abc enum a as const b as const c as const nested object age number static const static items array object a string b boolean complex array union object a string object b number sec intersection string const x const v Infer lt typeof validate gt name aaa age familyName null abc b nested age static static items a b true a b false complex a b sec x if validate v const string v name const number v age const string void v familyName const a b c v abc const age number v nested const static v static const Array lt a string b boolean gt v items Why I made itRecently there is a high demand to run zod together with remix and others under the MB limit of Cloudflare Workers MB for paid plans kb of remix is unavoidable since it is a framework but zod has a size of kb kb for a single function validator is a little bit too much bundlephobia says kb but I checked it with my own build and it was about kb However it is still big I need a lightweight zod alternative for Cloudflare Workers not to mention the build size of the frontend So I made what I think is the best zod alternative Why is zod size so big In general libraries that adopt the API style of method chaining do not benefit from the ESM various bundlers to remove unnecessary code Imagine jQuery for example Validators such as zod do not need to be method chains and could be represented by function composition but the Pipeline Operator that allows this to be written naturally is still being hotly debated at Stage and is not expected to be available anytime soon As far as I read the Zod code there is a lack of optimization for tree shaking by method chaining and the Locale definition for displaying Error Reporter and Error Message is quite large I thought about Forking Zod itself but I thought I could achieve my goal by implementing the parts I really want in my use case in the way I want Features I want in zodA set of validators at the same level as TypeScript type expressionsAn Infer lt T gt to the synthesized validatorsSo I first created it with this kind of API set in mindimport object array union number string type Infer from lizod const validate object v array union string number type MyType Infer lt typeof validate gt const input any v hello world if validate input type narrowing in this scope const v Array lt number string gt input v zod does not mesh with TypeScript type expressions in some places due to the merging of existing validators and instruction sets lizod can be used with the same type sense as TypeScript s A B and A amp B since the instruction levels are union and intersect Things you don t needUtilities like email It implements regexp expr instead so the regular expression itself is brought separately One of the reasons why zod is so heavy is because it wraps a lot of this kind of regexp inside Method ChainClever Error ReporterIn the spirit of create your own missing validators only primitive validators are implemented in the main body FinallyI think there are many people who think that zod is only possible with a collection of utilities or that not having an error reporter is a shame etc For those people lizod is a great tool For those people lizod s small amount of code may be useful as a foundation to fork and tweak At least I expect this kind of functionality from zod and when I implemented it it became lizod I have been able to create it because I have been getting more and more good at type puzzling recently I am waiting for your comments feature suggestions and PR 2023-05-23 09:00:35
海外TECH Engadget Warner Bros.' Max streaming service launches with new $20 4K tier https://www.engadget.com/warner-bros-max-streaming-service-launches-with-new-20-4k-tier-092756959.html?src=rss Warner Bros x Max streaming service launches with new K tierHBO Max is completing its transformation into Warner Bros Discovery s quot Max quot streaming service today and it s launching with a new tier especially made for K ultra HD viewing The Ultimate Ad Free tier will set you back a month or if you re paying for a whole year making it the service s most expensive subscription option yet A subscription will give you access to over K movies and TV show episodes which is nearly eight times more than previously available K content It will also give you the ability to stream on up to four devices at the same time and to store up to offline downloads Ultimate Ad Free s arrival however could spell the end of K availability for regular ad free subscribers While Warner Bros didn t say it outright the company included a line in its announcement to reveal that quot existing HBO Max subscribers will still have access to their current plan features for a minimum of six months following launch quot We ve asked the company for clarification To note Warner Bros raised its subscription prices in January so you now have to pay a month for the ad free tier and for the ad supported one nbsp For the Ultimate Ad Free tier Dolby Atmos and Vision will also be available for select content and devices The company plans to keep growing its K library every month going forward but for now the ultra HD shows and movies you can stream with a subscription include Game of Thrones House of the Dragon The Last of Us the Harry Potter movies The Lord of the Rings trilogy The Dark Knight trilogy and The Matrix films Further all Warner Bros movies released this year and in the future will be added to the tier s K library when they arrive on Max This article originally appeared on Engadget at 2023-05-23 09:27:56
ラズパイ Raspberry Pi Preparing young children for a digital world | Hello World #21 https://www.raspberrypi.org/blog/preparing-young-children-digital-world-hello-world-21/ Preparing young children for a digital world Hello World How do we teach our youngest learners digital and computing skills Hello World s issue will focus on this question and all things primary school computing education We re excited to share this new issue with you on Tuesday May Today we re giving you a taste by sharing an article from it written by our The post Preparing young children for a digital world Hello World appeared first on Raspberry Pi Foundation 2023-05-23 09:09:26
ニュース BBC News - Home Cardiff riot: Two teenagers killed in crash before Ely disorder https://www.bbc.co.uk/news/uk-wales-65677472?at_medium=RSS&at_campaign=KARANGA police 2023-05-23 09:47:25
ニュース BBC News - Home Prince Harry loses challenge to pay for police protection in UK https://www.bbc.co.uk/news/uk-65609209?at_medium=RSS&at_campaign=KARANGA individuals 2023-05-23 09:30:04
ニュース BBC News - Home Food price inflation falls for second month in a row https://www.bbc.co.uk/news/business-65677582?at_medium=RSS&at_campaign=KARANGA kantar 2023-05-23 09:09:16
ニュース BBC News - Home Dominic Raab to stand down as MP at next election https://www.bbc.co.uk/news/uk-politics-65678955?at_medium=RSS&at_campaign=KARANGA decision 2023-05-23 09:34:51
ビジネス 不景気.com 千葉のジム運営「エポックスポーツクラブ」に破産開始決定 - 不景気com https://www.fukeiki.com/2023/05/epoch-sports-club.html 千葉県船橋市 2023-05-23 09:51:26
ニュース Newsweek 築130年の住宅に引っ越したTikToker夫婦、3つの「隠し部屋」を発見...その中には... https://www.newsweekjapan.jp/stories/world/2023/05/130tiktoker3.php 築年の住宅に引っ越したTikToker夫婦、つの「隠し部屋」を発見その中には築年の古い住宅に引っ越した夫婦のコートニーとマット。 2023-05-23 18:20:00
マーケティング MarkeZine 千葉日報デジタル、初心者向けの広告運用支援プログラム「ネットアドバイザー」を提供開始 http://markezine.jp/article/detail/42329 提供開始 2023-05-23 18:15:00
IT 週刊アスキー PC『ガンダムトライヴ』でスコアバトル「可能性の獣たち~暗闇を照らす陽光~」が開催! https://weekly.ascii.jp/elem/000/004/137/4137818/ 開催期間 2023-05-23 18:50:00
IT 週刊アスキー 水不足に挑むDG TAKANO 節水ノズルの次は汚れが一秒で落ちる皿 https://weekly.ascii.jp/elem/000/004/137/4137812/ dgtakano 2023-05-23 18:30:00
IT 週刊アスキー JT、Ploom Xを980円で販売するキャンペーンを5月29日より実施 https://weekly.ascii.jp/elem/000/004/137/4137784/ ploomx 2023-05-23 18:15:00
IT 週刊アスキー 「モンスト」シリーズ最新作『キュービックスターズ』がサービス開始! https://weekly.ascii.jp/elem/000/004/137/4137807/ 記念 2023-05-23 18:10:00
IT 週刊アスキー 山善、980gの「軽量コードレススティッククリーナー」パワーブラシ搭載 https://weekly.ascii.jp/elem/000/004/137/4137808/ 重量 2023-05-23 18:45:00
IT 週刊アスキー 入り口が低く省スペースの自動猫トイレ「CATLINK SCOOPER SE」 https://weekly.ascii.jp/elem/000/004/137/4137795/ catlink 2023-05-23 18:30:00

コメント

このブログの人気の投稿

投稿時間:2021-06-17 05:05:34 RSSフィード2021-06-17 05:00 分まとめ(1274件)

投稿時間:2021-06-20 02:06:12 RSSフィード2021-06-20 02:00 分まとめ(3871件)

投稿時間:2020-12-01 09:41:49 RSSフィード2020-12-01 09:00 分まとめ(69件)