Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add share button to toolbar #494

Merged
merged 4 commits into from
Jan 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
5 changes: 3 additions & 2 deletions src/livecodes/UI/share.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export const createShareContainer = async (
<img
src="${getAbsoluteUrl(baseUrl) + 'assets/icons/' + service.icon}"
alt="${service.name}"
${service.name === 'X / Twitter' ? 'class="twitter"' : ''}
/>
</span>
${service.name}
Expand Down Expand Up @@ -102,8 +103,8 @@ export const createShareContainer = async (
createShareUrl: ({ url }) => `https://www.facebook.com/sharer.php?u=${encode(url)}`,
},
{
name: 'Twitter',
icon: 'twitter.svg',
name: 'X / Twitter',
icon: 'x.svg',
createShareUrl: ({ url, title }) =>
`https://twitter.com/intent/tweet?url=${encode(url)}&text=${encode(title)}`,
},
Expand Down
17 changes: 17 additions & 0 deletions src/livecodes/assets/icons/x.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions src/livecodes/assets/images/share.svg
Loading
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
16 changes: 10 additions & 6 deletions src/livecodes/styles/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,6 @@

// scrollbar
* {
scrollbar-width: thin;

&::-webkit-scrollbar {
height: 10px;
width: 10px;
Expand Down Expand Up @@ -309,6 +307,10 @@ a {
#toolbar {
font-size: 0.8em;

#share-button {
display: none;
}

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

#settings-button {
display: none;
}

#share-button,
#settings-button,
#editor-settings-btn,
#project-info-btn,
#custom-settings-btn {
Expand Down Expand Up @@ -2772,6 +2772,10 @@ i.arrow {
margin-right: 0.5em;
width: 21px;
}

img.twitter {
height: 23px;
}
}
}
}
Expand Down
Loading