-
Notifications
You must be signed in to change notification settings - Fork 258
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace custom modal implementation with turbo/stimulus
- Loading branch information
Showing
11 changed files
with
47 additions
and
256 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
42 changes: 22 additions & 20 deletions
42
app/components/blacklight/system/modal_component.html.erb
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 |
---|---|---|
@@ -1,25 +1,27 @@ | ||
<div data-blacklight-modal="container"> | ||
<%= prefix %> | ||
<turbo-frame id="modal"> | ||
<div data-blacklight-modal="container"> | ||
<%= prefix %> | ||
|
||
<div class="modal-header"> | ||
<%= header || (capture do %> | ||
<h1 class="modal-title"><%= title %></h1> | ||
<% end) %> | ||
|
||
<button type="button" class="blacklight-modal-close btn-close close" data-bl-dismiss="modal" aria-label="<%= t('blacklight.modal.close') %>"> | ||
<span aria-hidden="true" class="visually-hidden">×</span> | ||
</button> | ||
</div> | ||
<div class="modal-header"> | ||
<%= header || (capture do %> | ||
<h1 class="modal-title"><%= title %></h1> | ||
<% end) %> | ||
|
||
<%= body || (capture do %> | ||
<div class="modal-body"> | ||
<%= content %> | ||
<button type="button" class="blacklight-modal-close btn-close close" data-action="blacklight--modal#close" aria-label="<%= t('blacklight.modal.close') %>"> | ||
<span aria-hidden="true" class="visually-hidden">×</span> | ||
</button> | ||
</div> | ||
<% end) %> | ||
|
||
<% if footer.present? %> | ||
<div class="modal-footer"> | ||
<%= footer %> | ||
</div> | ||
<% end %> | ||
<%= body || (capture do %> | ||
<div class="modal-body"> | ||
<%= content %> | ||
</div> | ||
<% end) %> | ||
|
||
<% if footer.present? %> | ||
<div class="modal-footer"> | ||
<%= footer %> | ||
</div> | ||
<% end %> | ||
</div> | ||
</div> |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,17 @@ | ||
import { Controller } from "@hotwired/stimulus" | ||
|
||
export default class extends Controller { | ||
static targets = ['content', 'modal'] | ||
|
||
connect() { | ||
this.contentTarget.innerHTML = '<turbo-frame id="modal"></turbo-frame>'; | ||
} | ||
|
||
open() { | ||
this.modalTarget.showModal(); | ||
} | ||
|
||
close() { | ||
this.modalTarget.close(); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<dialog id="blacklight-modal" class="modal" data-turbo="false"> | ||
<dialog id="blacklight-modal" class="modal" data-blacklight--modal-target="modal"> | ||
<div class="modal-dialog modal-lg"> | ||
<div class="modal-content"> | ||
<div class="modal-content" data-blacklight--modal-target="content"> | ||
</div> | ||
</div> | ||
</dialog> |