@valerius_petrini/corekit-ui 0.1.82 → 0.1.84

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.
@@ -0,0 +1,3 @@
1
+ export declare function portal(node: HTMLElement, target?: string): {
2
+ destroy(): void;
3
+ };
@@ -0,0 +1,9 @@
1
+ export function portal(node, target = 'body') {
2
+ const targetEl = document.querySelector(target);
3
+ targetEl.appendChild(node);
4
+ return {
5
+ destroy() {
6
+ node.remove();
7
+ }
8
+ };
9
+ }
@@ -12,7 +12,7 @@
12
12
  argTypes: {
13
13
  variant: {
14
14
  control: "select",
15
- options: ["bordered", "elevated"],
15
+ options: ["bordered", "elevated", "ghost", "flat"],
16
16
  },
17
17
  size: {
18
18
  control: "select",
@@ -28,8 +28,16 @@
28
28
  });
29
29
  </script>
30
30
 
31
- <Story name="Default" args={{ variant: "bordered", size: "md" }}>
31
+ {#snippet header()}
32
+ <img src="https://upload.wikimedia.org/wikipedia/commons/c/c8/Altja_j%C3%B5gi_Lahemaal.jpg" alt="Card">
33
+ {/snippet}
34
+
35
+ {#snippet footer()}
36
+ <Button href="https://example.com" external class="ml-auto mr-4" color="sub">Learn More</Button>
37
+ <Button href="https://example.com" external>Get Started</Button>
38
+ {/snippet}
39
+
40
+ <Story name="Default" args={{ variant: "bordered", size: "md", footer, header }}>
32
41
  <Text tag="h2" class="text-2xl font-bold mb-4">Customizable Card</Text>
33
42
  <Text class="mb-4">This is a customizable card component. You can add any content here and style it as needed.</Text>
34
- <Button href="https://example.com" target="_blank">Learn More</Button>
35
43
  </Story>
@@ -14,12 +14,14 @@
14
14
  variant = "bordered",
15
15
  size = "md",
16
16
  radius = "md",
17
+ footer = undefined,
18
+ header = undefined,
17
19
  ...restProps
18
20
  }: CardProps = $props();
19
21
 
20
22
  let combinedClass = $derived(twMerge(
21
- "text-main-text rounded-lg transition-all ease-in-out bg-gradient-to-br from-sub-background to-sub-background-accent p-4 w-full",
22
- href && "block hover:bg-sub-background-hover cursor-pointer",
23
+ "text-main-text rounded-lg transition-colors transition-all ease-in-out bg-gradient-to-br from-sub-background to-sub-background-accent p-4 w-full flex flex-col",
24
+ href && "block hover:from-sub-background-hover hover:to-sub-background-hover cursor-pointer hover:border-sub-background-border-hover hover:-translate-y-0.5",
23
25
  cardVariantStyles[variant],
24
26
  getSizeStyleClass(size, "card"),
25
27
  getSizeStyleClass(radius, "radius"),
@@ -43,5 +45,17 @@
43
45
  {...restProps}
44
46
  bind:this={element}
45
47
  >
48
+ {#if header}
49
+ <div class="-mx-4 -mt-4 mb-4 overflow-hidden">
50
+ {@render header()}
51
+ </div>
52
+ {/if}
53
+
46
54
  {@render children?.()}
55
+
56
+ {#if footer}
57
+ <div class="flex items-center justify-between border-t border-sub-background-border mt-4 -mx-4 -mb-4 px-4 py-3 text-sm text-sub-text">
58
+ {@render footer()}
59
+ </div>
60
+ {/if}
47
61
  </svelte:element>
@@ -1,6 +1,7 @@
1
+ import type { Snippet } from "svelte";
1
2
  import type { SizeStyle } from "../../../styles/size";
2
3
  import type { BaseComponentProps } from "../../../types/BaseComponent";
3
- export type CardVariant = "bordered" | "elevated";
4
+ export type CardVariant = "bordered" | "elevated" | "ghost" | "flat";
4
5
  /**
5
6
  * <Corekit UI> A Card component
6
7
  *
@@ -13,4 +14,6 @@ export interface CardProps extends BaseComponentProps {
13
14
  variant?: CardVariant;
14
15
  size?: SizeStyle;
15
16
  radius?: SizeStyle;
17
+ footer?: Snippet;
18
+ header?: Snippet;
16
19
  }
@@ -1,4 +1,6 @@
1
1
  export const cardVariantStyles = {
2
2
  bordered: "border-[1px] border-sub-background-border",
3
- elevated: "shadow-md",
3
+ elevated: "shadow-[0_4px_12px_rgba(0,0,0,0.35)]",
4
+ ghost: "bg-transparent border-transparent",
5
+ flat: "border border-transparent shadow-none",
4
6
  };
@@ -19,6 +19,7 @@
19
19
  import { Input } from "..";
20
20
 
21
21
  import Pipette from "@lucide/svelte/icons/pipette";
22
+ import { portal } from "../../../actions/portal";
22
23
 
23
24
  let {
24
25
  children = undefined,
@@ -89,6 +90,7 @@
89
90
 
90
91
  const { x, y } = await computePosition(element, floatingEl, {
91
92
  placement: "bottom-start",
93
+ strategy: "absolute",
92
94
  middleware: [
93
95
  offset(8),
94
96
  flip(),
@@ -300,8 +302,9 @@
300
302
  {@const hsv = hexToHsv(value || "#000000")}
301
303
  <div
302
304
  bind:this={floatingEl}
305
+ use:portal
303
306
  transition:fly={{ y: -10, duration: 200 }}
304
- class="fixed z-999999 bg-sub-background rounded-md p-4 flex gap-2.5 flex-wrap"
307
+ class="absolute z-999999 bg-sub-background rounded-md p-4 flex gap-2.5 flex-wrap"
305
308
  style="top: {dropdownY}px; left: {dropdownX}px; min-width: {referenceWidth}px; max-width: calc(100vw - 16px);"
306
309
  >
307
310
  <div class="color-canvas relative rounded h-36 cursor-crosshair" style="background-color: hsl({hue}, 100%, 50%);" bind:this={canvasEl}>
@@ -11,6 +11,7 @@
11
11
  import BaseInput from "../helper/BaseInput.svelte";
12
12
  import Text from "../../typography/Text/index.svelte";
13
13
  import { fly } from "svelte/transition";
14
+ import { portal } from "../../../actions/portal";
14
15
 
15
16
  let {
16
17
  children = undefined,
@@ -90,6 +91,7 @@
90
91
 
91
92
  const { x, y } = await computePosition(element!, node, {
92
93
  placement: "bottom-start",
94
+ strategy: "absolute",
93
95
  middleware: [offset(8), flip(), shift({ padding: 8 })]
94
96
  });
95
97
 
@@ -223,7 +225,8 @@
223
225
  {#if isFocused}
224
226
  <div
225
227
  use:initFloating
226
- style="position: fixed; top: {dropdownY}px; left: {dropdownX}px; width: {referenceWidth}px;"
228
+ use:portal
229
+ style="position: absolute; top: {dropdownY}px; left: {dropdownX}px; width: {referenceWidth}px;"
227
230
  style:visibility={ready ? "visible" : "hidden"}
228
231
  transition:fly={{ y: -10, duration: 200 }}
229
232
  class="z-999999 overflow-hidden border border-white/10 bg-sub-background shadow-xl shadow-black/40 {getSizeStyleClass(radius, 'radius')}"
@@ -14,6 +14,7 @@
14
14
 
15
15
  import ChevronUp from "@lucide/svelte/icons/chevron-up";
16
16
  import ChevronDown from "@lucide/svelte/icons/chevron-down";
17
+ import { portal } from "../../../actions/portal.js";
17
18
 
18
19
  let {
19
20
  children = undefined,
@@ -46,6 +47,7 @@
46
47
  async function updatePosition() {
47
48
  const { x: fx, y: fy, placement } = await computePosition(element!, node, {
48
49
  placement: "bottom-start",
50
+ strategy: "absolute",
49
51
  middleware: [offset(4), flip(), shift({ padding: 12 })],
50
52
  });
51
53
  x = fx;
@@ -102,8 +104,9 @@
102
104
  {#if open}
103
105
  <div
104
106
  use:initDropdown
107
+ use:portal
105
108
  role="menu"
106
- style="position: fixed; top: {y}px; left: {x}px;"
109
+ style="position: absolute; top: {y}px; left: {x}px;"
107
110
  class="z-100 shadow-lg"
108
111
  style:visibility={ready ? "visible" : "hidden"}
109
112
  >
@@ -20,6 +20,7 @@
20
20
 
21
21
  const combinedClass = $derived(twMerge(
22
22
  defaultClass,
23
+ (color === "sub") && "bg-transparent",
23
24
  className,
24
25
  active ? activeClass : "",
25
26
  ));
@@ -15,6 +15,7 @@
15
15
  autoUpdate
16
16
 
17
17
  } from "@floating-ui/dom";
18
+ import { portal } from "../../../actions/portal.js";
18
19
 
19
20
  let {
20
21
  text,
@@ -44,6 +45,7 @@
44
45
 
45
46
  const { x: fx, y: fy, placement, middlewareData } = await computePosition(trigger, tooltipEl, {
46
47
  placement: position,
48
+ strategy: "absolute",
47
49
  middleware: [
48
50
  offset(8),
49
51
  flip(),
@@ -156,8 +158,9 @@
156
158
  {#if visible}
157
159
  <div
158
160
  bind:this={tooltipEl}
161
+ use:portal
159
162
  role="tooltip"
160
- style="position: fixed; top: {y}px; left: {x}px;"
163
+ style="position: absolute; top: {y}px; left: {x}px;"
161
164
  class="z-999999 {interactive ? 'pointer-events-auto' : 'pointer-events-none'}"
162
165
  onmouseenter={onTooltipEnter}
163
166
  onmouseleave={onTooltipLeave}
@@ -18,6 +18,7 @@
18
18
  --color-form-background: var(--vpcui-form-background);
19
19
  --color-form-hover: var(--vpcui-form-hover);
20
20
  --color-form-border: var(--vpcui-form-border);
21
+ --color-sub-background-border-hover: var(--vpcui-sub-background-border-hover);
21
22
 
22
23
  --color-primary: var(--vpcui-primary);
23
24
  --color-secondary: var(--vpcui-secondary);
@@ -79,8 +80,9 @@
79
80
  --vpcui-main-background: var(--vpcui-light-50);
80
81
  --vpcui-sub-background: var(--vpcui-light-100);
81
82
  --vpcui-sub-background-hover: var(--vpcui-light-150);
82
- --vpcui-sub-background-border: var(--vpcui-light-150);
83
- --vpcui-sub-background-accent: var(--vpcui-light-150);
83
+ --vpcui-sub-background-border: var(--vpcui-light-200);
84
+ --vpcui-sub-background-accent: var(--vpcui-light-50);
85
+ --vpcui-sub-background-border-hover: var(--vpcui-light-250);
84
86
  --vpcui-main-text: var(--vpcui-light-950);
85
87
  --vpcui-sub-text: var(--vpcui-light-300);
86
88
  --vpcui-contrast-text: var(--vpcui-light-950);
@@ -109,8 +111,9 @@ html.dark {
109
111
  --vpcui-main-background: var(--vpcui-dark-50);
110
112
  --vpcui-sub-background: var(--vpcui-dark-100);
111
113
  --vpcui-sub-background-hover: var(--vpcui-dark-150);
112
- --vpcui-sub-background-border: var(--vpcui-dark-150);
113
- --vpcui-sub-background-accent: var(--vpcui-dark-125);
114
+ --vpcui-sub-background-border: var(--vpcui-dark-200);
115
+ --vpcui-sub-background-accent: var(--vpcui-dark-150);
116
+ --vpcui-sub-background-border-hover: var(--vpcui-dark-250);
114
117
  --vpcui-main-text: var(--vpcui-dark-950);
115
118
  --vpcui-sub-text: var(--vpcui-dark-300);
116
119
  --vpcui-contrast-text: var(--vpcui-dark-50);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@valerius_petrini/corekit-ui",
3
- "version": "0.1.82",
3
+ "version": "0.1.84",
4
4
  "description": "Component Library used across all my projects",
5
5
  "author": "Valerius Petrini Jr.",
6
6
  "license": "MIT",