-
-
Notifications
You must be signed in to change notification settings - Fork 585
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
129 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
@use "variables" as *; | ||
// Footer is sticky at the bottom of the stage | ||
.gjs-pn-footer { | ||
bottom: 0; | ||
left: $projectBarWidth; | ||
right: $viewsPanelWidth; | ||
border-top: 1px solid #dee2e6; | ||
display: flex; | ||
justify-content: space-between; | ||
align-items: center; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import { onFooter } from "./footer"; | ||
|
||
export default function (editor, options) { | ||
let breadcrumbsContainer | ||
onFooter(footer => { | ||
// Initialize the breadcrumbs container | ||
breadcrumbsContainer = document.createElement('div'); | ||
breadcrumbsContainer.id = 'breadcrumbs-container'; | ||
footer.prepend(breadcrumbsContainer); | ||
// Add breadcrumbs styles | ||
const breadcrumbsStyles = document.createElement('style'); | ||
breadcrumbsStyles.innerHTML = ` | ||
#breadcrumbs-container { | ||
display: flex; | ||
align-items: center; | ||
height: 100%; | ||
padding: 0 10px; | ||
font-size: 12px; | ||
color: #999; | ||
} | ||
#breadcrumbs-container h3 { | ||
margin: 0; | ||
} | ||
#breadcrumbs-container .breadcrumb { | ||
margin: 5px; | ||
font-size: large; | ||
line-height: 1; | ||
cursor: pointer; | ||
} | ||
#breadcrumbs-container .breadcrumb span { | ||
text-decoration: underline; | ||
} | ||
#breadcrumbs-container .breadcrumb::after { | ||
content: "➔"; | ||
margin-left: 10px; | ||
} | ||
#breadcrumbs-container .breadcrumb:last-child::after { | ||
content: ""; | ||
} | ||
`; | ||
footer.prepend(breadcrumbsStyles); | ||
renderBreadcrumbs(); | ||
}) | ||
// Append the breadcrumbs container to the editor's container | ||
|
||
editor.on('component:selected style', () => renderBreadcrumbs()); | ||
function renderBreadcrumbs() { | ||
let component = editor.getSelected() ?? editor.Pages.getSelected().getMainComponent() | ||
|
||
if(!breadcrumbsContainer) return | ||
|
||
// Clear the breadcrumbs container | ||
breadcrumbsContainer.innerHTML = ''; | ||
|
||
// Traverse up the tree of components, prepending each to the breadcrumbs | ||
while (component) { | ||
const breadcrumb = createBreadcrumb(component); | ||
breadcrumbsContainer.prepend(breadcrumb); | ||
console.log(component, component.tagName); | ||
component = component.parent(); | ||
} | ||
|
||
// Label | ||
const label = document.createElement('span'); | ||
label.innerHTML = '<h3>Selection: </h3>'; | ||
breadcrumbsContainer.prepend(label); | ||
} | ||
function createBreadcrumb(component) { | ||
const breadcrumb = document.createElement('span'); | ||
const model = component.model; | ||
breadcrumb.onclick = () => { | ||
editor.select(component); | ||
}; | ||
breadcrumb.classList.add('breadcrumb'); | ||
breadcrumb.innerHTML = `<span>${component.get('tagName')}${component.getClasses().length ? `.${component.getClasses().join('.')}` : ''}</span>`; | ||
return breadcrumb | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Styles are in: src/scss/footer.scss | ||
let _onFooter = [] | ||
let footer | ||
export default function (editor, options) { | ||
const panel = editor.Panels.addPanel({ | ||
id: 'footer', | ||
visible: true, | ||
buttons: [{ | ||
id: 'myNewButton', | ||
className: 'someClass', | ||
command: 'someCommand', | ||
attributes: { title: 'Some title' }, | ||
active: false, | ||
|
||
}], | ||
}) | ||
setTimeout(() => { | ||
footer = panel.view?.el | ||
_onFooter.forEach(cbk => cbk(footer)) | ||
_onFooter = [] | ||
}) | ||
} | ||
|
||
export function onFooter(fn) { | ||
if(footer) fn(footer) | ||
else _onFooter.push(fn) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters