1
0
mirror of https://github.com/garraflavatra/rolens.git synced 2025-01-18 13:07:58 +00:00

Added horizontal/vertical view toggle to the shell (#37)

This commit is contained in:
Romein van Buren 2023-07-19 20:18:40 +02:00
parent 9d577ac429
commit 77747c10c2
Signed by: romein
GPG Key ID: 0EFF8478ADDF6C49
3 changed files with 34 additions and 12 deletions

View File

@ -3,6 +3,7 @@
export let name = ''; export let name = '';
export let spin = false; export let spin = false;
export let rotation = 0;
if (name === 'loading') { if (name === 'loading') {
spin = true; spin = true;
@ -10,6 +11,19 @@
</script> </script>
<style> <style>
@keyframes spinning {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
svg {
transition: transform 0.25s;
will-change: transform;
}
svg.spinning {
animation: spinning 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
}
:global(.field) svg { :global(.field) svg {
width: 13px; width: 13px;
height: 13px; height: 13px;
@ -21,15 +35,6 @@
width: auto; width: auto;
vertical-align: bottom; vertical-align: bottom;
} }
@keyframes spinning {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
svg.spinning {
animation: spinning 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
}
</style> </style>
<svg <svg
@ -43,6 +48,7 @@
stroke-linecap="round" stroke-linecap="round"
stroke-linejoin="round" stroke-linejoin="round"
class:spinning={spin} class:spinning={spin}
style:transform="rotate({rotation}deg)"
> >
{@html icons[name] || ''} {@html icons[name] || ''}
</svg> </svg>

View File

@ -40,5 +40,6 @@
"!": "<path d=\"M10.29 3.86 1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0zM12 9v4M12 17h.01\"/>", "!": "<path d=\"M10.29 3.86 1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0zM12 9v4M12 17h.01\"/>",
"loading": "<path d=\"M12 2v4M12 18v4M4.93 4.93l2.83 2.83M16.24 16.24l2.83 2.83M2 12h4M18 12h4M4.93 19.07l2.83-2.83M16.24 7.76l2.83-2.83\"/>", "loading": "<path d=\"M12 2v4M12 18v4M4.93 4.93l2.83 2.83M16.24 16.24l2.83 2.83M2 12h4M18 12h4M4.93 19.07l2.83-2.83M16.24 7.76l2.83-2.83\"/>",
"shell": "<path d=\"m4 17 6-6-6-6M12 19h8\"/>", "shell": "<path d=\"m4 17 6-6-6-6M12 19h8\"/>",
"doc": "<path d=\"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z\"/><path d=\"M14 2v6h6M16 13H8M16 17H8M10 9H8\"/>" "doc": "<path d=\"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z\"/><path d=\"M14 2v6h6M16 13H8M16 17H8M10 9H8\"/>",
"columns": "<path d=\"M12 3h7a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-7m0-18H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h7m0-18v18\"/>"
} }

View File

@ -15,6 +15,7 @@
const extensions = [ javascript() ]; const extensions = [ javascript() ];
let script = ''; let script = '';
let result = {}; let result = {};
let horizontal = false;
let copySucceeded = false; let copySucceeded = false;
let timeout; let timeout;
let busy = false; let busy = false;
@ -72,6 +73,10 @@
timeout = setTimeout(() => copySucceeded = false, 1500); timeout = setTimeout(() => copySucceeded = false, 1500);
} }
function toggleView() {
horizontal = !horizontal;
}
$: visible && editor.focus(); $: visible && editor.focus();
onMount(() => { onMount(() => {
@ -94,7 +99,7 @@
onDestroy(() => clearTimeout(timeout)); onDestroy(() => clearTimeout(timeout));
</script> </script>
<div class="shell"> <div class="shell" class:horizontal>
<div class="overflow"> <div class="overflow">
<!-- svelte-ignore a11y-label-has-associated-control --> <!-- svelte-ignore a11y-label-has-associated-control -->
<label class="field"> <label class="field">
@ -130,6 +135,10 @@
</button> </button>
</div> </div>
<button class="button viewtoggle" title="Toggle horizontal/vertical view" on:click={toggleView}>
<Icon name="columns" rotation={horizontal ? 90 : 0} />
</button>
{#key result} {#key result}
<div class="status flash-green"> <div class="status flash-green">
{#if result?.status} {#if result?.status}
@ -145,6 +154,9 @@
display: grid; display: grid;
grid-template: 1fr auto / 1fr 1fr; grid-template: 1fr auto / 1fr 1fr;
} }
.shell.horizontal {
grid-template: 1fr 1fr auto / 1fr;
}
.overflow { .overflow {
overflow: auto; overflow: auto;
@ -189,7 +201,10 @@
align-items: center; align-items: center;
grid-column: 1 / 3; grid-column: 1 / 3;
} }
.controls .status { .controls .viewtoggle {
margin-left: auto; margin-left: auto;
} }
.shell.horizontal .controls {
grid-column: 1;
}
</style> </style>