Add a share link button to the editor.

This commit is contained in:
Bauke 2022-11-23 14:14:35 +01:00
parent dbff19e2b9
commit 42b5c3ece9
Signed by: Bauke
GPG Key ID: C1C0F29952BCF558
2 changed files with 18 additions and 1 deletions

View File

@ -1,4 +1,4 @@
import {ConfirmButton} from '@holllo/preact-components'; import {ConfirmButton, FeedbackButton} from '@holllo/preact-components';
import {html} from 'htm/preact'; import {html} from 'htm/preact';
import {Component} from 'preact'; import {Component} from 'preact';
import browser from 'webextension-polyfill'; import browser from 'webextension-polyfill';
@ -13,6 +13,7 @@ import {
redirectTypes, redirectTypes,
} from '../../redirect/exports.js'; } from '../../redirect/exports.js';
import storage from '../../redirect/storage.js'; import storage from '../../redirect/storage.js';
import {share} from '../../utilities/share-redirect.js';
type Props = { type Props = {
redirect: Redirect; redirect: Redirect;
@ -124,6 +125,11 @@ export default class Editor extends Component<Props, State> {
this.setState({enabled}); this.setState({enabled});
}; };
copyShareLink = async () => {
const link = share(this.state);
await navigator.clipboard.writeText(link);
};
render() { render() {
const { const {
enabled, enabled,
@ -198,6 +204,13 @@ export default class Editor extends Component<Props, State> {
> >
${enabled ? '●' : '○'} ${enabled ? '●' : '○'}
</button> </button>
<${FeedbackButton}
attributes=${{class: 'button share', title: 'Copy share link'}}
click=${this.copyShareLink}
feedbackText="💖"
text="📋"
timeout=${5 * 1000}
/>
</div> </div>
`; `;
} }

View File

@ -31,6 +31,10 @@
&.disabled { &.disabled {
background-color: var(--da-2); background-color: var(--da-2);
} }
&.share {
background-color: var(--da-7);
}
} }
.input { .input {