Skip to content

Commit

Permalink
feat(UI): add editor settings button to editor toolbar
Browse files Browse the repository at this point in the history
  • Loading branch information
hatemhosny committed Dec 10, 2023
1 parent 078e963 commit 213cfc9
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 11 deletions.
2 changes: 2 additions & 0 deletions src/livecodes/UI/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ export const getExternalResourcesBtn = /* @__PURE__ */ () =>
document.querySelector('#editor-tools #external-resources-btn') as HTMLElement;
export const getExternalResourcesMark = /* @__PURE__ */ () =>
document.querySelector('#editor-tools #external-resources-mark') as HTMLElement;
export const getEditorSettingsBtn = /* @__PURE__ */ () =>
document.querySelector('#editor-tools #editor-settings-btn') as HTMLElement;
export const getResultButton = /* @__PURE__ */ () =>
document.querySelector('#result-button') as HTMLElement;
export const getFullscreenButton = /* @__PURE__ */ () =>
Expand Down
17 changes: 17 additions & 0 deletions src/livecodes/assets/images/gear.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 8 additions & 6 deletions src/livecodes/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2161,6 +2161,14 @@ const handleEditorTools = () => {
eventsManager.addEventListener(UI.getEditorStatus(), 'click', () => {
showScreen('editor-settings', { scrollToSelector: 'label[data-name="editorMode"]' });
});

eventsManager.addEventListener(UI.getExternalResourcesBtn(), 'click', () => {
showScreen('resources');
});

eventsManager.addEventListener(UI.getEditorSettingsBtn(), 'click', () => {
showScreen('editor-settings');
});
};

const handleProcessors = () => {
Expand Down Expand Up @@ -3370,12 +3378,6 @@ const handleExternalResources = () => {
createExrenalResourcesUI,
false,
);
eventsManager.addEventListener(
UI.getExternalResourcesBtn(),
'click',
createExrenalResourcesUI,
false,
);
registerScreen('resources', createExrenalResourcesUI);
};

Expand Down
5 changes: 4 additions & 1 deletion src/livecodes/html/app.html
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,12 @@
<span data-status="script"></span>
</span>
<span id="external-resources-btn" class="hint--top-left" data-hint="External Resources">
<img src="{{baseUrl}}assets/images/script-sheet.svg" alt="External Resources" />
<img src="{{baseUrl}}assets/images/script-sheet.svg" alt="external resources" />
<span id="external-resources-mark" class="mark"></span>
</span>
<span id="editor-settings-btn" class="hint--top-left" data-hint="Editor Settings">
<img src="{{baseUrl}}assets/images/gear.svg" alt="editor settings" />
</span>
</div>
<button id="code-run-button" class="hint--top-left" data-hint="Run (Shift + Enter)">
<img
Expand Down
8 changes: 4 additions & 4 deletions src/livecodes/styles/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,10 @@ a {
display: none;
}

#editor-settings-btn {
display: none;
}

@media only screen and (max-width: 1080px) {
#buttons {
width: 30% !important;
Expand Down Expand Up @@ -565,10 +569,6 @@ a {
margin: auto 4px;
}
}

#external-resources-btn {
right: 1em;
}
}
}

Expand Down

0 comments on commit 213cfc9

Please sign in to comment.