Skip to content

Commit

Permalink
feat(UI): add share button to toolbar
Browse files Browse the repository at this point in the history
  • Loading branch information
hatemhosny committed Jan 26, 2024
1 parent db877e9 commit 9a1cb6d
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 7 deletions.
2 changes: 2 additions & 0 deletions src/livecodes/UI/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ export const getCustomSettingsBtn = /* @__PURE__ */ () =>
document.querySelector('#editor-tools #custom-settings-btn') as HTMLElement;
export const getEditorSettingsBtn = /* @__PURE__ */ () =>
document.querySelector('#editor-tools #editor-settings-btn') as HTMLElement;
export const getShareButton = /* @__PURE__ */ () =>
document.querySelector('#share-button') as HTMLElement;
export const getResultButton = /* @__PURE__ */ () =>
document.querySelector('#result-button') as HTMLElement;
export const getFullscreenButton = /* @__PURE__ */ () =>
Expand Down
2 changes: 2 additions & 0 deletions src/livecodes/assets/images/share.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions src/livecodes/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2140,6 +2140,10 @@ const handleResultButton = () => {
eventsManager.addEventListener(UI.getResultButton(), 'click', () => split?.show('output', true));
};

const handleShareButton = () => {
eventsManager.addEventListener(UI.getShareButton(), 'click', () => showScreen('share'));
};

const handleEditorTools = () => {
if (!configureEditorTools(getActiveEditor().getLanguage())) return;

Expand Down Expand Up @@ -3883,6 +3887,7 @@ const basicHandlers = () => {
handleHotKeys();
handleRunButton();
handleResultButton();
handleShareButton();
handleEditorTools();
handleProcessors();
handleResultLoading();
Expand Down
21 changes: 18 additions & 3 deletions src/livecodes/html/app.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,27 @@
loading="lazy"
/>
</a>
<a
href="javascript:void(0)"
id="share-button"
class="button hint--bottom"
data-hint="Share"
tabindex="10"
>
<img
width="20"
height="20"
alt="Run"
src="{{baseUrl}}assets/images/share.svg"
loading="lazy"
/>
</a>
<a
href="javascript:void(0)"
id="result-button"
class="button hint--bottom"
data-hint="Toggle Result"
tabindex="10"
tabindex="11"
>
<img
width="28"
Expand All @@ -85,7 +100,7 @@
id="fullscreen-button"
class="button hint--bottom"
data-hint="Full Screen"
tabindex="11"
tabindex="12"
>
<img
width="28"
Expand All @@ -100,7 +115,7 @@
id="settings-button"
class="button"
aria-label="Menu"
tabindex="12"
tabindex="13"
>
<img
width="30"
Expand Down
10 changes: 6 additions & 4 deletions src/livecodes/styles/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,10 @@ a {
#toolbar {
font-size: 0.8em;

#share-button {
display: none;
}

#buttons > .button {
margin: 3px;
width: 35px;
Expand Down Expand Up @@ -391,10 +395,8 @@ a {
display: flex !important;
}

#settings-button {
display: none;
}

#share-button,
#settings-button,
#editor-settings-btn,
#project-info-btn,
#custom-settings-btn {
Expand Down

0 comments on commit 9a1cb6d

Please sign in to comment.