-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
58 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
web/src/lib/components/asset-viewer/editor/crop-tool/crop-preset.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<script lang="ts"> | ||
import Button, { type Color } from '$lib/components/elements/buttons/button.svelte'; | ||
import Icon from '$lib/components/elements/icon.svelte'; | ||
import type { CropAspectRatio } from '$lib/stores/asset-editor.store'; | ||
export let size: { | ||
icon: string; | ||
name: CropAspectRatio; | ||
viewBox: string; | ||
rotate?: boolean; | ||
}; | ||
export let selectedSize: CropAspectRatio; | ||
export let rotateHorizontal: boolean; | ||
export let selectType: (size: CropAspectRatio) => void; | ||
$: isSelected = selectedSize === size.name; | ||
$: buttonColor = (isSelected ? 'primary' : 'transparent-gray') as Color; | ||
$: rotatedTitle = (title: string, toRotate: boolean) => { | ||
let sides = title.split(':'); | ||
if (toRotate) { | ||
sides.reverse(); | ||
} | ||
return sides.join(':'); | ||
}; | ||
$: toRotate = (def: boolean | undefined) => { | ||
if (def === false) { | ||
return false; | ||
} | ||
return (def && !rotateHorizontal) || (!def && rotateHorizontal); | ||
}; | ||
</script> | ||
|
||
<li> | ||
<Button color={buttonColor} class="flex-col gap-1" size="sm" rounded="lg" on:click={() => selectType(size.name)}> | ||
<Icon size="1.75em" path={size.icon} viewBox={size.viewBox} class={toRotate(size.rotate) ? 'rotate-90' : ''} /> | ||
<span>{rotatedTitle(size.name, rotateHorizontal)}</span> | ||
</Button> | ||
</li> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters