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

feat(website): image editor #202

Draft
wants to merge 6 commits into
base: feature/website
Choose a base branch
from
Draft
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
54 changes: 54 additions & 0 deletions platform/website/src/assets/styles/global.scss
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,60 @@ input[type="password"] {
}
}

// Style the range input
input[type="range"] {
appearance: none;
-webkit-appearance: none;
background: transparent;

&:focus {
outline: none;
}

&::-moz-range-thumb {
appearance: none;
width: 1rem;
height: 1rem;
border-radius: 50%;
background: white;
cursor: pointer;
}

&::-ms-thumb {
width: 1rem;
height: 1rem;
border-radius: 50%;
background: white;
cursor: pointer;
}

&::-webkit-slider-thumb {
-webkit-appearance: none;
margin-top: -0.25rem;
width: 1rem;
height: 1rem;
border-radius: 50%;
background: white;
cursor: pointer;
}

&::-webkit-slider-runnable-track {
width: 100%;
height: 0.5rem;
cursor: pointer;
background: rgba($textColor, 0.25);
border-radius: 0.25rem;
}

&::-moz-range-track {
width: 100%;
height: 0.5rem;
cursor: pointer;
background: rgba($textColor, 0.25);
border-radius: 0.25rem;
}
}

// Screen reader only
// Hide but still render
.sr-only:not(:focus):not(:active) {
Expand Down
50 changes: 0 additions & 50 deletions platform/website/src/components/player.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -611,56 +611,6 @@
}

.volume {
appearance: none;
-webkit-appearance: none;
width: 8rem;
background: transparent;
}

.volume:focus {
outline: none;
}

.volume::-moz-range-thumb {
appearance: none;
width: 1rem;
height: 1rem;
border-radius: 50%;
background: white;
cursor: pointer;
}

.volume::-ms-thumb {
width: 1rem;
height: 1rem;
border-radius: 50%;
background: white;
cursor: pointer;
}

.volume::-webkit-slider-thumb {
-webkit-appearance: none;
margin-top: -0.25rem;
width: 1rem;
height: 1rem;
border-radius: 50%;
background: white;
cursor: pointer;
}

.volume::-webkit-slider-runnable-track {
width: 100%;
height: 0.5rem;
cursor: pointer;
background: rgba($textColor, 0.25);
border-radius: 0.25rem;
}

.volume::-moz-range-track {
width: 100%;
height: 0.5rem;
cursor: pointer;
background: rgba($textColor, 0.25);
border-radius: 0.25rem;
}
</style>
127 changes: 127 additions & 0 deletions platform/website/src/components/settings/image-editor-dialog.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
<script lang="ts">
import { createEventDispatcher } from "svelte";
import Dialog from "../dialog.svelte";
import ImageEditor from "./image-editor.svelte";
import Fa from "svelte-fa";
import {
faBorderAll,
faCheck,
faUpRightAndDownLeftFromCenter,
} from "@fortawesome/free-solid-svg-icons";
import Spinner from "../spinner.svelte";

export let src: string;

const dispatch = createEventDispatcher();

let loading = false;
let editor: ImageEditor;
let scale: number = 1;
let grid = false;

function onSubmit() {
if (!editor) return;
loading = true;
editor.calculateResult((blob) => {
loading = false;
dispatch("submit", { blob: blob });
});
}
</script>

<Dialog width={25} on:close>
<div class="container">
<div class="editor">
<ImageEditor
size={20 * 16}
minScale={1}
maxScale={2}
bind:this={editor}
bind:scale
{src}
gridOverlay={grid}
/>
<div class="input-row">
<Fa icon={faUpRightAndDownLeftFromCenter} fw />
<input class="scale" type="range" min="1" max="2" step="0.01" bind:value={scale} />
<button
class="button"
class:secondary={!grid}
class:primary={grid}
on:click={() => (grid = !grid)}
>
<Fa icon={faBorderAll} fw />
</button>
</div>
</div>
<div class="buttons">
<button class="button secondary" on:click={() => dispatch("close")}>Cancel</button>
<button class="button primary submit" on:click={onSubmit}>
Submit
{#if loading}
<Spinner />
{:else}
<Fa icon={faCheck} />
{/if}
</button>
</div>
</div>
</Dialog>

<style lang="scss">
@import "../../assets/styles/variables.scss";

.container {
display: flex;
flex-direction: column;
align-items: center;
gap: 2rem;
}

.editor {
display: flex;
flex-direction: column;
align-items: center;
gap: 1rem;

& > .input-row {
width: 100%;

display: flex;
justify-content: space-between;
align-items: center;
gap: 1rem;

color: $textColorLight;

& > .button {
padding: 0.5rem 0.6rem;
display: flex;
align-items: center;
justify-content: center;
}

& > .scale {
width: 100%;
}
}
}

.buttons {
width: 100%;

display: flex;
justify-content: space-between;
gap: 1rem;

& > .button {
padding: 0.4rem 0.8rem;

&.submit {
display: flex;
align-items: center;
gap: 0.5rem;
}
}
}
</style>
Loading
Loading