Skip to content

Commit

Permalink
Merge pull request #194 from blackcandy-org/dev
Browse files Browse the repository at this point in the history
Use native dialog element
  • Loading branch information
aidewoode committed Aug 24, 2022
2 parents 95f56ec + 87ba94b commit 048e81f
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 36 deletions.
15 changes: 10 additions & 5 deletions app/assets/stylesheets/components/_dialog.scss
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
@use "../tools/functions" as *;

.c-dialog {
position: fixed;
top: 100px;
left: 0;
right: 0;
z-index: 1000;
padding: 0;
margin-top: 100px;
background: var(--dialog-bg-color);
border: none;
border-radius: border-radius("medium");
width: 100%;
max-width: 360px;
color: inherit;
}

.c-dialog::backdrop {
background-color: var(--dialog-backdrop-color);
}

.c-dialog__header {
Expand Down
10 changes: 9 additions & 1 deletion app/assets/stylesheets/settings/_theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@
--dialog-header-bg-color: #{$grey-lighter};
--dialog-header-color: #{$black};

::backdrop {
--dialog-backdrop-color: #{color.change($grey-lightest, $alpha: 0.9)};
}

/* Overlay */
--overlay-blur-bg-color: #{color.change($grey-lightest, $alpha: 0.9)};

Expand Down Expand Up @@ -170,7 +174,7 @@
--tab-active-color: #{$purple-light};

/* List */
--list-border-color: #{$black-lighter};
--list-border-color: #{$black-light};
--list-active-color: #{$purple-light};
--list-dragging-placeholder-bg-color: #{$black-light};
--list-dragging-bg-color: #{$black-dark};
Expand Down Expand Up @@ -202,6 +206,10 @@
--dialog-header-bg-color: #{$grey};
--dialog-header-color: #{$black};

::backdrop {
--dialog-backdrop-color: #{color.change($black-light, $alpha: 0.9)};
}

/* Overlay */
--overlay-blur-bg-color: #{color.change($black-light, $alpha: 0.9)};

Expand Down
30 changes: 3 additions & 27 deletions app/javascript/controllers/dialog_controller.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,11 @@
import { Controller } from '@hotwired/stimulus'

export default class extends Controller {
static values = {
isShown: Boolean
}

initialize () {
if (this.isShownValue) {
this.show()
} else {
this.hide()
}
}

connect () {
this.element.addEventListener('dialog:hide', this.hide)
this.element.addEventListener('dialog:show', this.show)
}

disconnect () {
this.element.removeEventListener('dialog:hide', this.hide)
this.element.removeEventListener('dialog:show', this.show)
}

show = () => {
document.querySelector('#js-overlay').classList.remove('u-display-none')
this.element.classList.remove('u-display-none')
this.element.showModal()
}

hide = () => {
document.querySelector('#js-overlay').classList.add('u-display-none')
this.element.classList.add('u-display-none')
hide () {
this.element.close()
}
}
4 changes: 2 additions & 2 deletions app/views/layouts/dialog.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<%= turbo_frame_tag 'turbo-dialog' do %>
<section class='c-dialog o-container o-container--extra-narrow u-display-none' data-controller='dialog' data-dialog-is-shown-value='true'>
<dialog class='c-dialog' data-controller='dialog'>
<header class='c-dialog__header o-flex o-flex--justify-between'>
<h2 class='u-mb-0'><%= yield(:title) %></h2>
<span class='u-cursor-pointer' data-action='click->dialog#hide'>
Expand All @@ -9,5 +9,5 @@
<div id='js-dialog-content' class='c-dialog__content u-position-relative'>
<%= yield %>
</div>
</section>
</dialog>
<% end %>
3 changes: 2 additions & 1 deletion test/application_system_test_case.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
driven_by :cuprite, screen_size: [1400, 900], options: {
browser_options: {"no-sandbox": nil},
url_blacklist: ["https://www.gravatar.com"]
url_blacklist: ["https://www.gravatar.com"],
timeout: 10
}

def login_as(user)
Expand Down

0 comments on commit 048e81f

Please sign in to comment.