Skip to content

Commit

Permalink
chore: Define devtool tooltips data here
Browse files Browse the repository at this point in the history
  • Loading branch information
julianrubisch committed Apr 19, 2023
1 parent 6a643c5 commit c375a84
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 31 deletions.
55 changes: 27 additions & 28 deletions app/assets/builds/@turbo-boost/elements.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions app/assets/builds/@turbo-boost/elements.js.map

Large diffs are not rendered by default.

51 changes: 51 additions & 0 deletions app/javascript/elements/toggle_elements/trigger_element/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,4 +204,55 @@ export default class ToggleTriggerElement extends ToggleElement {
if (!this.controls) return null
return document.getElementById(this.controls)
}

get triggerTooltipData () {
let content = this.triggerElement.viewStack
.reverse()
.map((view, index) => {
return this.triggerElement.sharedViews.includes(view)
? `<div slot="content">${index + 1}. ${view}</div>`
: `<div slot="content-bottom">${index + 1}. ${view}</div>`
}, this)
.join('')

return {
subtitle: `
<b>id</b>: ${this.triggerElement.id}<br>
<b>aria-controls</b>: ${this.triggerElement.controls}<br>
<b>aria-expanded</b>: ${this.triggerElement.expanded}<br>
<b>remember</b>: ${this.triggerElement.remember}<br>
`,
content: `
<div slot="content-top">
<svg xmlns="http://www.w3.org/2000/svg" style="display:inline-block;" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><polygon points="12 2 2 7 12 12 22 7 12 2"></polygon><polyline points="2 17 12 22 22 17"></polyline><polyline points="2 12 12 17 22 12"></polyline></svg>
<b>View Stack</b>
</div>
${content}
`
}
}

get targetTooltipData () {
let content = this.targetElement.viewStack
.reverse()
.map((view, index) => {
return this.triggerElement.sharedViews.includes(view)
? `<div slot="content">${index + 1}. ${view}</div>`
: `<div slot="content-bottom">${index + 1}. ${view}</div>`
}, this)
.join('')

return {
subtitle: `<b>id</b>: ${this.targetElement.id}<br>
<b>aria-labeled-by</b>: ${this.targetElement.labeledBy}<br>
`,
content: `
<div slot="content-top">
<svg xmlns="http://www.w3.org/2000/svg" style="display:inline-block;" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><polygon points="12 2 2 7 12 12 22 7 12 2"></polygon><polyline points="2 17 12 22 22 17"></polyline><polyline points="2 12 12 17 22 12"></polyline></svg>
<b>View Stack</b>
</div>
${content}
`
}
}
}

0 comments on commit c375a84

Please sign in to comment.