-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathCustomProperty.svelte
More file actions
50 lines (45 loc) · 1.11 KB
/
Copy pathCustomProperty.svelte
File metadata and controls
50 lines (45 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<script lang="ts">
import { serialize_path } from './utils.js';
import type { CustomPropertyProps } from './types.js';
let { path, tag = 'div', class: css_class, children, style, ...rest }: CustomPropertyProps = $props();
let path_str = $derived(serialize_path(path));
</script>
<svelte:element
this={tag}
class={css_class}
data-type="property"
data-path={path_str}
style="anchor-name: --{path_str};{style ? ` ${style}` : ''}"
{...rest}
>
<div class="property-selectable">
<div class="svedit-selectable"><br /></div>
</div>
{@render children()}
</svelte:element>
<style>
[data-type='property'] {
position: relative;
}
.property-selectable {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
z-index: 1;
outline: none;
/* Position the hidden selectable element at the bottom so the
browser's native scroll-to-caret ensures the full property
is visible, not just the top edge. */
display: none;
align-items: flex-end;
justify-content: center;
}
:global(.svedit.editable) .property-selectable {
display: flex;
}
.svedit-selectable {
caret-color: transparent;
}
</style>