Skip to content

Commit

Permalink
Fix dynamic diagram when mode changes
Browse files Browse the repository at this point in the history
  • Loading branch information
fdodino committed Oct 14, 2024
1 parent fe2b904 commit f90d46c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/dynamicDiagram/diagram-index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,15 +181,21 @@ function readyForLayoutElems(elements) {
)
}

function recreateDiagram(currentElements) {
changeElementsMode()
cy.elements().remove()
cy.add(currentElements)
updateLayout()
}

function modeChanged() {
const toggleMode = getInputElement('toggle-mode')
const newTitle = toggleMode.checked ? 'Dark mode ON' : 'Light Mode ON'
toggleMode.setAttribute('title', newTitle)

// @ts-expect-error it works and we need it
document.getElementById('main').style = `background-color: ${backgroundColor()}`
cy.elements().remove()
reloadDiagram(currentElements)
recreateDiagram([...currentElements])
}

function backgroundColor() {
Expand Down

0 comments on commit f90d46c

Please sign in to comment.