Skip to content

Commit

Permalink
feat: introduce auto detection
Browse files Browse the repository at this point in the history
  • Loading branch information
bart-krakowski committed Mar 18, 2023
1 parent 62ee294 commit 77e105f
Showing 1 changed file with 33 additions and 24 deletions.
57 changes: 33 additions & 24 deletions packages/status/ui.html
Original file line number Diff line number Diff line change
Expand Up @@ -200,39 +200,48 @@
if (appearanceInput) {
appearanceInput.checked = true
}
onAppearanceChange(appearance)
}

typeInputs.forEach((elem) => {
elem.addEventListener('change', () => {
parent.postMessage(
{
pluginMessage: {
type: 'change-status',
payload: {
status: elem.value,
appearance: document.querySelector('input[name="appearance"]:checked').value,
},
const onStatusChange = (status) => {
parent.postMessage(
{
pluginMessage: {
type: 'change-status',
payload: {
status,
appearance: document.querySelector('input[name="appearance"]:checked')?.value,
},
},
},
'*'
)
}

const onAppearanceChange = (appearance) => {
parent.postMessage(
{
pluginMessage: {
type: 'change-status',
payload: {
status: document.querySelector('input[name="type"]:checked')?.value,
appearance: appearance,
},
},
'*'
)
},
'*'
)
}

typeInputs.forEach((elem) => {
elem.addEventListener('change', () => {
onStatusChange(elem.value)
})
})

appearanceInputs.forEach((elem) => {
elem.addEventListener('change', () => {
parent.postMessage(
{
pluginMessage: {
type: 'change-status',
payload: {
status: document.querySelector('input[name="type"]:checked')?.value,
appearance: elem.value,
},
},
},
'*'
)
onAppearanceChange(elem.value)
})
})

Expand Down

0 comments on commit 77e105f

Please sign in to comment.