-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reimplement redirect and dismiss as custom actions
- Loading branch information
Showing
10 changed files
with
53 additions
and
92 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 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
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,33 @@ | ||
import { Turbo } from "@hotwired/turbo-rails"; | ||
|
||
import { StreamModal } from "./modals/stream_modal"; | ||
import { StreamRenderer } from "./utils/stream_renderer"; | ||
|
||
function kpop(action) { | ||
return action.targetElements[0]?.kpop; | ||
} | ||
|
||
Turbo.StreamActions.kpop_open = function () { | ||
const animate = !kpop(this).openValue; | ||
|
||
kpop(this) | ||
?.dismiss({ animate, reason: "before-turbo-stream" }) | ||
.then(() => { | ||
new StreamRenderer(this.targetElements[0], this).render(); | ||
kpop(this)?.open(new StreamModal(this.target, this), { animate }); | ||
}); | ||
}; | ||
|
||
Turbo.StreamActions.kpop_dismiss = function () { | ||
kpop(this)?.dismiss({ reason: "turbo_stream.kpop.dismiss" }); | ||
}; | ||
|
||
Turbo.StreamActions.kpop_redirect_to = function () { | ||
if (this.dataset.turboFrame === this.target) { | ||
this.targetElements[0].src = this.getAttribute("href"); | ||
} else { | ||
Turbo.visit(this.getAttribute("href"), { | ||
action: this.dataset.turboAction, | ||
}); | ||
} | ||
}; |
File renamed without changes.
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 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