Move bridge javascript into existing folder structure

This commit is contained in:
Adrien Maston
2026-01-08 16:22:55 +01:00
parent eae17b82b4
commit 3a43941575
9 changed files with 7 additions and 4 deletions
@@ -0,0 +1,40 @@
import { BridgeElement } from "@hotwired/hotwire-native-bridge"
BridgeElement.prototype.isDisplayedOnPlatform = function() {
return !this.hasClass("hide-on-native")
}
BridgeElement.prototype.showOnPlatform = function() {
this.element.classList.remove("hide-on-native")
}
BridgeElement.prototype.hideOnPlatform = function() {
this.element.classList.add("hide-on-native")
}
BridgeElement.prototype.getButton = function() {
return {
title: this.title,
icon: this.getIcon(),
label: this.getLabel()
}
}
BridgeElement.prototype.getIcon = function() {
const name = this.bridgeAttribute("icon-name")
const url = this.bridgeAttribute(`icon-${this.platform}-url`)
if (name || url) {
return { name, url }
}
return null
}
BridgeElement.prototype.getLabel = function() {
return this.bridgeAttribute("label")
}
BridgeElement.prototype.displaysNavButtonMenu = function() {
return this.bridgeAttribute("displays-nav-button-menu") === "true"
}
+1 -1
View File
@@ -1,2 +1,2 @@
import "initializers/current"
import "bridge/initializers"
import "initializers/bridge/bridge_element"