Skip to content

Commit

Permalink
Update build process (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
hopsoft authored Aug 9, 2023
1 parent c54a791 commit 0ecf518
Show file tree
Hide file tree
Showing 17 changed files with 429 additions and 2,631 deletions.
24 changes: 0 additions & 24 deletions .github/workflows/prettier-standard.yml

This file was deleted.

29 changes: 29 additions & 0 deletions .github/workflows/prettier.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Prettier

on:
pull_request:
branches:
- '*'
push:
branches:
- main

jobs:
prettier:
name: Prettier Check Action
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
version: '16.x'
cache: 'yarn'

- name: Yarn install
run: yarn install --frozen-lockfile

- name: Run Prettier
run: yarn run prettier package.json prettier.config.js bin/build.mjs app/javascript/**/**/**/**/*.js


1 change: 1 addition & 0 deletions app/assets/builds/@turbo-boost/commands.metafile.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"inputs":{"node_modules/@turbo-boost/commands/app/assets/builds/@turbo-boost/commands.js":{"bytes":11151,"imports":[],"format":"esm"},"node_modules/@turbo-boost/devtools/dist/@turbo-boost/devtools.js":{"bytes":19326,"imports":[],"format":"esm"},"app/javascript/elements/turbo_boost_element/index.js":{"bytes":844,"imports":[],"format":"esm"},"app/javascript/elements/toggle_elements/toggle_element/index.js":{"bytes":2193,"imports":[{"path":"app/javascript/elements/turbo_boost_element/index.js","kind":"import-statement","original":"../../turbo_boost_element"}],"format":"esm"},"app/javascript/elements/toggle_elements/target_element/index.js":{"bytes":3370,"imports":[{"path":"app/javascript/elements/toggle_elements/toggle_element/index.js","kind":"import-statement","original":"../toggle_element"}],"format":"esm"},"app/javascript/elements/toggle_elements/trigger_element/focus.js":{"bytes":1585,"imports":[],"format":"esm"},"app/javascript/elements/toggle_elements/trigger_element/index.js":{"bytes":7168,"imports":[{"path":"node_modules/@turbo-boost/devtools/dist/@turbo-boost/devtools.js","kind":"import-statement","original":"@turbo-boost/devtools"},{"path":"app/javascript/elements/toggle_elements/toggle_element/index.js","kind":"import-statement","original":"../toggle_element"},{"path":"app/javascript/elements/toggle_elements/trigger_element/focus.js","kind":"import-statement","original":"./focus"}],"format":"esm"},"app/javascript/elements/index.js":{"bytes":481,"imports":[{"path":"app/javascript/elements/turbo_boost_element/index.js","kind":"import-statement","original":"./turbo_boost_element"},{"path":"app/javascript/elements/toggle_elements/target_element/index.js","kind":"import-statement","original":"./toggle_elements/target_element"},{"path":"app/javascript/elements/toggle_elements/trigger_element/index.js","kind":"import-statement","original":"./toggle_elements/trigger_element"}],"format":"esm"},"app/javascript/index.js":{"bytes":244,"imports":[{"path":"node_modules/@turbo-boost/commands/app/assets/builds/@turbo-boost/commands.js","kind":"import-statement","original":"@turbo-boost/commands"},{"path":"node_modules/@turbo-boost/devtools/dist/@turbo-boost/devtools.js","kind":"import-statement","original":"@turbo-boost/devtools"},{"path":"app/javascript/elements/index.js","kind":"import-statement","original":"./elements"}],"format":"esm"}},"outputs":{"app/assets/builds/@turbo-boost/elements.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":92571},"app/assets/builds/@turbo-boost/elements.js":{"imports":[],"exports":["default"],"entryPoint":"app/javascript/index.js","inputs":{"node_modules/@turbo-boost/commands/app/assets/builds/@turbo-boost/commands.js":{"bytesInOutput":11085},"node_modules/@turbo-boost/devtools/dist/@turbo-boost/devtools.js":{"bytesInOutput":19262},"app/javascript/elements/turbo_boost_element/index.js":{"bytesInOutput":541},"app/javascript/elements/toggle_elements/toggle_element/index.js":{"bytesInOutput":1284},"app/javascript/elements/toggle_elements/target_element/index.js":{"bytesInOutput":2040},"app/javascript/elements/toggle_elements/trigger_element/focus.js":{"bytesInOutput":768},"app/javascript/elements/toggle_elements/trigger_element/index.js":{"bytesInOutput":4299},"app/javascript/elements/index.js":{"bytesInOutput":146},"app/javascript/index.js":{"bytesInOutput":124}},"bytes":39609}}}
55 changes: 15 additions & 40 deletions app/assets/builds/@turbo-boost/elements.js

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions app/assets/builds/@turbo-boost/elements.metafile.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"inputs":{"node_modules/@turbo-boost/commands/app/assets/builds/@turbo-boost/commands.js":{"bytes":11151,"imports":[],"format":"esm"},"node_modules/@turbo-boost/devtools/dist/@turbo-boost/devtools.js":{"bytes":19326,"imports":[],"format":"esm"},"app/javascript/elements/turbo_boost_element/index.js":{"bytes":844,"imports":[],"format":"esm"},"app/javascript/elements/toggle_elements/toggle_element/index.js":{"bytes":2193,"imports":[{"path":"app/javascript/elements/turbo_boost_element/index.js","kind":"import-statement","original":"../../turbo_boost_element"}],"format":"esm"},"app/javascript/elements/toggle_elements/target_element/index.js":{"bytes":3370,"imports":[{"path":"app/javascript/elements/toggle_elements/toggle_element/index.js","kind":"import-statement","original":"../toggle_element"}],"format":"esm"},"app/javascript/elements/toggle_elements/trigger_element/focus.js":{"bytes":1585,"imports":[],"format":"esm"},"app/javascript/elements/toggle_elements/trigger_element/index.js":{"bytes":7168,"imports":[{"path":"node_modules/@turbo-boost/devtools/dist/@turbo-boost/devtools.js","kind":"import-statement","original":"@turbo-boost/devtools"},{"path":"app/javascript/elements/toggle_elements/toggle_element/index.js","kind":"import-statement","original":"../toggle_element"},{"path":"app/javascript/elements/toggle_elements/trigger_element/focus.js","kind":"import-statement","original":"./focus"}],"format":"esm"},"app/javascript/elements/index.js":{"bytes":481,"imports":[{"path":"app/javascript/elements/turbo_boost_element/index.js","kind":"import-statement","original":"./turbo_boost_element"},{"path":"app/javascript/elements/toggle_elements/target_element/index.js","kind":"import-statement","original":"./toggle_elements/target_element"},{"path":"app/javascript/elements/toggle_elements/trigger_element/index.js","kind":"import-statement","original":"./toggle_elements/trigger_element"}],"format":"esm"},"app/javascript/index.js":{"bytes":244,"imports":[{"path":"node_modules/@turbo-boost/commands/app/assets/builds/@turbo-boost/commands.js","kind":"import-statement","original":"@turbo-boost/commands"},{"path":"node_modules/@turbo-boost/devtools/dist/@turbo-boost/devtools.js","kind":"import-statement","original":"@turbo-boost/devtools"},{"path":"app/javascript/elements/index.js","kind":"import-statement","original":"./elements"}],"format":"esm"}},"outputs":{"app/assets/builds/@turbo-boost/elements.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":92571},"app/assets/builds/@turbo-boost/elements.js":{"imports":[],"exports":["default"],"entryPoint":"app/javascript/index.js","inputs":{"node_modules/@turbo-boost/commands/app/assets/builds/@turbo-boost/commands.js":{"bytesInOutput":11085},"node_modules/@turbo-boost/devtools/dist/@turbo-boost/devtools.js":{"bytesInOutput":19262},"app/javascript/elements/turbo_boost_element/index.js":{"bytesInOutput":541},"app/javascript/elements/toggle_elements/toggle_element/index.js":{"bytesInOutput":1284},"app/javascript/elements/toggle_elements/target_element/index.js":{"bytesInOutput":2040},"app/javascript/elements/toggle_elements/trigger_element/focus.js":{"bytesInOutput":768},"app/javascript/elements/toggle_elements/trigger_element/index.js":{"bytesInOutput":4299},"app/javascript/elements/index.js":{"bytesInOutput":146},"app/javascript/index.js":{"bytesInOutput":124}},"bytes":39609}}}
44 changes: 20 additions & 24 deletions app/javascript/elements/toggle_elements/target_element/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import ToggleElement from '../toggle_element'

export default class ToggleTargetElement extends ToggleElement {
connectedCallback () {
connectedCallback() {
super.connectedCallback()

this.mouseenterHandler = this.onMouseenter.bind(this)
Expand All @@ -23,7 +23,7 @@ export default class ToggleTargetElement extends ToggleElement {
})
}

disconnectedCallback () {
disconnectedCallback() {
this.removeEventListener('mouseenter', this.mouseenterHandler)

this.collapseOn.forEach(entry => {
Expand All @@ -43,27 +43,26 @@ export default class ToggleTargetElement extends ToggleElement {
// perhaps use a mechanic other than morph

// TODO: implement cache (similar to Turbo Drive restoration visit)
cacheHTML () {
cacheHTML() {
// this.cachedHTML = this.innerHTML
}

// TODO: implement cache (similar to Turbo Drive restoration visit)
renderCachedHTML () {
renderCachedHTML() {
// if (!this.cachedHTML) return
// this.innerHTML = this.cachedHTML
}

onMouseenter () {
onMouseenter() {
clearTimeout(this.collapseTimeout)
}

collapse (delay = 250) {
collapse(delay = 250) {
clearTimeout(this.collapseTimeout)
if (this.busy) return
if (typeof delay !== 'number') delay = 250

if (delay > 0)
return (this.collapseTimeout = setTimeout(() => this.collapse(0), delay))
if (delay > 0) return (this.collapseTimeout = setTimeout(() => this.collapse(0), delay))

this.innerHTML = ''
try {
Expand All @@ -72,63 +71,60 @@ export default class ToggleTargetElement extends ToggleElement {
} catch {}
}

collapseNow (event) {
collapseNow(event) {
if (event.target.closest('turbo-boost-devtool-tooltip')) return
this.collapse(0)
}

collapseMatches () {
collapseMatches() {
document.querySelectorAll(this.collapseSelector).forEach(el => {
if (el.id === this.id) return
if (el.collapse) el.collapse(0)
})
}

get collapseSelector () {
return (
this.triggerElement.collapseSelector ||
this.getAttribute('collapse-selector')
)
get collapseSelector() {
return this.triggerElement.collapseSelector || this.getAttribute('collapse-selector')
}

get focusSelector () {
get focusSelector() {
return this.getAttribute('focus-selector')
}

// the active trigger
get triggerElement () {
get triggerElement() {
return document.getElementById(this.labeledBy)
}

// all triggers
get triggerElements () {
get triggerElements() {
return document.querySelectorAll(`[aria-controls="${this.id}"]`)
}

// the dom id of the active trigger
get labeledBy () {
get labeledBy() {
return this.getAttribute('aria-labeledby')
}

set labeledBy (value) {
set labeledBy(value) {
return this.setAttribute('aria-labeledby', value)
}

get collapseOn () {
get collapseOn() {
const value = this.getAttribute('collapse-on')
if (!value) return []
return JSON.parse(value)
}

get expanded () {
get expanded() {
return this.triggerElement ? this.triggerElement.expanded : false
}

set expanded (value) {
set expanded(value) {
this.triggerElements.forEach(el => (el.expanded = value))
}

get busy () {
get busy() {
return this.triggerElement && this.triggerElement.busy
}
}
20 changes: 10 additions & 10 deletions app/javascript/elements/toggle_elements/toggle_element/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ export const busyDelay = 100 // milliseconds - time to wait before showing busy
export const busyDuration = 400 // milliseconds - minimum time that busy element is shown

export default class ToggleElement extends TurboBoostElement {
constructor () {
constructor() {
super(html)
}

// TODO: Should we timeout after a theoretical max wait time?
// The idea being that a server error occurred and the toggle failed.
showBusyElement () {
showBusyElement() {
clearTimeout(this.showBusyElementTimeout)
clearTimeout(this.hideBusyElementTimeout)

Expand All @@ -30,7 +30,7 @@ export default class ToggleElement extends TurboBoostElement {
}, busyDelay)
}

hideBusyElement () {
hideBusyElement() {
clearTimeout(this.showBusyElementTimeout)
clearTimeout(this.hideBusyElementTimeout)

Expand All @@ -46,38 +46,38 @@ export default class ToggleElement extends TurboBoostElement {
}, delay)
}

get busyElement () {
get busyElement() {
return this.querySelector(':scope > [slot="busy"]')
}

get busySlotElement () {
get busySlotElement() {
return this.shadowRoot.querySelector('slot[name="busy"]')
}

get defaultSlotElement () {
get defaultSlotElement() {
return this.shadowRoot.querySelector('slot:not([name])')
}

// indicates if an rpc call is active/busy
get busy () {
get busy() {
return this.getAttribute('busy') === 'true'
}

// indicates if an rpc call is active/busy
set busy (value) {
set busy(value) {
value = !!value
if (this.busy === value) return
this.setAttribute('busy', value)
if (value) this.showBusyElement()
else this.hideBusyElement()
}

get busyStartedAt () {
get busyStartedAt() {
if (!this.dataset.busyStartedAt) return 0
return Number(this.dataset.busyStartedAt)
}

set busyStartedAt (value) {
set busyStartedAt(value) {
this.dataset.busyStartedAt = value
}
}
28 changes: 6 additions & 22 deletions app/javascript/elements/toggle_elements/trigger_element/focus.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,18 @@
let focusTimeout

function deactivateTrixAttributes (editor) {
const attributes = [
'bold',
'bullet',
'code',
'heading1',
'href',
'italic',
'number',
'quote',
'strike'
]
function deactivateTrixAttributes(editor) {
const attributes = ['bold', 'bullet', 'code', 'heading1', 'href', 'italic', 'number', 'quote', 'strike']
attributes.forEach(name => editor.deactivateAttribute(name))
}

function focusTrixEditorElement (element) {
function focusTrixEditorElement(element) {
if (element.value.length === 0) return

const editor = element.editor

// move cursor to the end
let lastRange = []
while (
lastRange[0] !== editor.getSelectedRange()[0] &&
lastRange[1] !== editor.getSelectedRange()[1]
) {
while (lastRange[0] !== editor.getSelectedRange()[0] && lastRange[1] !== editor.getSelectedRange()[1]) {
lastRange = editor.getSelectedRange()
editor.moveCursorInDirection('forward')
}
Expand All @@ -39,13 +26,10 @@ function focusTrixEditorElement (element) {
deactivateTrixAttributes(editor)

// move cursor to end and collapse the selection
editor.setSelectedRange([
editor.getSelectedRange()[1],
editor.getSelectedRange()[1]
])
editor.setSelectedRange([editor.getSelectedRange()[1], editor.getSelectedRange()[1]])
}

function debouncedFocus (element) {
function debouncedFocus(element) {
clearTimeout(focusTimeout)

focusTimeout = setTimeout(() => {
Expand Down
Loading

0 comments on commit 0ecf518

Please sign in to comment.