Files
fizzy/app/javascript/initializers/bridge/bridge_element.js
T
2026-02-25 17:08:11 +01:00

31 lines
658 B
JavaScript

import { BridgeElement } from "@hotwired/hotwire-native-bridge"
BridgeElement.prototype.getButton = function() {
const button = {
title: this.title,
icon: this.getIcon(),
showLabel: this.getShowLabel(),
isMainAction: this.getIsMainAction()
}
console.log(button)
return button
}
BridgeElement.prototype.getIcon = function() {
const url = this.bridgeAttribute(`icon-url`)
if (url) {
return { url }
}
return null
}
BridgeElement.prototype.getShowLabel = function() {
return !!this.bridgeAttribute(`show-label`)
}
BridgeElement.prototype.getIsMainAction = function() {
return !!this.bridgeAttribute(`main-action`)
}