-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e760da6
commit 39c1ff3
Showing
8 changed files
with
78 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
lib/generators/css_zero/add/templates/app/assets/images/download.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions
1
lib/generators/css_zero/add/templates/app/assets/images/share.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
41 changes: 41 additions & 0 deletions
41
lib/generators/css_zero/add/templates/app/assets/stylesheets/lightbox.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
:root { | ||
--lightbox-padding: var(--size-4); | ||
} | ||
|
||
.lightbox { | ||
background-color: rgba(0, 0, 0, .8); | ||
block-size: 100dvh; | ||
max-block-size: unset; | ||
inline-size: 100dvw; | ||
max-inline-size: unset; | ||
padding: var(--lightbox-padding); | ||
|
||
&[open] { | ||
display: grid; | ||
place-items: center; | ||
} | ||
} | ||
|
||
.lightbox__close { | ||
align-self: start; | ||
grid-area: 1/1; | ||
justify-self: end; | ||
} | ||
|
||
.lightbox__download { | ||
align-self: end; | ||
grid-area: 1/1; | ||
justify-self: end; | ||
} | ||
|
||
.lightbox__share { | ||
align-self: start; | ||
grid-area: 1/1; | ||
justify-self: start; | ||
} | ||
|
||
.lightbox__image { | ||
grid-area: 1/1; | ||
max-inline-size: calc(100dvw - (var(--lightbox-padding) * 2)); | ||
max-block-size: calc(100dvh - (var(--lightbox-padding) * 2)); | ||
} |
26 changes: 26 additions & 0 deletions
26
lib/generators/css_zero/add/templates/app/javascript/controllers/lightbox_controller.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { Controller } from "@hotwired/stimulus" | ||
|
||
export default class extends Controller { | ||
static targets = [ "dialog", "zoomedImage", "download", "share" ] | ||
|
||
show(event) { | ||
this.dialogTarget.showModal() | ||
this.#set(event.target.parentNode) | ||
} | ||
|
||
close() { | ||
this.dialogTarget.close() | ||
} | ||
|
||
reset() { | ||
this.zoomedImageTarget.src = "" | ||
this.downloadTarget.href = "" | ||
this.shareTarget.dataset.webShareFileValue = ""; | ||
} | ||
|
||
#set(target) { | ||
this.zoomedImageTarget.src = target.href | ||
this.downloadTarget.href = target.dataset.lightboxUrlValue; | ||
this.shareTarget.dataset.webShareFileValue = target.dataset.lightboxUrlValue; | ||
} | ||
} |