-
Notifications
You must be signed in to change notification settings - Fork 3
Changed slideover to popover and dialog #46
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
Changes from all commits
816af82
bb64285
9804369
97e3160
84de007
c62b859
5760d9a
0b4d598
27a9885
a66a2ae
8d4d0ca
39ccc91
0dbafc6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| import "invokers-polyfill" | ||
|
|
||
| if (!(typeof HTMLElement !== 'undefined' && typeof HTMLElement.prototype === 'object' && 'popover' in HTMLElement.prototype)) | ||
| { | ||
| function replacePopovers(baseElement) { | ||
| function replacePopover(el, newCommand) { | ||
| let target = el.getAttribute('popovertarget') ?? el.getAttribute('commandfor') | ||
| el.removeAttribute('popovertargetaction') | ||
| el.removeAttribute('popovertarget') | ||
| el.setAttribute('commandfor', target) | ||
| el.setAttribute('command', newCommand) | ||
| } | ||
|
|
||
| baseElement.querySelectorAll('[command=show-popover]').forEach(el => el.command = 'show-modal') | ||
| baseElement.querySelectorAll('[command=toggle-popover]').forEach(el => el.command = 'show-modal') | ||
| baseElement.querySelectorAll('[command=hide-popover]').forEach(el => el.command = 'close') | ||
|
|
||
| baseElement.querySelectorAll('[popovertargetaction=show]').forEach(el => replacePopover(el, 'show-modal')) | ||
| baseElement.querySelectorAll('[popovertargetaction=toggle]').forEach(el => replacePopover(el, 'show-modal')) | ||
| baseElement.querySelectorAll('[popovertargetaction=hide]').forEach(el => replacePopover(el, 'close')) | ||
| } | ||
|
|
||
| replacePopovers(document) | ||
|
|
||
| const observer = new MutationObserver((mutations) => { | ||
| if (mutations.some((mutation) => | ||
| mutation.target.hasAttribute('popovertargetaction') | ||
| || mutation.target.hasAttribute('popovertarget') | ||
| || mutation.target.hasAttribute('commandfor') | ||
| )) { | ||
| replacePopovers(mutation.target.parentElement ?? document) | ||
| } | ||
| }) | ||
|
|
||
| observer.observe(document, { | ||
| attributes: true, | ||
| childList: true, | ||
| subtree: true, | ||
| attributeFilter: ['popovertargetaction', 'popovertarget', 'command'] | ||
| }) | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| <!doctype html> | ||
| <html> | ||
| <html class="has-[:is([popover]:popover-open,dialog[open])]:overflow-clip"> | ||
| <head> | ||
| <meta charset="utf-8"> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1"> | ||
|
|
@@ -10,7 +10,7 @@ | |
|
|
||
| <title>Rapidez Blade Components Preview</title> | ||
| </head> | ||
| <body class="has-[.prevent-scroll:checked]:overflow-clip"> | ||
| <body> | ||
| <div class="bg mb-6"> | ||
| <div class="container mx-auto px-5 py-10"> | ||
| <h1 class="font-bold text-2xl">Rapidez Blade Components preview</h1> | ||
|
|
@@ -207,44 +207,64 @@ | |
| <div class="flex flex-col gap-3"> | ||
| <h3 class="text-md font-bold">Default</h3> | ||
| <div> | ||
| <x-rapidez::button.primary for="default-slideover"> | ||
| <x-rapidez::button.primary command="show-modal" commandfor="default-slideover"> | ||
| Open Slideover | ||
| </x-rapidez::button.primary> | ||
| <x-rapidez::slideover id="default-slideover" title="Example Slideover"> | ||
| <div class="p-4"> | ||
| <p class="mb-4">This is an example of the slideover component.</p> | ||
| <p>You can put any content here!</p> | ||
| </div> | ||
|
|
||
| <x-rapidez::slideover id="default-slideover" closedby="any"> | ||
| <x-rapidez::slideover.header> | ||
| Title | ||
| <x-rapidez::slideover.close command="close" commandfor="default-slideover" /> | ||
|
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. Could we make
Contributor
Author
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. There are some ways but since you can choose between a dialog and a popover those attributes differ from eachother. We can make some magic that that can detect what type you use and add those attributes but that feels wrong in my opinion. Also when you nest popovers (slideover inside a slideover) you can target the parent popover to close them both if you navigate a layer deeper. By keeping it simple like this it does require some default attributes to specify what you want it to do.
Contributor
Author
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. I've tried the following, added aware that checks if parent component has the id attribute, and uses that automatically for the close commandfor and popovertarget. I've added both attributes for dialog and popover by default so that you don't have to explicitly add them each time. The component looks like the following Issue is that i would have another back.blade.php file that looks like the close.blade.php component doing the exact same thing.
|
||
| </x-rapidez::slideover.header> | ||
| <x-rapidez::slideover.content> | ||
| Content | ||
| </x-rapidez::slideover.content> | ||
| <x-rapidez::slideover.footer> | ||
| Footer | ||
| </x-rapidez::slideover.footer> | ||
| </x-rapidez::slideover> | ||
| </div> | ||
| </div> | ||
|
|
||
| <div class="flex flex-col gap-3"> | ||
| <h3 class="text-md font-bold">Right-positioned</h3> | ||
| <div> | ||
| <x-rapidez::button.secondary for="right-slideover"> | ||
| <x-rapidez::button.secondary command="show-modal" commandfor="right-slideover"> | ||
| Open Right Slideover | ||
| </x-rapidez::button.secondary> | ||
| <x-rapidez::slideover id="right-slideover" position="right" title="Right Slideover"> | ||
| <div class="p-4"> | ||
| <p class="mb-4">This slideover appears from the right side.</p> | ||
| <p>It demonstrates the position property.</p> | ||
| </div> | ||
|
|
||
| <x-rapidez::slideover id="right-slideover" position="right" closedby="any"> | ||
| <x-rapidez::slideover.header> | ||
| Title | ||
| <x-rapidez::slideover.close command="close" commandfor="right-slideover" /> | ||
| </x-rapidez::slideover.header> | ||
| <x-rapidez::slideover.content> | ||
| Content | ||
| </x-rapidez::slideover.content> | ||
| <x-rapidez::slideover.footer> | ||
| Footer | ||
| </x-rapidez::slideover.footer> | ||
| </x-rapidez::slideover> | ||
| </div> | ||
| </div> | ||
| <div class="flex flex-col gap-3"> | ||
| <h3 class="text-md font-bold">Mobile only</h3> | ||
| <div> | ||
| <x-rapidez::button.outline for="mobile-slideover" class="lg:hidden"> | ||
| <x-rapidez::button.outline command="show-modal" commandfor="example" class="lg:hidden"> | ||
| Open Mobile Slideover | ||
| </x-rapidez::button.outline> | ||
| <x-rapidez::slideover.mobile id="mobile-slideover" title="Mobile Slideover"> | ||
| <div class="max-lg:p-4"> | ||
| <p class="mb-4">This is a mobile-specific slideover that transforms on desktop.</p> | ||
| <p>On mobile devices, it appears as a slideover.</p> | ||
| <p class="mt-4">On desktop screens (lg breakpoint and above), this content is directly embedded in the page instead of being in a slideover.</p> | ||
| </div> | ||
|
|
||
| <x-rapidez::slideover.mobile id="example" closedby="any"> | ||
| <x-rapidez::slideover.mobile.header> | ||
| Title | ||
| <x-rapidez::slideover.close command="close" commandfor="example" /> | ||
| </x-rapidez::slideover.mobile.header> | ||
| <x-rapidez::slideover.mobile.content> | ||
| This content will be visible on desktop, however if you scale to mobile resolution this will be hidden inside a slideover. | ||
| </x-rapidez::slideover.mobile.content> | ||
| <x-rapidez::slideover.mobile.footer> | ||
| Footer | ||
| </x-rapidez::slideover.mobile.footer> | ||
| </x-rapidez::slideover.mobile> | ||
| </div> | ||
| </div> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| <button {{ $attributes->twMerge('shrink-0 cursor-pointer hover:opacity-75') }}> | ||
| <x-heroicon-o-arrow-left class="size-6" /> | ||
| </button> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| <button {{ $attributes->twMerge('shrink-0 cursor-pointer hover:opacity-75 absolute right-5 top-1/2 -translate-y-1/2') }}> | ||
| <x-heroicon-o-x-mark class="size-7" /> | ||
| </button> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| <div {{ $attributes->twMerge('p-5 overflow-y-auto max-h-full') }}> | ||
| {{ $slot }} | ||
| </div> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| <div {{ $attributes->twMerge('p-5 flex gap-x-4')}}> | ||
| {{ $slot }} | ||
| </div> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| <div {{ $attributes->twMerge('p-5 bg-primary text-primary-text flex gap-x-4 items-center text-center justify-center text-lg relative') }}> | ||
| {{ $slot }} | ||
| </div> |
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| <x-rapidez::slideover.content :attributes="$attributes->twMerge('lg:contents')"> | ||
| {{ $slot }} | ||
| </x-rapidez::slideover.content> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| <x-rapidez::slideover.footer :attributes="$attributes->twMerge('lg:hidden')"> | ||
| {{ $slot }} | ||
| </x-rapidez::slideover.footer> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| <x-rapidez::slideover.header :attributes="$attributes->twMerge('lg:hidden')"> | ||
| {{ $slot }} | ||
| </x-rapidez::slideover.header> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| {{-- | ||
| This mobile version shows content on desktop and hides it within a slideover on mobile resolution. | ||
|
|
||
| ## Behavior | ||
| - On mobile: Functions as a regular slideover | ||
| - On desktop: Content is displayed directly on the page | ||
| - Button should be hidden on desktop using `lg:hidden` | ||
|
|
||
| ## Example | ||
| ```blade | ||
| <button commandfor="example" command="show-modal" class="lg:hidden"> | ||
| Open Mobile Slideover | ||
| </button> | ||
|
|
||
| <x-rapidez::slideover.mobile id="example" closedby="any"> | ||
| <x-rapidez::slideover.mobile.header> | ||
| Title | ||
| <x-rapidez::slideover.close commandfor="example" command="show-modal" /> | ||
| </x-rapidez::slideover.mobile.header> | ||
| <x-rapidez::slideover.mobile.content> | ||
| Content | ||
| </x-rapidez::slideover.mobile.content> | ||
| <x-rapidez::slideover.mobile.footer> | ||
| Footer | ||
| </x-rapidez::slideover.mobile.footer> | ||
| </x-rapidez::slideover.mobile> | ||
| ``` | ||
| --}} | ||
|
|
||
| <x-rapidez::slideover :attributes="$attributes->twMerge('lg:contents')"> | ||
| {{ $slot }} | ||
| </x-rapidez::slideover> |
This file was deleted.


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.
I feel like this is missing an example of the popover, these are all dialog slideovers.
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.
Visually it's exactly the same (same component same styling), within the <x-slideover component i've added simple instructions on how you can use the attributes on your button to trigger it as a popover or dialog.
If others also agree I'll add it :)