Decouple login modal opening from Angular

This commit is contained in:
Matt-Yorkley
2022-01-16 13:19:39 +00:00
parent 6561a7246b
commit 04da148af0
3 changed files with 15 additions and 7 deletions

View File

@@ -3,17 +3,17 @@
.small-12.columns.text-center
%h3.pad-top
= t :checkout_headline
.row.pad-top
-if guest_checkout_allowed?
.row.pad-top{ "data-controller": "login-modal" }
- if guest_checkout_allowed?
.small-5.columns.text-center
%button.primary.expand{"auth" => "login"}
%button.primary.expand{ "data-action": "click->login-modal#call" }
= t :label_login
.small-2.columns.text-center
%p.pad-top= "#{t :action_or}"
.small-5.columns.text-center
%button.neutral-btn.dark.expand{"ng-click" => "enabled = true"}
= t :checkout_as_guest
-else
- else
.small-6.columns.small-centered
%button.primary.expand{"auth" => "login"}
%button.primary.expand{ "data-action": "click->login-modal#call" }
= t :label_login

View File

@@ -1,5 +1,5 @@
%li#login-link
%a{"auth" => "login"}
%li#login-link{ "data-controller": "login-modal" }
%a{"auth": "login", "data-action": "click->login-modal#call" }
%img{ src: image_pack_path("menu/icn-login.svg") }
%span
= t 'label_login'

View File

@@ -0,0 +1,8 @@
import { Controller } from "stimulus"
export default class extends Controller {
call(event) {
event.preventDefault()
window.dispatchEvent(new Event("login:modal:open"))
}
}