@valerius_petrini/corekit-ui 0.1.48 → 0.1.49

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.
@@ -10,7 +10,7 @@
10
10
  ...restProps
11
11
  }: CardProps = $props();
12
12
 
13
- let defaultClass = "text-main-text shadow-xl radius-lg transition-colors bg-sub-background hover:bg-sub-background-hover p-4";
13
+ let defaultClass = "text-main-text shadow-xl rounded-lg transition-colors bg-sub-background hover:bg-sub-background-hover p-4";
14
14
  let combinedClass = $derived(twMerge(defaultClass, className));
15
15
  </script>
16
16
 
@@ -7,31 +7,24 @@
7
7
  children = undefined,
8
8
  class: className = "",
9
9
  classTop = "",
10
+ threshold = 10,
10
11
  ...restProps
11
12
  }: NavbarProps = $props();
12
13
 
13
- let defaultClass = "box-border transition-colors duration-300 fixed top-0 left-0 w-full h-14 z-[100] flex items-center bg-main-background/99 border-b-sub-background border-b";
14
+ let defaultClass = "transition-colors duration-300 fixed top-0 left-0 w-full h-14 z-[100] flex items-center bg-main-background/99 border-b-sub-background border-box border-b";
14
15
 
15
16
  let scrollY = $state(0);
17
+ let isAtTop = $derived(scrollY <= threshold);
16
18
 
17
- let combinedClass = $derived(scrollY === 0
18
- ? twMerge(defaultClass, className, classTop)
19
- : twMerge(defaultClass, className));
20
-
21
- function onScroll() {
22
- scrollY = window.scrollY;
23
- }
24
-
25
- onMount(() => {
26
- window.addEventListener('scroll', onScroll);
27
- onScroll();
28
-
29
- return () => {
30
- window.removeEventListener('scroll', onScroll);
31
- };
32
- });
19
+ const combinedClass = $derived(twMerge(
20
+ defaultClass,
21
+ className,
22
+ isAtTop ? classTop : ""
23
+ ));
33
24
  </script>
34
25
 
26
+ <svelte:window bind:scrollY={scrollY}/>
27
+
35
28
  <nav class={combinedClass} {...restProps}>
36
29
  {@render children?.()}
37
30
  </nav>
@@ -1,39 +1,35 @@
1
1
  <script lang="ts">
2
2
  import { twMerge } from "tailwind-merge";
3
3
  import Button from "./Button.svelte";
4
- import { onMount } from "svelte";
5
4
  import type { NavbarElementProps } from "../types/Navbar.js";
5
+ import { page } from "$app/state";
6
6
 
7
7
  let {
8
8
  children = undefined,
9
9
  class: className = "",
10
10
  classTop = "",
11
+ activeClass = "",
11
12
  href = undefined,
13
+ threshold = 10,
12
14
  ...restProps
13
15
  }: NavbarElementProps = $props();
14
16
 
15
- let defaultClass = "navbar-element w-fit h-full px-5 py-0 text-main-text hover:bg-navbar-element-hover-background";
17
+ let defaultClass = "navbar-element w-fit h-full px-5 py-0 text-main-text";
16
18
 
17
19
  let scrollY = $state(0);
18
-
19
- let combinedClass = $derived(scrollY === 0
20
- ? twMerge(defaultClass, className, classTop)
21
- : twMerge(defaultClass, className));
22
-
23
- function onScroll() {
24
- scrollY = window.scrollY;
25
- }
26
-
27
- onMount(() => {
28
- window.addEventListener('scroll', onScroll);
29
- onScroll();
30
-
31
- return () => {
32
- window.removeEventListener('scroll', onScroll);
33
- };
34
- });
20
+ let isAtTop = $derived(scrollY <= threshold);
21
+ let isActive = $derived(page.url.pathname === href);
22
+
23
+ const combinedClass = $derived(twMerge(
24
+ defaultClass,
25
+ className,
26
+ isActive ? activeClass : "",
27
+ isAtTop ? classTop : "",
28
+ ));
35
29
  </script>
36
30
 
37
- <Button radius={0} {href} class={combinedClass} {...restProps}>
31
+ <svelte:window bind:scrollY={scrollY}/>
32
+
33
+ <Button radius={0} {href} color="none" class={combinedClass} {...restProps} aria-current={isActive ? 'page' : undefined}>
38
34
  {@render children?.()}
39
35
  </Button>
@@ -1,4 +1,5 @@
1
1
  <script lang="ts">
2
+ import { sizeStyleParts, textStyle, type SizeStyle } from "../styles/size.js";
2
3
  import type { TextProps } from "../types/Text.js";
3
4
  import { twMerge } from "tailwind-merge";
4
5
 
@@ -6,34 +7,59 @@
6
7
  children = undefined,
7
8
  class: className = "",
8
9
  tag = "p",
10
+ shrink = false,
11
+ size = "none",
9
12
  ...restProps
10
13
  }: TextProps = $props();
11
14
 
12
- const tagStyles = {
13
- "p": "text-base",
14
- "div": "text-base",
15
- "span": "text-base",
16
- "label": "text-sm",
17
- "strong": "text-base font-bold",
18
- "em": "text-base italic",
19
- "small": "text-sm",
20
- "blockquote": "border-l-4 border-gray-500 pl-2 opacity-70",
21
- "pre": "font-mono bg-sub-background px-3 py-2 radius overflow-x-auto whitespace-pre",
22
- "code": "font-mono bg-sub-background px-3 py-2 radius inline-block",
23
- "a": "text-blue-400 hover:text-blue-500 hover:underline",
24
- "li": "text-base list-disc list-inside",
25
- "h1": "text-6xl font-extrabold",
26
- "h2": "text-5xl font-bold",
27
- "h3": "text-4xl font-semibold",
28
- "h4": "text-3xl font-medium",
29
- "h5": "text-2xl font-medium",
30
- "h6": "text-xl font-medium"
15
+ const tagStyles: Record<string, { class: string; size: keyof typeof textStyle }> = {
16
+ "p": { class: "", size: "text-base" },
17
+ "div": { class: "", size: "text-base" },
18
+ "span": { class: "", size: "text-base" },
19
+ "label": { class: "", size: "text-sm" },
20
+ "strong": { class: "font-bold", size: "text-base" },
21
+ "b": { class: "font-bold", size: "text-base" },
22
+ "em": { class: "italic", size: "text-base" },
23
+ "i": { class: "italic", size: "text-base" },
24
+ "u": { class: "underline", size: "text-base" },
25
+ "small": { class: "", size: "text-sm" },
26
+ "blockquote": { class: "border-l-4 border-gray-500 pl-2 opacity-70", size: "text-base" },
27
+ "pre": { class: "font-mono bg-sub-background px-3 py-2 radius overflow-x-auto whitespace-pre", size: "text-base" },
28
+ "code": { class: "font-mono bg-sub-background px-3 py-2 radius inline-block", size: "text-base" },
29
+ "a": { class: "text-blue-400 hover:text-blue-500 hover:underline transition-colors cursor-pointer", size: "text-base" },
30
+ "li": { class: "text-base list-disc list-inside", size: "text-base" },
31
+ "h1": { class: "font-extrabold", size: "text-6xl" },
32
+ "h2": { class: "font-bold", size: "text-5xl" },
33
+ "h3": { class: "font-semibold", size: "text-4xl" },
34
+ "h4": { class: "font-medium", size: "text-3xl" },
35
+ "h5": { class: "font-medium", size: "text-2xl" },
36
+ "h6": { class: "font-medium", size: "text-xl" }
31
37
  };
32
38
 
39
+ function getTextSizeInRem(): string {
40
+ if (size !== "none") {
41
+ const sizeKey = (sizeStyleParts[size as SizeStyle]?.text ?? "text-base") as keyof typeof textStyle;
42
+ return textStyle[sizeKey] ?? textStyle["text-base"];
43
+ }
44
+
45
+ return textStyle[tagStyles[tag]?.size || "text-base"] ?? textStyle["text-base"];
46
+ }
47
+
48
+ let shrinkStyle = $derived(shrink
49
+ ? `font-size: clamp(8px, 12cqi, ${getTextSizeInRem()}); white-space: nowrap; display: block; width: fit-content;`
50
+ : ""
51
+ );
52
+
33
53
  let defaultClass = "text-main-text";
34
- let combinedClass = $derived(twMerge(defaultClass, tagStyles[tag] || "", className));
54
+ let combinedClass = $derived(twMerge(
55
+ defaultClass,
56
+ tagStyles[tag]?.class || "",
57
+ tagStyles[tag]?.size || "",
58
+ sizeStyleParts[size]?.text || "",
59
+ className
60
+ ));
35
61
  </script>
36
62
 
37
- <svelte:element this={tag} class={combinedClass} {...restProps}>
63
+ <svelte:element this={tag} style={shrinkStyle} class={combinedClass} {...restProps}>
38
64
  {@render children?.()}
39
65
  </svelte:element>
package/dist/index.d.ts CHANGED
@@ -9,5 +9,6 @@ export { default as FloatingInput } from "./components/FloatingInput.svelte";
9
9
  export { default as FloatingSelect } from "./components/FloatingSelect.svelte";
10
10
  export { default as Text } from "./components/Text.svelte";
11
11
  export { default as Card } from "./components/Card.svelte";
12
+ export { default as Checkbox } from "./components/Checkbox.svelte";
12
13
  export { fbmBackground } from "./actions/fbm.ts";
13
14
  export type { TypewriterAction, DisplaySegment } from "./types/Typewriter.d.ts";
package/dist/index.js CHANGED
@@ -9,4 +9,5 @@ export { default as FloatingInput } from "./components/FloatingInput.svelte";
9
9
  export { default as FloatingSelect } from "./components/FloatingSelect.svelte";
10
10
  export { default as Text } from "./components/Text.svelte";
11
11
  export { default as Card } from "./components/Card.svelte";
12
+ export { default as Checkbox } from "./components/Checkbox.svelte";
12
13
  export { fbmBackground } from "./actions/fbm.js";
@@ -1,3 +1,15 @@
1
- export type SizeStyle = "xs" | "sm" | "md" | "lg" | "xl" | "2xl" | "3xl" | "4xl" | "full" | "none" | number;
2
- export type SizeStyleType = "button" | "buttonIcon" | "radius";
1
+ export type SizeStyle = "xs" | "sm" | "md" | "lg" | "xl" | "2xl" | "3xl" | "4xl" | "5xl" | "6xl" | "full" | "none" | number;
2
+ export type SizeStyleType = "button" | "buttonIcon" | "radius" | "text";
3
3
  export declare const sizeStyleParts: Record<SizeStyle, Record<SizeStyleType, string>>;
4
+ export declare const textStyle: {
5
+ "text-xs": string;
6
+ "text-sm": string;
7
+ "text-base": string;
8
+ "text-lg": string;
9
+ "text-xl": string;
10
+ "text-2xl": string;
11
+ "text-3xl": string;
12
+ "text-4xl": string;
13
+ "text-5xl": string;
14
+ "text-6xl": string;
15
+ };
@@ -2,56 +2,91 @@ export const sizeStyleParts = {
2
2
  xs: {
3
3
  button: "text-xs h-4 px-1 py-0.5",
4
4
  buttonIcon: "text-xs h-4 w-4 p-0.5",
5
- radius: "rounded-xs"
5
+ radius: "rounded-xs",
6
+ text: "text-xs"
6
7
  },
7
8
  sm: {
8
9
  button: "text-sm h-6 px-2 py-1",
9
10
  buttonIcon: "text-sm h-6 w-6 p-1",
10
- radius: "rounded-sm"
11
+ radius: "rounded-sm",
12
+ text: "text-sm"
11
13
  },
12
14
  md: {
13
15
  button: "text-base h-8 px-3 py-1.5",
14
16
  buttonIcon: "text-base h-8 w-8 p-1.5",
15
- radius: "rounded-md"
17
+ radius: "rounded-md",
18
+ text: "text-base"
16
19
  },
17
20
  lg: {
18
21
  button: "text-lg h-10 px-4 py-2",
19
22
  buttonIcon: "text-lg h-10 w-10 p-2",
20
- radius: "rounded-lg"
23
+ radius: "rounded-lg",
24
+ text: "text-lg"
21
25
  },
22
26
  xl: {
23
27
  button: "text-xl h-12 px-5 py-2.5",
24
28
  buttonIcon: "text-xl h-12 w-12 p-2.5",
25
- radius: "rounded-xl"
29
+ radius: "rounded-xl",
30
+ text: "text-xl"
26
31
  },
27
32
  "2xl": {
28
33
  button: "text-2xl h-14 px-6 py-3",
29
34
  buttonIcon: "text-2xl h-14 w-14 p-3",
30
- radius: "rounded-2xl"
35
+ radius: "rounded-2xl",
36
+ text: "text-2xl"
31
37
  },
32
38
  "3xl": {
33
39
  button: "text-3xl h-16 px-7 py-3.5",
34
40
  buttonIcon: "text-3xl h-16 w-16 p-3.5",
35
- radius: "rounded-3xl"
41
+ radius: "rounded-3xl",
42
+ text: "text-3xl"
36
43
  },
37
44
  "4xl": {
38
45
  button: "text-4xl h-18 px-8 py-4",
39
46
  buttonIcon: "text-4xl h-18 w-18 p-4",
40
- radius: "rounded-4xl"
47
+ radius: "rounded-4xl",
48
+ text: "text-4xl"
49
+ },
50
+ "5xl": {
51
+ button: "text-5xl h-20 px-9 py-4.5",
52
+ buttonIcon: "text-5xl h-20 w-20 p-4.5",
53
+ radius: "rounded-[2.5rem]",
54
+ text: "text-5xl"
55
+ },
56
+ "6xl": {
57
+ button: "text-6xl h-24 px-10 py-5",
58
+ buttonIcon: "text-6xl h-24 w-24 p-5",
59
+ radius: "rounded-[3rem]",
60
+ text: "text-6xl"
41
61
  },
42
62
  full: {
43
63
  button: "w-full text-base h-8 px-3 py-1",
44
64
  buttonIcon: "w-full aspect-square text-base p-1",
45
- radius: "rounded-full"
65
+ radius: "rounded-full",
66
+ text: "w-full text-base"
46
67
  },
47
68
  none: {
48
- button: "",
49
- buttonIcon: "",
50
- radius: "rounded-none"
69
+ button: "p-0 h-auto text-base",
70
+ buttonIcon: "p-0 h-auto w-auto text-base",
71
+ radius: "rounded-none",
72
+ text: ""
51
73
  },
52
74
  0: {
53
75
  button: "",
54
76
  buttonIcon: "",
55
- radius: "rounded-none"
77
+ radius: "rounded-none",
78
+ text: ""
56
79
  }
57
80
  };
81
+ export const textStyle = {
82
+ "text-xs": "0.75rem",
83
+ "text-sm": "0.875rem",
84
+ "text-base": "1rem",
85
+ "text-lg": "1.125rem",
86
+ "text-xl": "1.25rem",
87
+ "text-2xl": "1.5rem",
88
+ "text-3xl": "1.875rem",
89
+ "text-4xl": "2.25rem",
90
+ "text-5xl": "3rem",
91
+ "text-6xl": "3.75rem"
92
+ };
@@ -2,6 +2,7 @@ export interface NavbarProps {
2
2
  children?: any;
3
3
  class?: string;
4
4
  classTop?: string;
5
+ threshold?: number;
5
6
  [key: string]: any;
6
7
  };
7
8
 
@@ -9,6 +10,8 @@ export interface NavbarElementProps {
9
10
  children?: any;
10
11
  class?: string;
11
12
  classTop?: string;
13
+ activeClass?: string;
12
14
  href?: string;
15
+ threshold?: number;
13
16
  [key: string]: any;
14
17
  }
@@ -1,8 +1,10 @@
1
- type TextTagOptions = "p" | "div" | "span" | "label" | "strong" | "em" | "small" | "blockquote" | "pre" | "code" | "a" | "li" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6";
1
+ type TextTagOptions = "p" | "div" | "span" | "label" | "strong" | "em" | "b" | "i" | "u" | "small" | "blockquote" | "pre" | "code" | "a" | "li" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6";
2
2
 
3
3
  export interface TextProps {
4
4
  children?: any;
5
5
  class?: string;
6
6
  tag?: TextTagOptions;
7
+ shrink?: boolean;
8
+ size?: SizeStyle;
7
9
  [key: string]: any;
8
10
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@valerius_petrini/corekit-ui",
3
- "version": "0.1.48",
3
+ "version": "0.1.49",
4
4
  "description": "Component Library used across all my projects",
5
5
  "author": "Valerius Petrini Jr.",
6
6
  "license": "MIT",