Skip to content

Commit

Permalink
Extend modal size option (#67)
Browse files Browse the repository at this point in the history
* initial commit for Extend modal size option, fixes #66

* fix modal size option and test
  • Loading branch information
jmarsh24 authored Jul 31, 2023
1 parent d8c9825 commit 8dd518f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion spec/rails_app/app/views/posts/index.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ h1 Posts

p data-controller="hello"

a href=modal_path(new_post_path) Write New Post
a href=modal_path(new_post_path, size: "custom-size") Write New Post

- @posts.each do |post|
h2 = post.title
Expand Down
1 change: 1 addition & 0 deletions spec/system/modal_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

click_on "Write New Post"
expect(page).to have_selector ".modal--open"
expect(page).to have_selector ".modal--custom-size"
expect(page).to have_content "Compose Post"
expect(page).to have_link "Cancel"

Expand Down
6 changes: 5 additions & 1 deletion src/modal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,11 @@ export class Modal {
closeButton.style.display = close ?? true ? "block" : "none";
root.classList.add("modal--open");
root.classList.add("modal--loading");
root.classList.toggle("modal--small", size === "small");

if (size) {
root.classList.add(`modal--${size}`);
}

frame.innerHTML = await getHTML(url);
root.classList.remove("modal--loading");
}
Expand Down

0 comments on commit 8dd518f

Please sign in to comment.