lapikit 0.4.6 → 0.4.8
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/dist/labs/compiler/components.js +2 -1
- package/dist/labs/components/index.d.ts +1 -0
- package/dist/labs/components/index.js +1 -0
- package/dist/labs/components/separator/separator.svelte +133 -0
- package/dist/labs/components/separator/separator.svelte.d.ts +4 -0
- package/dist/labs/components/separator/separator.types.d.ts +14 -0
- package/dist/labs/components/separator/separator.types.js +1 -0
- package/package.json +1 -1
|
@@ -4,3 +4,4 @@ export { default as KitBtn } from './btn/btn.svelte';
|
|
|
4
4
|
export { default as KitIcon } from './icon/icon.svelte';
|
|
5
5
|
export { default as KitAvatar } from './avatar/avatar.svelte';
|
|
6
6
|
export { default as KitSpacer } from './spacer/spacer.svelte';
|
|
7
|
+
export { default as KitSeparator } from './separator/separator.svelte';
|
|
@@ -5,3 +5,4 @@ export { default as KitBtn } from './btn/btn.svelte';
|
|
|
5
5
|
export { default as KitIcon } from './icon/icon.svelte';
|
|
6
6
|
export { default as KitAvatar } from './avatar/avatar.svelte';
|
|
7
7
|
export { default as KitSpacer } from './spacer/spacer.svelte';
|
|
8
|
+
export { default as KitSeparator } from './separator/separator.svelte';
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { useClassName, useStyles } from '../../utils/index.js';
|
|
3
|
+
import { makeComponentProps } from '../../compiler/mapped-code.js';
|
|
4
|
+
import type { SeparatorProps } from './separator.types.js';
|
|
5
|
+
|
|
6
|
+
let {
|
|
7
|
+
ref = $bindable(),
|
|
8
|
+
is = 'hr',
|
|
9
|
+
light = false,
|
|
10
|
+
dark = false,
|
|
11
|
+
inset = false,
|
|
12
|
+
thickness,
|
|
13
|
+
orientation = 'horizontal',
|
|
14
|
+
opacity,
|
|
15
|
+
color,
|
|
16
|
+
class: className = '',
|
|
17
|
+
style: styleAttr = '',
|
|
18
|
+
's-class': sClass,
|
|
19
|
+
's-style': sStyle,
|
|
20
|
+
...rest
|
|
21
|
+
}: SeparatorProps = $props();
|
|
22
|
+
|
|
23
|
+
let safeOrientation = $derived(
|
|
24
|
+
typeof orientation === 'string' && (orientation === 'horizontal' || orientation === 'vertical')
|
|
25
|
+
? orientation
|
|
26
|
+
: 'horizontal'
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
let { classProps, styleProps, restProps } = $derived(
|
|
30
|
+
makeComponentProps(rest as Record<string, unknown>)
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
let componentClass = $derived(
|
|
34
|
+
useClassName({
|
|
35
|
+
baseClass: 'kit-separator',
|
|
36
|
+
className: `${className ?? ''}`.trim(),
|
|
37
|
+
sClass,
|
|
38
|
+
classProps
|
|
39
|
+
})
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
let componentStyle = $derived(
|
|
43
|
+
useStyles({
|
|
44
|
+
styleAttr,
|
|
45
|
+
sStyle,
|
|
46
|
+
styleProps
|
|
47
|
+
})
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
let mergedStyle = $derived(
|
|
51
|
+
[
|
|
52
|
+
componentStyle,
|
|
53
|
+
color ? `--kit-separator-color:${color}` : '',
|
|
54
|
+
opacity !== undefined ? `--kit-separator-opacity:${opacity}` : '',
|
|
55
|
+
thickness !== undefined && safeOrientation === 'horizontal'
|
|
56
|
+
? `--kit-separator-top-width:${typeof thickness === 'number' ? `${thickness}px` : thickness}`
|
|
57
|
+
: '',
|
|
58
|
+
thickness !== undefined && safeOrientation === 'vertical'
|
|
59
|
+
? `--kit-separator-right-width:${typeof thickness === 'number' ? `${thickness}px` : thickness}`
|
|
60
|
+
: ''
|
|
61
|
+
]
|
|
62
|
+
.filter(Boolean)
|
|
63
|
+
.join('; ')
|
|
64
|
+
);
|
|
65
|
+
</script>
|
|
66
|
+
|
|
67
|
+
<svelte:element
|
|
68
|
+
this={is}
|
|
69
|
+
bind:this={ref}
|
|
70
|
+
{...restProps}
|
|
71
|
+
class={componentClass}
|
|
72
|
+
style={mergedStyle}
|
|
73
|
+
role="separator"
|
|
74
|
+
aria-orientation={safeOrientation}
|
|
75
|
+
data-light={light || undefined}
|
|
76
|
+
data-dark={dark || undefined}
|
|
77
|
+
data-inset={inset || undefined}
|
|
78
|
+
data-orientation={safeOrientation}
|
|
79
|
+
/>
|
|
80
|
+
|
|
81
|
+
<style>
|
|
82
|
+
.kit-separator {
|
|
83
|
+
--kit-separator-color: var(--kit-fg);
|
|
84
|
+
--kit-separator-opacity: 0.12;
|
|
85
|
+
--kit-separator-top-width: thin;
|
|
86
|
+
--kit-separator-right-width: thin;
|
|
87
|
+
--kit-separator-vertical-min-size: 1.5rem;
|
|
88
|
+
|
|
89
|
+
display: block;
|
|
90
|
+
flex: 1 1 100%;
|
|
91
|
+
height: 0;
|
|
92
|
+
max-height: 0;
|
|
93
|
+
opacity: var(--kit-separator-opacity);
|
|
94
|
+
border-color: var(--kit-separator-color);
|
|
95
|
+
border-style: solid;
|
|
96
|
+
transition: inherit;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.kit-separator[data-light='true'] {
|
|
100
|
+
--kit-separator-color: color-mix(in oklab, var(--kit-fg), white 40%);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.kit-separator[data-dark='true'] {
|
|
104
|
+
--kit-separator-color: color-mix(in oklab, white, transparent 18%);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.kit-separator[data-inset]:not([data-orientation='vertical']) {
|
|
108
|
+
max-width: calc(100% - 4.5rem);
|
|
109
|
+
margin-inline-start: 4.5rem;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.kit-separator[data-inset][data-orientation='vertical'] {
|
|
113
|
+
margin-block: 0.5rem;
|
|
114
|
+
max-height: calc(100% - 1rem);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.kit-separator:not([data-orientation='vertical']) {
|
|
118
|
+
width: 100%;
|
|
119
|
+
border-width: var(--kit-separator-top-width) 0 0 0;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.kit-separator[data-orientation='vertical'] {
|
|
123
|
+
align-self: stretch;
|
|
124
|
+
display: inline-flex;
|
|
125
|
+
width: 0;
|
|
126
|
+
height: auto;
|
|
127
|
+
min-height: var(--kit-separator-vertical-min-size);
|
|
128
|
+
max-width: 0;
|
|
129
|
+
max-height: none;
|
|
130
|
+
vertical-align: text-bottom;
|
|
131
|
+
border-width: 0 var(--kit-separator-right-width) 0 0;
|
|
132
|
+
}
|
|
133
|
+
</style>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Base } from '../../utils/types/index.js';
|
|
2
|
+
type Orientation = 'horizontal' | 'vertical';
|
|
3
|
+
export interface SeparatorProps extends Base {
|
|
4
|
+
ref?: HTMLElement | null;
|
|
5
|
+
is?: 'div' | 'hr';
|
|
6
|
+
light?: boolean;
|
|
7
|
+
dark?: boolean;
|
|
8
|
+
inset?: boolean;
|
|
9
|
+
thickness?: string | number;
|
|
10
|
+
opacity?: string | number;
|
|
11
|
+
color?: string;
|
|
12
|
+
orientation?: Orientation | Record<string, Orientation>;
|
|
13
|
+
}
|
|
14
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|