@peteai/presentation-editor 0.0.2 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/components/presentation-editor/active-layers-buttons.svelte +53 -0
- package/dist/components/presentation-editor/active-layers-buttons.svelte.d.ts +3 -0
- package/dist/components/presentation-editor/active-layers.svelte +181 -0
- package/dist/components/presentation-editor/active-layers.svelte.d.ts +3 -0
- package/dist/components/presentation-editor/color-indicator/color-indicator-gradient-def.svelte +81 -0
- package/dist/components/presentation-editor/color-indicator/color-indicator-gradient-def.svelte.d.ts +9 -0
- package/dist/components/presentation-editor/color-indicator/color-indicator-gradient.svelte +21 -0
- package/dist/components/presentation-editor/color-indicator/color-indicator-gradient.svelte.d.ts +8 -0
- package/dist/components/presentation-editor/color-indicator/color-indicator.svelte +23 -0
- package/dist/components/presentation-editor/color-indicator/color-indicator.svelte.d.ts +6 -0
- package/dist/components/presentation-editor/color-indicator/index.d.ts +4 -0
- package/dist/components/presentation-editor/color-indicator/index.js +6 -0
- package/dist/components/presentation-editor/cursor-tooltip.svelte +1 -1
- package/dist/components/presentation-editor/dragged.svelte +21 -11
- package/dist/components/presentation-editor/fonts.d.ts +3 -0
- package/dist/components/presentation-editor/fonts.js +1278 -0
- package/dist/components/presentation-editor/header.svelte +21 -33
- package/dist/components/presentation-editor/header.svelte.d.ts +16 -6
- package/dist/components/presentation-editor/hotkeys.svelte +85 -0
- package/dist/components/presentation-editor/{sidebar/layers.svelte.d.ts → hotkeys.svelte.d.ts} +3 -3
- package/dist/components/presentation-editor/layers/active-background-border.svelte +3 -7
- package/dist/components/presentation-editor/layers/active-layer-border.svelte +2 -5
- package/dist/components/presentation-editor/layers/active-layer-border.svelte.d.ts +0 -1
- package/dist/components/presentation-editor/layers/buttons/border-button/border-button.svelte +113 -129
- package/dist/components/presentation-editor/layers/buttons/border-button/border-button.svelte.d.ts +2 -2
- package/dist/components/presentation-editor/layers/buttons/corner-radius-button/corner-radius-button.svelte +51 -32
- package/dist/components/presentation-editor/layers/buttons/corner-radius-button/corner-radius-button.svelte.d.ts +2 -2
- package/dist/components/presentation-editor/layers/buttons/flip-button/flip-button.svelte +30 -7
- package/dist/components/presentation-editor/layers/buttons/flip-button/flip-button.svelte.d.ts +3 -3
- package/dist/components/presentation-editor/layers/buttons/opacity-button/opacity-button.svelte +76 -33
- package/dist/components/presentation-editor/layers/buttons/opacity-button/opacity-button.svelte.d.ts +3 -3
- package/dist/components/presentation-editor/layers/controls/corner-scale-control/corner-scale-control.svelte +89 -59
- package/dist/components/presentation-editor/layers/controls/corner-scale-control/corner-scale-control.svelte.d.ts +5 -100
- package/dist/components/presentation-editor/layers/controls/group-resize-control/group-resize-control.svelte +337 -0
- package/dist/components/presentation-editor/layers/controls/group-resize-control/group-resize-control.svelte.d.ts +104 -0
- package/dist/components/presentation-editor/layers/controls/group-resize-control/index.d.ts +2 -0
- package/dist/components/presentation-editor/layers/controls/group-resize-control/index.js +4 -0
- package/dist/components/presentation-editor/layers/controls/rotate-control/rotate-control.svelte +128 -43
- package/dist/components/presentation-editor/layers/controls/rotate-control/rotate-control.svelte.d.ts +1 -5
- package/dist/components/presentation-editor/layers/controls/side-resize-control/side-resize-control.svelte +68 -57
- package/dist/components/presentation-editor/layers/controls/side-resize-control/side-resize-control.svelte.d.ts +2 -110
- package/dist/components/presentation-editor/layers/controls/side-scale-control/side-scale-control.svelte +45 -32
- package/dist/components/presentation-editor/layers/controls/side-scale-control/side-scale-control.svelte.d.ts +2 -54
- package/dist/components/presentation-editor/layers/index.d.ts +4 -5
- package/dist/components/presentation-editor/layers/index.js +7 -8
- package/dist/components/presentation-editor/layers/layer-button.svelte +25 -7
- package/dist/components/presentation-editor/layers/layer-wrapper.svelte +212 -162
- package/dist/components/presentation-editor/layers/layer-wrapper.svelte.d.ts +2 -2
- package/dist/components/presentation-editor/layers/types/background/background-content-image.svelte +41 -0
- package/dist/components/presentation-editor/layers/types/background/background-content-image.svelte.d.ts +8 -0
- package/dist/components/presentation-editor/layers/types/background/background-layer-buttons.svelte +28 -74
- package/dist/components/presentation-editor/layers/types/background/background-layer-buttons.svelte.d.ts +2 -17
- package/dist/components/presentation-editor/layers/types/background/background-layer-content.svelte +19 -0
- package/dist/components/presentation-editor/layers/types/background/background-layer-content.svelte.d.ts +8 -0
- package/dist/components/presentation-editor/layers/types/background/background-layer.svelte +69 -61
- package/dist/components/presentation-editor/layers/types/background/background-layer.svelte.d.ts +2 -3
- package/dist/components/presentation-editor/layers/types/background/index.d.ts +2 -3
- package/dist/components/presentation-editor/layers/types/background/index.js +2 -3
- package/dist/components/presentation-editor/layers/types/html/buttons/alignment-button/alignment-button.svelte +55 -12
- package/dist/components/presentation-editor/layers/types/html/buttons/alignment-button/alignment-button.svelte.d.ts +3 -3
- package/dist/components/presentation-editor/layers/types/html/buttons/bold-button/bold-button.svelte +60 -8
- package/dist/components/presentation-editor/layers/types/html/buttons/bold-button/bold-button.svelte.d.ts +3 -3
- package/dist/components/presentation-editor/layers/types/html/buttons/case-button/case-button.svelte +59 -24
- package/dist/components/presentation-editor/layers/types/html/buttons/case-button/case-button.svelte.d.ts +3 -3
- package/dist/components/presentation-editor/layers/types/html/buttons/color-button/color-button.svelte +27 -76
- package/dist/components/presentation-editor/layers/types/html/buttons/color-button/color-button.svelte.d.ts +3 -3
- package/dist/components/presentation-editor/layers/types/html/buttons/font-family-button/font-family-button.svelte +36 -0
- package/dist/components/presentation-editor/layers/types/html/buttons/font-family-button/font-family-button.svelte.d.ts +7 -0
- package/dist/components/presentation-editor/layers/types/html/buttons/font-family-button/index.d.ts +2 -0
- package/dist/components/presentation-editor/layers/types/html/buttons/font-family-button/index.js +2 -0
- package/dist/components/presentation-editor/layers/types/html/buttons/font-size-button/font-size-button.svelte +72 -29
- package/dist/components/presentation-editor/layers/types/html/buttons/font-size-button/font-size-button.svelte.d.ts +3 -5
- package/dist/components/presentation-editor/layers/types/html/buttons/italic-button/italic-button.svelte +60 -8
- package/dist/components/presentation-editor/layers/types/html/buttons/italic-button/italic-button.svelte.d.ts +3 -3
- package/dist/components/presentation-editor/layers/types/html/buttons/list-button/list-button.svelte +71 -18
- package/dist/components/presentation-editor/layers/types/html/buttons/list-button/list-button.svelte.d.ts +3 -3
- package/dist/components/presentation-editor/layers/types/html/buttons/strikethrough-button/strikethrough-button.svelte +54 -8
- package/dist/components/presentation-editor/layers/types/html/buttons/strikethrough-button/strikethrough-button.svelte.d.ts +3 -3
- package/dist/components/presentation-editor/layers/types/html/buttons/underline-button/underline-button.svelte +54 -9
- package/dist/components/presentation-editor/layers/types/html/buttons/underline-button/underline-button.svelte.d.ts +3 -3
- package/dist/components/presentation-editor/layers/types/html/editor/createEditor.js +2 -2
- package/dist/components/presentation-editor/layers/types/html/editor/utils.d.ts +11 -0
- package/dist/components/presentation-editor/layers/types/html/editor/utils.js +88 -0
- package/dist/components/presentation-editor/layers/types/html/extensions/font-family/font-family.d.ts +27 -0
- package/dist/components/presentation-editor/layers/types/html/extensions/font-family/font-family.js +40 -0
- package/dist/components/presentation-editor/layers/types/html/extensions/font-family/index.d.ts +3 -0
- package/dist/components/presentation-editor/layers/types/html/extensions/font-family/index.js +3 -0
- package/dist/components/presentation-editor/layers/types/html/extensions/font-size/font-size.d.ts +5 -1
- package/dist/components/presentation-editor/layers/types/html/extensions/font-size/font-size.js +3 -7
- package/dist/components/presentation-editor/layers/types/html/extensions.d.ts +1 -0
- package/dist/components/presentation-editor/layers/types/html/extensions.js +56 -0
- package/dist/components/presentation-editor/layers/types/html/html-content.svelte +26 -5
- package/dist/components/presentation-editor/layers/types/html/html-layer-content.svelte +26 -0
- package/dist/components/presentation-editor/layers/types/html/html-layer-content.svelte.d.ts +9 -0
- package/dist/components/presentation-editor/layers/types/html/html-layer-edit.svelte +103 -0
- package/dist/components/presentation-editor/layers/types/html/html-layer-edit.svelte.d.ts +8 -0
- package/dist/components/presentation-editor/layers/types/html/html-layer.svelte +61 -53
- package/dist/components/presentation-editor/layers/types/html/index.d.ts +3 -5
- package/dist/components/presentation-editor/layers/types/html/index.js +3 -56
- package/dist/components/presentation-editor/layers/types/image/{image-content.svelte → image-layer-content.svelte} +11 -3
- package/dist/components/presentation-editor/layers/types/image/image-layer-content.svelte.d.ts +8 -0
- package/dist/components/presentation-editor/layers/types/image/image-layer.svelte +51 -21
- package/dist/components/presentation-editor/layers/types/image/index.d.ts +2 -4
- package/dist/components/presentation-editor/layers/types/image/index.js +2 -4
- package/dist/components/presentation-editor/layers/utils.d.ts +68 -9
- package/dist/components/presentation-editor/layers/utils.js +260 -25
- package/dist/components/presentation-editor/menu/background-menu-content.svelte +80 -0
- package/dist/components/presentation-editor/menu/background-menu-content.svelte.d.ts +9 -0
- package/dist/components/presentation-editor/menu/layer-menu-content.svelte +183 -0
- package/dist/components/presentation-editor/menu/layer-menu-content.svelte.d.ts +3 -0
- package/dist/components/presentation-editor/menu/slide-menu-content.svelte +67 -0
- package/dist/components/presentation-editor/menu/slide-menu-content.svelte.d.ts +9 -0
- package/dist/components/presentation-editor/presentation-editor.svelte +119 -175
- package/dist/components/presentation-editor/presentation-editor.svelte.js +597 -136
- package/dist/components/presentation-editor/sidebar/color-sidebar/color-sidebar-color.svelte +58 -0
- package/dist/components/presentation-editor/sidebar/color-sidebar/color-sidebar-color.svelte.d.ts +10 -0
- package/dist/components/presentation-editor/sidebar/color-sidebar/color-sidebar-gradient-picker.svelte +144 -0
- package/dist/components/presentation-editor/sidebar/color-sidebar/color-sidebar-gradient-picker.svelte.d.ts +7 -0
- package/dist/components/presentation-editor/sidebar/color-sidebar/color-sidebar.svelte +404 -0
- package/dist/components/presentation-editor/sidebar/color-sidebar/color-sidebar.svelte.d.ts +3 -0
- package/dist/components/presentation-editor/sidebar/color-sidebar/index.d.ts +2 -0
- package/dist/components/presentation-editor/sidebar/color-sidebar/index.js +2 -0
- package/dist/components/presentation-editor/sidebar/font-sidebar/font-sidebar-button.svelte +26 -0
- package/dist/components/presentation-editor/sidebar/font-sidebar/font-sidebar-button.svelte.d.ts +8 -0
- package/dist/components/presentation-editor/sidebar/font-sidebar/font-sidebar.svelte +216 -0
- package/dist/components/presentation-editor/sidebar/font-sidebar/font-sidebar.svelte.d.ts +3 -0
- package/dist/components/presentation-editor/sidebar/font-sidebar/index.d.ts +2 -0
- package/dist/components/presentation-editor/sidebar/font-sidebar/index.js +2 -0
- package/dist/components/presentation-editor/sidebar/position-slidebar.svelte +130 -0
- package/dist/components/presentation-editor/sidebar/position-slidebar.svelte.d.ts +18 -0
- package/dist/components/presentation-editor/sidebar/sidebar-text-tab-button.svelte +90 -0
- package/dist/components/presentation-editor/sidebar/sidebar-text-tab-button.svelte.d.ts +7 -0
- package/dist/components/presentation-editor/sidebar/sidebar-text-tab.svelte +82 -0
- package/dist/components/presentation-editor/sidebar/sidebar-text-tab.svelte.d.ts +18 -0
- package/dist/components/presentation-editor/sidebar/{images-library.svelte → sidebar-uploads-tab.svelte} +0 -1
- package/dist/components/presentation-editor/sidebar/sidebar-uploads-tab.svelte.d.ts +3 -0
- package/dist/components/presentation-editor/sidebar/sidebar-wrapper.svelte +25 -0
- package/dist/components/presentation-editor/sidebar/sidebar-wrapper.svelte.d.ts +7 -0
- package/dist/components/presentation-editor/sidebar/sidebar.svelte +71 -15
- package/dist/components/presentation-editor/sidebar/sidebar.svelte.d.ts +16 -5
- package/dist/components/presentation-editor/sidebar/uploads-image.svelte +28 -11
- package/dist/components/presentation-editor/slide-editor.svelte +20 -22
- package/dist/components/presentation-editor/slide-inner.svelte +19 -18
- package/dist/components/presentation-editor/slides-navigation/slide-preview.svelte +61 -52
- package/dist/components/presentation-editor/slides-navigation/slides-navigation.svelte +6 -8
- package/dist/components/presentation-editor/snapping-guides.svelte +3 -3
- package/dist/components/presentation-editor/types.d.ts +67 -27
- package/dist/components/presentation-editor/utils.d.ts +50 -1
- package/dist/components/presentation-editor/utils.js +101 -6
- package/dist/components/ui/button/button.svelte +3 -2
- package/dist/components/ui/button/button.svelte.d.ts +5 -82
- package/dist/components/ui/color-picker/color-picker-alpha-grid.svelte +43 -0
- package/dist/components/ui/color-picker/color-picker-alpha-grid.svelte.d.ts +8 -0
- package/dist/components/ui/color-picker/color-picker.svelte +344 -0
- package/dist/components/ui/color-picker/color-picker.svelte.d.ts +13 -0
- package/dist/components/ui/color-picker/index.d.ts +3 -0
- package/dist/components/ui/color-picker/index.js +5 -0
- package/dist/components/ui/context-menu/context-menu-shortcut.svelte +6 -3
- package/dist/components/ui/context-menu/context-menu-sub-trigger.svelte +1 -1
- package/dist/components/ui/dropdown-menu/dropdown-menu-item.svelte +1 -1
- package/dist/components/ui/dropdown-menu/dropdown-menu-shortcut.svelte +6 -3
- package/dist/components/ui/dropdown-menu/dropdown-menu-sub-trigger.svelte +1 -1
- package/dist/components/ui/infinite-loader/index.d.ts +4 -0
- package/dist/components/ui/infinite-loader/index.js +4 -0
- package/dist/components/ui/infinite-loader/infinite-loader-loop-tracker.d.ts +13 -0
- package/dist/components/ui/infinite-loader/infinite-loader-loop-tracker.js +44 -0
- package/dist/components/ui/infinite-loader/infinite-loader-state.svelte.d.ts +15 -0
- package/dist/components/ui/infinite-loader/infinite-loader-state.svelte.js +28 -0
- package/dist/components/ui/infinite-loader/infinite-loader.svelte +149 -0
- package/dist/components/ui/infinite-loader/infinite-loader.svelte.d.ts +17 -0
- package/dist/components/ui/input/input.svelte +1 -1
- package/dist/components/ui/slider/slider.svelte +20 -18
- package/dist/components/ui/tabs/index.d.ts +6 -0
- package/dist/components/ui/tabs/index.js +8 -0
- package/dist/components/ui/tabs/tabs-content.svelte +19 -0
- package/dist/components/ui/tabs/tabs-content.svelte.d.ts +4 -0
- package/dist/components/ui/tabs/tabs-list.svelte +19 -0
- package/dist/components/ui/tabs/tabs-list.svelte.d.ts +4 -0
- package/dist/components/ui/tabs/tabs-trigger.svelte +19 -0
- package/dist/components/ui/tabs/tabs-trigger.svelte.d.ts +4 -0
- package/dist/components/ui/toggle/toggle.svelte +3 -2
- package/dist/components/ui/toggle/toggle.svelte.d.ts +2 -46
- package/dist/plugin.js +3 -2
- package/dist/utils.d.ts +1 -0
- package/dist/utils.js +1 -0
- package/package.json +28 -25
- package/dist/components/presentation-editor/app.css +0 -12
- package/dist/components/presentation-editor/layers/hovered-layer.svelte +0 -34
- package/dist/components/presentation-editor/layers/hovered-layer.svelte.d.ts +0 -7
- package/dist/components/presentation-editor/layers/types/background/background-content.svelte +0 -11
- package/dist/components/presentation-editor/layers/types/background/background-content.svelte.d.ts +0 -7
- package/dist/components/presentation-editor/layers/types/background/background-layer-thumb.svelte +0 -12
- package/dist/components/presentation-editor/layers/types/background/background-layer-thumb.svelte.d.ts +0 -7
- package/dist/components/presentation-editor/layers/types/html/html-layer-active.svelte +0 -159
- package/dist/components/presentation-editor/layers/types/html/html-layer-active.svelte.d.ts +0 -8
- package/dist/components/presentation-editor/layers/types/html/html-layer-buttons.svelte +0 -42
- package/dist/components/presentation-editor/layers/types/html/html-layer-buttons.svelte.d.ts +0 -10
- package/dist/components/presentation-editor/layers/types/html/html-layer-thumb.svelte +0 -24
- package/dist/components/presentation-editor/layers/types/html/html-layer-thumb.svelte.d.ts +0 -8
- package/dist/components/presentation-editor/layers/types/image/image-content.svelte.d.ts +0 -8
- package/dist/components/presentation-editor/layers/types/image/image-layer-buttons.svelte +0 -21
- package/dist/components/presentation-editor/layers/types/image/image-layer-buttons.svelte.d.ts +0 -7
- package/dist/components/presentation-editor/layers/types/image/image-layer-thumb.svelte +0 -13
- package/dist/components/presentation-editor/layers/types/image/image-layer-thumb.svelte.d.ts +0 -8
- package/dist/components/presentation-editor/sidebar/images-library.svelte.d.ts +0 -3
- package/dist/components/presentation-editor/sidebar/layers.svelte +0 -94
- package/dist/components/presentation-editor/slides-navigation/buttons/slide-delete-button.svelte +0 -32
- package/dist/components/presentation-editor/slides-navigation/buttons/slide-delete-button.svelte.d.ts +0 -10
- package/dist/components/presentation-editor/slides-navigation/buttons/slide-duplicate-button.svelte +0 -34
- package/dist/components/presentation-editor/slides-navigation/buttons/slide-duplicate-button.svelte.d.ts +0 -10
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import SettingsIcon from 'lucide-svelte/icons/settings-2';
|
|
3
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
4
|
+
import { ColorIndicator } from '../../color-indicator/index.js';
|
|
5
|
+
import { ColorPickerAlphaGrid } from '../../../ui/color-picker/index.js';
|
|
6
|
+
import { cn } from '../../../../utils.js';
|
|
7
|
+
|
|
8
|
+
interface Props extends HTMLAttributes<HTMLButtonElement> {
|
|
9
|
+
color: string;
|
|
10
|
+
currentColor: string;
|
|
11
|
+
radius?: number;
|
|
12
|
+
settings?: boolean;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
let {
|
|
16
|
+
class: className,
|
|
17
|
+
color,
|
|
18
|
+
currentColor,
|
|
19
|
+
radius,
|
|
20
|
+
settings = true,
|
|
21
|
+
...restProps
|
|
22
|
+
}: Props = $props();
|
|
23
|
+
</script>
|
|
24
|
+
|
|
25
|
+
<button
|
|
26
|
+
class={cn(
|
|
27
|
+
'group relative h-full w-full overflow-hidden rounded-full after:absolute after:inset-0 after:rounded-full after:transition-shadow',
|
|
28
|
+
color === currentColor ? 'after:shadow-active' : 'hover:after:shadow-hover',
|
|
29
|
+
className,
|
|
30
|
+
)}
|
|
31
|
+
{...restProps}
|
|
32
|
+
>
|
|
33
|
+
<div class="wrapper after:shadow-inner-1 relative h-full w-full after:absolute after:inset-0">
|
|
34
|
+
<ColorPickerAlphaGrid size={12}>
|
|
35
|
+
<ColorIndicator {color} />
|
|
36
|
+
</ColorPickerAlphaGrid>
|
|
37
|
+
</div>
|
|
38
|
+
|
|
39
|
+
{#if settings && color === currentColor}
|
|
40
|
+
<div
|
|
41
|
+
class="pointer-events-none absolute inset-0 flex items-center justify-center opacity-0 transition-opacity group-hover:opacity-100"
|
|
42
|
+
>
|
|
43
|
+
<div class="bg-background text-foreground rounded-full p-1">
|
|
44
|
+
<SettingsIcon class="h-4 w-4" />
|
|
45
|
+
</div>
|
|
46
|
+
</div>
|
|
47
|
+
{/if}
|
|
48
|
+
</button>
|
|
49
|
+
|
|
50
|
+
<style>
|
|
51
|
+
.wrapper {
|
|
52
|
+
border-radius: inherit;
|
|
53
|
+
|
|
54
|
+
&::after {
|
|
55
|
+
border-radius: inherit;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
</style>
|
package/dist/components/presentation-editor/sidebar/color-sidebar/color-sidebar-color.svelte.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
2
|
+
interface Props extends HTMLAttributes<HTMLButtonElement> {
|
|
3
|
+
color: string;
|
|
4
|
+
currentColor: string;
|
|
5
|
+
radius?: number;
|
|
6
|
+
settings?: boolean;
|
|
7
|
+
}
|
|
8
|
+
declare const ColorSidebarColor: import("svelte").Component<Props, {}, "">;
|
|
9
|
+
type ColorSidebarColor = ReturnType<typeof ColorSidebarColor>;
|
|
10
|
+
export default ColorSidebarColor;
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import XIcon from 'lucide-svelte/icons/x';
|
|
3
|
+
import PlusIcon from 'lucide-svelte/icons/plus';
|
|
4
|
+
import { Button, buttonVariants } from '../../../ui/button/index.js';
|
|
5
|
+
import { ColorIndicator } from '../../color-indicator/index.js';
|
|
6
|
+
import { ColorPicker, ColorPickerAlphaGrid } from '../../../ui/color-picker/index.js';
|
|
7
|
+
import * as Popover from '../../../ui/popover/index.js';
|
|
8
|
+
import { cn } from '../../../../utils.js';
|
|
9
|
+
import { gradientToString, stringToGradient } from '../../utils.js';
|
|
10
|
+
import type { Gradient } from '../../types.js';
|
|
11
|
+
import ColorSidebarColor from './color-sidebar-color.svelte';
|
|
12
|
+
|
|
13
|
+
interface Props {
|
|
14
|
+
color: string;
|
|
15
|
+
setColor: (value: string, debounce?: boolean) => void;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const { color, setColor }: Props = $props();
|
|
19
|
+
|
|
20
|
+
const gradient = $derived(stringToGradient(color));
|
|
21
|
+
|
|
22
|
+
let openIndex: number | null = $state(null);
|
|
23
|
+
|
|
24
|
+
const gradientTypes: Gradient['type'][] = [
|
|
25
|
+
'linear90',
|
|
26
|
+
'linear180',
|
|
27
|
+
'linear135',
|
|
28
|
+
'radialCenter',
|
|
29
|
+
'radialTopLeft',
|
|
30
|
+
];
|
|
31
|
+
|
|
32
|
+
const addColor = () => {
|
|
33
|
+
const lastColor = gradient.colors.at(-1);
|
|
34
|
+
if (!lastColor) return;
|
|
35
|
+
const newColors = [...gradient.colors, lastColor];
|
|
36
|
+
openIndex = gradient.colors.length;
|
|
37
|
+
setColor(gradientToString({ ...gradient, colors: newColors }));
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const removeColor = (index: number) => {
|
|
41
|
+
if (gradient.colors.length <= 2) return;
|
|
42
|
+
const newColors = [...gradient.colors.slice(0, index), ...gradient.colors.slice(index + 1)];
|
|
43
|
+
openIndex = null;
|
|
44
|
+
setColor(gradientToString({ ...gradient, colors: newColors }));
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const updateColor = (hex: string, index: number) => {
|
|
48
|
+
const newColors = [...gradient.colors];
|
|
49
|
+
newColors[index] = hex;
|
|
50
|
+
setColor(gradientToString({ ...gradient, colors: newColors }), true);
|
|
51
|
+
};
|
|
52
|
+
</script>
|
|
53
|
+
|
|
54
|
+
<div class="flex flex-col gap-2">
|
|
55
|
+
<div class="mt-2 text-sm font-semibold">Gradient colors</div>
|
|
56
|
+
|
|
57
|
+
<div class="grid grid-cols-6 items-center justify-items-center gap-2">
|
|
58
|
+
{#each gradient.colors as color, index}
|
|
59
|
+
<div class="group relative h-10 w-10">
|
|
60
|
+
<Popover.Root
|
|
61
|
+
open={openIndex === index}
|
|
62
|
+
onOpenChange={(val) => {
|
|
63
|
+
openIndex = val ? index : null;
|
|
64
|
+
}}
|
|
65
|
+
>
|
|
66
|
+
<Popover.Trigger
|
|
67
|
+
class={cn(
|
|
68
|
+
buttonVariants({ variant: 'ghost', size: 'icon' }),
|
|
69
|
+
'hover:after:shadow-hover data-[state=open]:after:shadow-active relative h-full w-full shrink-0 overflow-hidden rounded-full after:absolute after:inset-0 after:rounded-full after:transition-shadow',
|
|
70
|
+
)}
|
|
71
|
+
>
|
|
72
|
+
<div
|
|
73
|
+
class="wrapper after:shadow-inner-1 relative h-full w-full after:absolute after:inset-0 after:rounded-full"
|
|
74
|
+
>
|
|
75
|
+
<ColorPickerAlphaGrid size={12}>
|
|
76
|
+
<ColorIndicator {color} />
|
|
77
|
+
</ColorPickerAlphaGrid>
|
|
78
|
+
</div>
|
|
79
|
+
</Popover.Trigger>
|
|
80
|
+
<Popover.Content align="start" sideOffset={2} class="w-80 p-4">
|
|
81
|
+
<ColorPicker
|
|
82
|
+
hex={color}
|
|
83
|
+
alpha={true}
|
|
84
|
+
onChange={({ hex }) => updateColor(hex, index)}
|
|
85
|
+
onDelete={gradient.colors.length > 2 ? () => removeColor(index) : undefined}
|
|
86
|
+
/>
|
|
87
|
+
</Popover.Content>
|
|
88
|
+
</Popover.Root>
|
|
89
|
+
{#if gradient.colors.length > 2}
|
|
90
|
+
<div class="absolute right-0 top-0 opacity-0 transition-opacity group-hover:opacity-100">
|
|
91
|
+
<Button
|
|
92
|
+
variant="muted"
|
|
93
|
+
size="icon-xs"
|
|
94
|
+
class="absolute h-6 w-6 -translate-x-1/2 -translate-y-1/2 rounded-full"
|
|
95
|
+
onclick={() => removeColor(index)}
|
|
96
|
+
>
|
|
97
|
+
<XIcon class="h-3 w-3" />
|
|
98
|
+
</Button>
|
|
99
|
+
</div>
|
|
100
|
+
{/if}
|
|
101
|
+
</div>
|
|
102
|
+
{/each}
|
|
103
|
+
|
|
104
|
+
{#if gradient.colors.length < 10}
|
|
105
|
+
<Button
|
|
106
|
+
variant="ghost"
|
|
107
|
+
size="icon"
|
|
108
|
+
class="hover:after:shadow-hover relative shrink-0 p-0 after:absolute after:inset-0 after:rounded-full after:transition-shadow"
|
|
109
|
+
onclick={addColor}
|
|
110
|
+
>
|
|
111
|
+
<div
|
|
112
|
+
class="after:shadow-inner-1 relative h-full w-full after:absolute after:inset-0 after:rounded-full"
|
|
113
|
+
>
|
|
114
|
+
<div
|
|
115
|
+
class="h-full w-full rounded-full"
|
|
116
|
+
style:background={`conic-gradient(red, orange, yellow, green, blue, indigo, violet, red)`}
|
|
117
|
+
></div>
|
|
118
|
+
<span class="absolute inset-0 flex h-full w-full items-center justify-center">
|
|
119
|
+
<span
|
|
120
|
+
class="bg-background text-foreground flex h-6 w-6 items-center justify-center rounded-full"
|
|
121
|
+
>
|
|
122
|
+
<PlusIcon />
|
|
123
|
+
</span>
|
|
124
|
+
</span>
|
|
125
|
+
</div>
|
|
126
|
+
</Button>
|
|
127
|
+
{/if}
|
|
128
|
+
</div>
|
|
129
|
+
|
|
130
|
+
<div class="mt-2 text-sm font-semibold">Style</div>
|
|
131
|
+
|
|
132
|
+
<div class="flex h-10 w-full gap-2">
|
|
133
|
+
{#each gradientTypes as type}
|
|
134
|
+
{@const gradientString = gradientToString({ ...gradient, type })}
|
|
135
|
+
<ColorSidebarColor
|
|
136
|
+
class="rounded-lg after:rounded-lg"
|
|
137
|
+
color={gradientString}
|
|
138
|
+
currentColor={color}
|
|
139
|
+
settings={false}
|
|
140
|
+
onclick={() => setColor(gradientString)}
|
|
141
|
+
/>
|
|
142
|
+
{/each}
|
|
143
|
+
</div>
|
|
144
|
+
</div>
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
interface Props {
|
|
2
|
+
color: string;
|
|
3
|
+
setColor: (value: string, debounce?: boolean) => void;
|
|
4
|
+
}
|
|
5
|
+
declare const ColorSidebarGradientPicker: import("svelte").Component<Props, {}, "">;
|
|
6
|
+
type ColorSidebarGradientPicker = ReturnType<typeof ColorSidebarGradientPicker>;
|
|
7
|
+
export default ColorSidebarGradientPicker;
|
|
@@ -0,0 +1,404 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import PlusIcon from 'lucide-svelte/icons/plus';
|
|
3
|
+
// import PaletteIcon from 'lucide-svelte/icons/palette';
|
|
4
|
+
import { ColorPicker } from '../../../ui/color-picker/index.js';
|
|
5
|
+
import * as Popover from '../../../ui/popover/index.js';
|
|
6
|
+
import * as Tabs from '../../../ui/tabs/index.js';
|
|
7
|
+
import { cn, createDebouncedCallback } from '../../../../utils.js';
|
|
8
|
+
import { getPresentationEditorContext } from '../../presentation-editor.svelte.js';
|
|
9
|
+
import type { HistoryAction, Gradient, ImageLayer, HtmlLayer } from '../../types.js';
|
|
10
|
+
import SidebarWrapper from '../sidebar-wrapper.svelte';
|
|
11
|
+
import ColorSidebarGradientPicker from './color-sidebar-gradient-picker.svelte';
|
|
12
|
+
import ColorSidebarColor from './color-sidebar-color.svelte';
|
|
13
|
+
import { gradientToString, stringToGradient } from '../../utils.js';
|
|
14
|
+
import {
|
|
15
|
+
createEditorNotReactive,
|
|
16
|
+
extractNodeColors,
|
|
17
|
+
extractSelectionColors,
|
|
18
|
+
} from '../../layers/types/html/editor/utils.js';
|
|
19
|
+
import { extractBorderColors } from '../../layers/utils.js';
|
|
20
|
+
|
|
21
|
+
let open = $state(false);
|
|
22
|
+
|
|
23
|
+
const editor = getPresentationEditorContext();
|
|
24
|
+
|
|
25
|
+
const { htmlEditor } = editor;
|
|
26
|
+
|
|
27
|
+
const defaultColor = '#000000';
|
|
28
|
+
|
|
29
|
+
const gradientsAllowed = $derived(
|
|
30
|
+
editor.activeSidebarPopup &&
|
|
31
|
+
['backgroundColor', 'borderColor'].includes(editor.activeSidebarPopup),
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
const defaultSolidColors = {
|
|
35
|
+
'#000000': 'Black',
|
|
36
|
+
'#545454': 'Dark Gray',
|
|
37
|
+
'#737373': 'Gray',
|
|
38
|
+
'#a6a6a6': 'Gray',
|
|
39
|
+
'#d9d9d9': 'Light Gray',
|
|
40
|
+
'#ffffff': 'White',
|
|
41
|
+
'#ff3131': 'Bright Red',
|
|
42
|
+
'#ff5757': 'Coral Red',
|
|
43
|
+
'#ff66c4': 'Pink',
|
|
44
|
+
'#cb6ce6': 'Magenta',
|
|
45
|
+
'#8c52ff': 'Purple',
|
|
46
|
+
'#5e17eb': 'Violet',
|
|
47
|
+
'#0097b2': 'Dark Turquoise',
|
|
48
|
+
'#0cc0df': 'Aqua Blue',
|
|
49
|
+
'#5ce1e6': 'Turquoise Blue',
|
|
50
|
+
'#38b6ff': 'Light Blue',
|
|
51
|
+
'#5271ff': 'Royal Blue',
|
|
52
|
+
'#004aad': 'Cobalt Blue',
|
|
53
|
+
'#00bf63': 'Green',
|
|
54
|
+
'#7ed957': 'Grass Green',
|
|
55
|
+
'#c1ff72': 'Lime',
|
|
56
|
+
'#ffde59': 'Yellow',
|
|
57
|
+
'#ffbd59': 'Peach',
|
|
58
|
+
'#ff914d': 'Orange',
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const defaultGradients = [
|
|
62
|
+
'linear90:#000000ff,#737373ff',
|
|
63
|
+
'linear90:#000000ff,#c89116ff',
|
|
64
|
+
'linear90:#000000ff,#3533cdff',
|
|
65
|
+
'linear90:#a6a6a6ff,#ffffffff',
|
|
66
|
+
'linear90:#fff7adff,#ffa9f9ff',
|
|
67
|
+
'linear90:#cdffd8ff,#94b9ffff',
|
|
68
|
+
'linear90:#ff3131ff,#ff914dff',
|
|
69
|
+
'linear90:#ff5757ff,#8c52ffff',
|
|
70
|
+
'linear90:#5170ffff,#ff66c4ff',
|
|
71
|
+
'linear90:#004aadff,#cb6ce6ff',
|
|
72
|
+
'linear90:#8c52ffff,#5ce1e6ff',
|
|
73
|
+
'linear90:#5de0e6ff,#004aadff',
|
|
74
|
+
'linear90:#8c52ffff,#00bf63ff',
|
|
75
|
+
'linear90:#0097b2ff,#7ed957ff',
|
|
76
|
+
'linear90:#0cc0dfff,#ffde59ff',
|
|
77
|
+
'linear90:#ffde59ff,#ff914dff',
|
|
78
|
+
'linear90:#ff66c4ff,#ffde59ff',
|
|
79
|
+
'linear90:#8c52ffff,#ff914dff',
|
|
80
|
+
];
|
|
81
|
+
|
|
82
|
+
const isGradient = (color: string) => ~color.indexOf(':');
|
|
83
|
+
|
|
84
|
+
const currentColor = $derived.by(() => {
|
|
85
|
+
if (editor.activeSidebarPopup === 'backgroundColor') {
|
|
86
|
+
return editor.activeSlide.backgroundColor;
|
|
87
|
+
} else if (editor.activeSidebarPopup === 'textColor') {
|
|
88
|
+
if ($htmlEditor) {
|
|
89
|
+
const colors = extractSelectionColors($htmlEditor);
|
|
90
|
+
if (colors.length === 1) {
|
|
91
|
+
return $htmlEditor.getAttributes('textStyle').color || defaultColor;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
} else if (editor.activeSidebarPopup === 'borderColor') {
|
|
95
|
+
const borderColors = extractBorderColors(
|
|
96
|
+
editor.activeLayers.filter((layer) => layer.type === 'image'),
|
|
97
|
+
);
|
|
98
|
+
if (!borderColors) {
|
|
99
|
+
return defaultColor;
|
|
100
|
+
} else if (borderColors.length === 1) {
|
|
101
|
+
return borderColors[0];
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
const documentColors = $derived.by(() => {
|
|
107
|
+
const colorSet = new Set<string>();
|
|
108
|
+
|
|
109
|
+
editor.slides.forEach((slide) => {
|
|
110
|
+
if (slide.backgroundColor) {
|
|
111
|
+
colorSet.add(slide.backgroundColor);
|
|
112
|
+
}
|
|
113
|
+
slide.layers.forEach((layer) => {
|
|
114
|
+
if (layer.type === 'html') {
|
|
115
|
+
extractNodeColors(layer.html, colorSet);
|
|
116
|
+
} else if (layer.type === 'image') {
|
|
117
|
+
if (layer.borderWidth && layer.borderColor) {
|
|
118
|
+
colorSet.add(layer.borderColor);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
let colorsArray = Array.from(colorSet);
|
|
125
|
+
|
|
126
|
+
if (!colorsArray.length) {
|
|
127
|
+
colorsArray.push('#ffffff');
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (!gradientsAllowed) {
|
|
131
|
+
colorsArray = colorsArray.filter((color) => !isGradient(color));
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return colorsArray.sort();
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
let undo: object | null = null;
|
|
138
|
+
let initialBorderColor: (ImageLayer & { state: ImageLayer })[] | null = null;
|
|
139
|
+
let initialTextColor: (HtmlLayer & { state: HtmlLayer })[] | null = null;
|
|
140
|
+
|
|
141
|
+
const editorNotReactive = createEditorNotReactive();
|
|
142
|
+
|
|
143
|
+
const setColor = (value: string, debounce = false) => {
|
|
144
|
+
console.log('setColor', { value, debounce });
|
|
145
|
+
if (currentColor === value) {
|
|
146
|
+
open = true;
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
if (editor.activeSidebarPopup === 'backgroundColor') {
|
|
151
|
+
if (!undo) {
|
|
152
|
+
undo = { backgroundColor: editor.activeSlide.backgroundColor };
|
|
153
|
+
}
|
|
154
|
+
const redo = { backgroundColor: value };
|
|
155
|
+
Object.assign(editor.activeSlide, redo);
|
|
156
|
+
const action: HistoryAction = { type: 'slide', slideId: editor.activeSlide.id, undo, redo };
|
|
157
|
+
if (debounce) {
|
|
158
|
+
debouncedUpdates(action);
|
|
159
|
+
} else {
|
|
160
|
+
editor.historyPush(action);
|
|
161
|
+
undo = null;
|
|
162
|
+
}
|
|
163
|
+
} else if (editor.activeSidebarPopup === 'textColor') {
|
|
164
|
+
if (editor.activeAction?.type === 'edit') {
|
|
165
|
+
if (value === defaultColor) {
|
|
166
|
+
$htmlEditor.chain().focus().unsetColor().run();
|
|
167
|
+
} else {
|
|
168
|
+
$htmlEditor.chain().focus().setColor(value).run();
|
|
169
|
+
}
|
|
170
|
+
} else {
|
|
171
|
+
if (!initialTextColor) {
|
|
172
|
+
initialTextColor = editor.activeLayers
|
|
173
|
+
.filter((layer) => layer.type === 'html')
|
|
174
|
+
.map((layer) => ({ ...layer, state: layer }));
|
|
175
|
+
}
|
|
176
|
+
const action: HistoryAction = {
|
|
177
|
+
type: 'layersGroup',
|
|
178
|
+
actions: initialTextColor.map((layerWithState) => {
|
|
179
|
+
const { state, ...layer } = layerWithState;
|
|
180
|
+
|
|
181
|
+
let chain = editorNotReactive.chain().setContent(layer.html).selectAll();
|
|
182
|
+
if (value === defaultColor) {
|
|
183
|
+
chain = chain.unsetColor();
|
|
184
|
+
} else {
|
|
185
|
+
chain = chain.setColor(value);
|
|
186
|
+
}
|
|
187
|
+
chain.run();
|
|
188
|
+
|
|
189
|
+
const undo = { html: layer.html };
|
|
190
|
+
const redo = { html: editorNotReactive.getJSON() };
|
|
191
|
+
Object.assign(state, redo);
|
|
192
|
+
|
|
193
|
+
return {
|
|
194
|
+
type: 'layer',
|
|
195
|
+
slideId: editor.activeSlide.id,
|
|
196
|
+
layer: { id: layer.id, type: layer.type },
|
|
197
|
+
undo,
|
|
198
|
+
redo,
|
|
199
|
+
};
|
|
200
|
+
}),
|
|
201
|
+
};
|
|
202
|
+
if (debounce) {
|
|
203
|
+
debouncedUpdates(action);
|
|
204
|
+
} else {
|
|
205
|
+
editor.historyPush(action);
|
|
206
|
+
initialTextColor = null;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
if ($htmlEditor) {
|
|
210
|
+
if (value === defaultColor) {
|
|
211
|
+
$htmlEditor.chain().focus().unsetColor().run();
|
|
212
|
+
} else {
|
|
213
|
+
$htmlEditor.chain().focus().setColor(value).run();
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
} else if (editor.activeSidebarPopup === 'borderColor') {
|
|
217
|
+
if (!initialBorderColor) {
|
|
218
|
+
initialBorderColor = editor.activeLayers
|
|
219
|
+
.filter((layer) => layer.type === 'image')
|
|
220
|
+
.filter((layer) => layer.borderWidth)
|
|
221
|
+
.map((layer) => ({ ...layer, state: layer }));
|
|
222
|
+
}
|
|
223
|
+
const action: HistoryAction = {
|
|
224
|
+
type: 'layersGroup',
|
|
225
|
+
actions: initialBorderColor.map((layerWithState) => {
|
|
226
|
+
const { state, ...layer } = layerWithState;
|
|
227
|
+
|
|
228
|
+
const undo = { borderColor: layer.borderColor };
|
|
229
|
+
const redo = { borderColor: value };
|
|
230
|
+
|
|
231
|
+
Object.assign(state, redo);
|
|
232
|
+
|
|
233
|
+
return {
|
|
234
|
+
type: 'layer',
|
|
235
|
+
slideId: editor.activeSlide.id,
|
|
236
|
+
layer: { id: layer.id, type: layer.type },
|
|
237
|
+
undo,
|
|
238
|
+
redo,
|
|
239
|
+
};
|
|
240
|
+
}),
|
|
241
|
+
};
|
|
242
|
+
if (debounce) {
|
|
243
|
+
debouncedUpdates(action);
|
|
244
|
+
} else {
|
|
245
|
+
editor.historyPush(action);
|
|
246
|
+
initialBorderColor = null;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
const debouncedUpdates = createDebouncedCallback((action) => {
|
|
252
|
+
console.log('debouncedUpdates', action);
|
|
253
|
+
editor.historyPush(action);
|
|
254
|
+
undo = null;
|
|
255
|
+
}, 750);
|
|
256
|
+
|
|
257
|
+
$effect(() => {
|
|
258
|
+
const { activeLayers, activeBackground } = editor;
|
|
259
|
+
if (editor.activeSidebarPopup === 'backgroundColor') {
|
|
260
|
+
if (!activeBackground) {
|
|
261
|
+
editor.activeSidebarPopup = null;
|
|
262
|
+
}
|
|
263
|
+
} else if (editor.activeSidebarPopup === 'borderColor') {
|
|
264
|
+
if (!activeLayers.some((layer) => layer.type === 'image' && layer.borderWidth)) {
|
|
265
|
+
editor.activeSidebarPopup = null;
|
|
266
|
+
}
|
|
267
|
+
} else if (editor.activeSidebarPopup === 'textColor') {
|
|
268
|
+
if (!activeLayers.some((layer) => layer.type === 'html')) {
|
|
269
|
+
editor.activeSidebarPopup = null;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
const generateComplementaryColor = (color: string): string => {
|
|
275
|
+
// Remove the hash at the start if it's there
|
|
276
|
+
const hex = color.replace('#', '');
|
|
277
|
+
|
|
278
|
+
// Convert to RGB
|
|
279
|
+
const r = parseInt(hex.substring(0, 2), 16);
|
|
280
|
+
const g = parseInt(hex.substring(2, 4), 16);
|
|
281
|
+
const b = parseInt(hex.substring(4, 6), 16);
|
|
282
|
+
|
|
283
|
+
// Find the complement
|
|
284
|
+
const compR = (255 - r).toString(16).padStart(2, '0');
|
|
285
|
+
const compG = (255 - g).toString(16).padStart(2, '0');
|
|
286
|
+
const compB = (255 - b).toString(16).padStart(2, '0');
|
|
287
|
+
|
|
288
|
+
// Return the complementary color in hex format
|
|
289
|
+
return `#${compR}${compG}${compB}`;
|
|
290
|
+
};
|
|
291
|
+
|
|
292
|
+
const switchType = (val: string) => {
|
|
293
|
+
if (val === 'gradient') {
|
|
294
|
+
if (!isGradient(currentColor)) {
|
|
295
|
+
const gradient: Gradient = {
|
|
296
|
+
type: 'linear90',
|
|
297
|
+
colors: [currentColor + 'ff', generateComplementaryColor(currentColor) + 'ff'],
|
|
298
|
+
};
|
|
299
|
+
setColor(gradientToString(gradient));
|
|
300
|
+
}
|
|
301
|
+
} else if (val === 'solid') {
|
|
302
|
+
if (isGradient(currentColor)) {
|
|
303
|
+
const gradient = stringToGradient(currentColor);
|
|
304
|
+
setColor(gradient.colors[0].slice(0, 7));
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
};
|
|
308
|
+
</script>
|
|
309
|
+
|
|
310
|
+
<SidebarWrapper name="Color">
|
|
311
|
+
<div class="flex items-center gap-2 py-2">
|
|
312
|
+
<h5 class="text-left text-sm font-bold">Document colors</h5>
|
|
313
|
+
</div>
|
|
314
|
+
<div class="grid grid-cols-6 items-stretch gap-1">
|
|
315
|
+
<div class="relative h-0 w-full" style:padding-top="100%">
|
|
316
|
+
<div class="absolute left-0 top-0 h-full w-full">
|
|
317
|
+
<Popover.Root bind:open>
|
|
318
|
+
<Popover.Trigger
|
|
319
|
+
class={cn(
|
|
320
|
+
'relative h-full w-full overflow-hidden rounded-full after:absolute after:inset-0 after:rounded-full after:transition-shadow',
|
|
321
|
+
open ? 'after:shadow-active' : 'hover:after:shadow-hover',
|
|
322
|
+
)}
|
|
323
|
+
>
|
|
324
|
+
<div
|
|
325
|
+
class="after:shadow-inner-1 relative h-full w-full after:absolute after:inset-0 after:rounded-full"
|
|
326
|
+
>
|
|
327
|
+
<div
|
|
328
|
+
class="h-full w-full rounded-full"
|
|
329
|
+
style:background={`conic-gradient(red, orange, yellow, green, blue, indigo, violet, red)`}
|
|
330
|
+
></div>
|
|
331
|
+
<span class="absolute inset-0 flex h-full w-full items-center justify-center">
|
|
332
|
+
<span
|
|
333
|
+
class="bg-background text-foreground flex h-6 w-6 items-center justify-center rounded-full"
|
|
334
|
+
>
|
|
335
|
+
<PlusIcon />
|
|
336
|
+
</span>
|
|
337
|
+
</span>
|
|
338
|
+
</div>
|
|
339
|
+
</Popover.Trigger>
|
|
340
|
+
<Popover.Content align="start" sideOffset={2} class="w-80 p-4">
|
|
341
|
+
{#if gradientsAllowed}
|
|
342
|
+
<Tabs.Root
|
|
343
|
+
value={isGradient(currentColor) ? 'gradient' : 'solid'}
|
|
344
|
+
class="w-full"
|
|
345
|
+
onValueChange={switchType}
|
|
346
|
+
>
|
|
347
|
+
<Tabs.List class="grid w-full grid-cols-2">
|
|
348
|
+
<Tabs.Trigger value="solid">Solid color</Tabs.Trigger>
|
|
349
|
+
<Tabs.Trigger value="gradient">Gradient</Tabs.Trigger>
|
|
350
|
+
</Tabs.List>
|
|
351
|
+
<Tabs.Content value="solid">
|
|
352
|
+
{#if !isGradient(currentColor)}
|
|
353
|
+
<ColorPicker hex={currentColor} onChange={({ hex }) => setColor(hex, true)} />
|
|
354
|
+
{/if}
|
|
355
|
+
</Tabs.Content>
|
|
356
|
+
<Tabs.Content value="gradient">
|
|
357
|
+
{#if isGradient(currentColor)}
|
|
358
|
+
<ColorSidebarGradientPicker color={currentColor} {setColor} />
|
|
359
|
+
{/if}
|
|
360
|
+
</Tabs.Content>
|
|
361
|
+
</Tabs.Root>
|
|
362
|
+
{:else}
|
|
363
|
+
<ColorPicker hex={currentColor} onChange={({ hex }) => setColor(hex, true)} />
|
|
364
|
+
{/if}
|
|
365
|
+
</Popover.Content>
|
|
366
|
+
</Popover.Root>
|
|
367
|
+
</div>
|
|
368
|
+
</div>
|
|
369
|
+
{#each documentColors as color}
|
|
370
|
+
<div class="relative h-0 w-full" style:padding-top="100%">
|
|
371
|
+
<div class="absolute left-0 top-0 h-full w-full">
|
|
372
|
+
<ColorSidebarColor {color} {currentColor} onclick={() => setColor(color)} />
|
|
373
|
+
</div>
|
|
374
|
+
</div>
|
|
375
|
+
{/each}
|
|
376
|
+
</div>
|
|
377
|
+
<div class="flex items-center gap-2 py-2">
|
|
378
|
+
<!-- <PaletteIcon class="h-5 w-5" /> -->
|
|
379
|
+
<h5 class="text-left text-sm font-bold">Default colors</h5>
|
|
380
|
+
</div>
|
|
381
|
+
<div class="text-muted-foreground text-xs">Solid colors</div>
|
|
382
|
+
<div class="grid grid-cols-6 items-stretch gap-1">
|
|
383
|
+
{#each Object.keys(defaultSolidColors) as color}
|
|
384
|
+
<div class="relative h-0 w-full" style:padding-top="100%">
|
|
385
|
+
<div class="absolute left-0 top-0 h-full w-full">
|
|
386
|
+
<ColorSidebarColor {color} {currentColor} onclick={() => setColor(color)} />
|
|
387
|
+
</div>
|
|
388
|
+
</div>
|
|
389
|
+
{/each}
|
|
390
|
+
</div>
|
|
391
|
+
|
|
392
|
+
{#if gradientsAllowed}
|
|
393
|
+
<div class="text-muted-foreground text-xs">Gradients</div>
|
|
394
|
+
<div class="grid grid-cols-6 items-stretch gap-1">
|
|
395
|
+
{#each defaultGradients as color}
|
|
396
|
+
<div class="relative h-0 w-full" style:padding-top="100%">
|
|
397
|
+
<div class="absolute left-0 top-0 h-full w-full">
|
|
398
|
+
<ColorSidebarColor {color} {currentColor} onclick={() => setColor(color)} />
|
|
399
|
+
</div>
|
|
400
|
+
</div>
|
|
401
|
+
{/each}
|
|
402
|
+
</div>
|
|
403
|
+
{/if}
|
|
404
|
+
</SidebarWrapper>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import CheckIcon from 'lucide-svelte/icons/check';
|
|
3
|
+
import { getPresentationEditorContext } from '../../presentation-editor.svelte.js';
|
|
4
|
+
import { onMount } from 'svelte';
|
|
5
|
+
import { Button, type ButtonProps } from '../../../ui/button/index.js';
|
|
6
|
+
|
|
7
|
+
interface Props extends ButtonProps {
|
|
8
|
+
family: string;
|
|
9
|
+
active?: boolean;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
let { family, active, ...restProps }: Props = $props();
|
|
13
|
+
|
|
14
|
+
const editor = getPresentationEditorContext();
|
|
15
|
+
|
|
16
|
+
onMount(() => {
|
|
17
|
+
editor.loadFont(family);
|
|
18
|
+
});
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<Button variant="ghost" class="justify-between" {...restProps}>
|
|
22
|
+
<div style="font-family: '{family}';">{family}</div>
|
|
23
|
+
{#if active}
|
|
24
|
+
<CheckIcon class="h-6 w-6" />
|
|
25
|
+
{/if}
|
|
26
|
+
</Button>
|
package/dist/components/presentation-editor/sidebar/font-sidebar/font-sidebar-button.svelte.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type ButtonProps } from '../../../ui/button/index.js';
|
|
2
|
+
interface Props extends ButtonProps {
|
|
3
|
+
family: string;
|
|
4
|
+
active?: boolean;
|
|
5
|
+
}
|
|
6
|
+
declare const FontSidebarButton: import("svelte").Component<Props, {}, "">;
|
|
7
|
+
type FontSidebarButton = ReturnType<typeof FontSidebarButton>;
|
|
8
|
+
export default FontSidebarButton;
|