@c-rex/components 0.0.9 → 0.0.10

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.
Files changed (134) hide show
  1. package/package.json +28 -46
  2. package/src/autocomplete.tsx +113 -0
  3. package/src/blog-card.tsx +87 -0
  4. package/src/blur-image.tsx +23 -0
  5. package/src/breadcrumb.tsx +81 -0
  6. package/src/empty.tsx +13 -0
  7. package/src/navbar.tsx +66 -0
  8. package/src/providers/search-state-wrapper.tsx +21 -0
  9. package/src/result-list.tsx +16 -0
  10. package/src/result-view/blog-view.stories.tsx +58 -0
  11. package/src/result-view/blog.tsx +38 -0
  12. package/src/result-view/table-view.stories.tsx +55 -0
  13. package/src/result-view/table.tsx +65 -0
  14. package/src/sidebar.tsx +76 -0
  15. package/src/stories/blog-card.stories.tsx +46 -0
  16. package/src/stories/blur-image.stories.tsx +51 -0
  17. package/src/stories/breadcrumb.stories.tsx +52 -0
  18. package/src/stories/empty.stories.tsx +14 -0
  19. package/src/stories/navbar.stories.tsx +16 -0
  20. package/src/stories/sidebar.stories.tsx +94 -0
  21. package/dist/autocomplete.cjs.js +0 -215
  22. package/dist/autocomplete.cjs.js.map +0 -1
  23. package/dist/autocomplete.d.cts +0 -10
  24. package/dist/autocomplete.d.ts +0 -10
  25. package/dist/autocomplete.esm.js +0 -154
  26. package/dist/autocomplete.esm.js.map +0 -1
  27. package/dist/blog-card.cjs.js +0 -265
  28. package/dist/blog-card.cjs.js.map +0 -1
  29. package/dist/blog-card.d.cts +0 -19
  30. package/dist/blog-card.d.ts +0 -19
  31. package/dist/blog-card.esm.js +0 -192
  32. package/dist/blog-card.esm.js.map +0 -1
  33. package/dist/blur-image.cjs.js +0 -198
  34. package/dist/blur-image.cjs.js.map +0 -1
  35. package/dist/blur-image.d.cts +0 -7
  36. package/dist/blur-image.d.ts +0 -7
  37. package/dist/blur-image.esm.js +0 -125
  38. package/dist/blur-image.esm.js.map +0 -1
  39. package/dist/breadcrumb.cjs.js +0 -159
  40. package/dist/breadcrumb.cjs.js.map +0 -1
  41. package/dist/breadcrumb.d.cts +0 -10
  42. package/dist/breadcrumb.d.ts +0 -10
  43. package/dist/breadcrumb.esm.js +0 -98
  44. package/dist/breadcrumb.esm.js.map +0 -1
  45. package/dist/empty.cjs.js +0 -79
  46. package/dist/empty.cjs.js.map +0 -1
  47. package/dist/empty.d.cts +0 -5
  48. package/dist/empty.d.ts +0 -5
  49. package/dist/empty.esm.js +0 -18
  50. package/dist/empty.esm.js.map +0 -1
  51. package/dist/navbar.cjs.js +0 -134
  52. package/dist/navbar.cjs.js.map +0 -1
  53. package/dist/navbar.d.cts +0 -9
  54. package/dist/navbar.d.ts +0 -9
  55. package/dist/navbar.esm.js +0 -61
  56. package/dist/navbar.esm.js.map +0 -1
  57. package/dist/providers/search-state-wrapper.cjs.js +0 -113
  58. package/dist/providers/search-state-wrapper.cjs.js.map +0 -1
  59. package/dist/providers/search-state-wrapper.d.cts +0 -14
  60. package/dist/providers/search-state-wrapper.d.ts +0 -14
  61. package/dist/providers/search-state-wrapper.esm.js +0 -51
  62. package/dist/providers/search-state-wrapper.esm.js.map +0 -1
  63. package/dist/result-list.cjs.js +0 -321
  64. package/dist/result-list.cjs.js.map +0 -1
  65. package/dist/result-list.d.cts +0 -9
  66. package/dist/result-list.d.ts +0 -9
  67. package/dist/result-list.esm.js +0 -247
  68. package/dist/result-list.esm.js.map +0 -1
  69. package/dist/result-view/blog-view.stories.cjs.js +0 -372
  70. package/dist/result-view/blog-view.stories.cjs.js.map +0 -1
  71. package/dist/result-view/blog-view.stories.d.cts +0 -11
  72. package/dist/result-view/blog-view.stories.d.ts +0 -11
  73. package/dist/result-view/blog-view.stories.esm.js +0 -295
  74. package/dist/result-view/blog-view.stories.esm.js.map +0 -1
  75. package/dist/result-view/blog.cjs.js +0 -290
  76. package/dist/result-view/blog.cjs.js.map +0 -1
  77. package/dist/result-view/blog.d.cts +0 -9
  78. package/dist/result-view/blog.d.ts +0 -9
  79. package/dist/result-view/blog.esm.js +0 -220
  80. package/dist/result-view/blog.esm.js.map +0 -1
  81. package/dist/result-view/table-view.stories.cjs.js +0 -196
  82. package/dist/result-view/table-view.stories.cjs.js.map +0 -1
  83. package/dist/result-view/table-view.stories.d.cts +0 -11
  84. package/dist/result-view/table-view.stories.d.ts +0 -11
  85. package/dist/result-view/table-view.stories.esm.js +0 -131
  86. package/dist/result-view/table-view.stories.esm.js.map +0 -1
  87. package/dist/result-view/table.cjs.js +0 -116
  88. package/dist/result-view/table.cjs.js.map +0 -1
  89. package/dist/result-view/table.d.cts +0 -9
  90. package/dist/result-view/table.d.ts +0 -9
  91. package/dist/result-view/table.esm.js +0 -59
  92. package/dist/result-view/table.esm.js.map +0 -1
  93. package/dist/sidebar.cjs.js +0 -225
  94. package/dist/sidebar.cjs.js.map +0 -1
  95. package/dist/sidebar.d.cts +0 -12
  96. package/dist/sidebar.d.ts +0 -12
  97. package/dist/sidebar.esm.js +0 -164
  98. package/dist/sidebar.esm.js.map +0 -1
  99. package/dist/stories/blog-card.stories.cjs.js +0 -323
  100. package/dist/stories/blog-card.stories.cjs.js.map +0 -1
  101. package/dist/stories/blog-card.stories.d.cts +0 -9
  102. package/dist/stories/blog-card.stories.d.ts +0 -9
  103. package/dist/stories/blog-card.stories.esm.js +0 -242
  104. package/dist/stories/blog-card.stories.esm.js.map +0 -1
  105. package/dist/stories/blur-image.stories.cjs.js +0 -265
  106. package/dist/stories/blur-image.stories.cjs.js.map +0 -1
  107. package/dist/stories/blur-image.stories.d.cts +0 -37
  108. package/dist/stories/blur-image.stories.d.ts +0 -37
  109. package/dist/stories/blur-image.stories.esm.js +0 -180
  110. package/dist/stories/blur-image.stories.esm.js.map +0 -1
  111. package/dist/stories/breadcrumb.stories.cjs.js +0 -214
  112. package/dist/stories/breadcrumb.stories.cjs.js.map +0 -1
  113. package/dist/stories/breadcrumb.stories.d.cts +0 -9
  114. package/dist/stories/breadcrumb.stories.d.ts +0 -9
  115. package/dist/stories/breadcrumb.stories.esm.js +0 -145
  116. package/dist/stories/breadcrumb.stories.esm.js.map +0 -1
  117. package/dist/stories/empty.stories.cjs.js +0 -93
  118. package/dist/stories/empty.stories.cjs.js.map +0 -1
  119. package/dist/stories/empty.stories.d.cts +0 -13
  120. package/dist/stories/empty.stories.d.ts +0 -13
  121. package/dist/stories/empty.stories.esm.js +0 -28
  122. package/dist/stories/empty.stories.esm.js.map +0 -1
  123. package/dist/stories/navbar.stories.cjs.js +0 -151
  124. package/dist/stories/navbar.stories.cjs.js.map +0 -1
  125. package/dist/stories/navbar.stories.d.cts +0 -8
  126. package/dist/stories/navbar.stories.d.ts +0 -8
  127. package/dist/stories/navbar.stories.esm.js +0 -74
  128. package/dist/stories/navbar.stories.esm.js.map +0 -1
  129. package/dist/stories/sidebar.stories.cjs.js +0 -327
  130. package/dist/stories/sidebar.stories.cjs.js.map +0 -1
  131. package/dist/stories/sidebar.stories.d.cts +0 -30
  132. package/dist/stories/sidebar.stories.d.ts +0 -30
  133. package/dist/stories/sidebar.stories.esm.js +0 -258
  134. package/dist/stories/sidebar.stories.esm.js.map +0 -1
package/package.json CHANGED
@@ -1,74 +1,57 @@
1
1
  {
2
2
  "name": "@c-rex/components",
3
- "version": "0.0.9",
4
- "type": "module",
3
+ "version": "0.0.10",
5
4
  "files": [
6
- "dist"
5
+ "src"
7
6
  ],
8
- "publishConfig": {
9
- "access": "public"
10
- },
7
+ "sideEffects": false,
11
8
  "exports": {
12
9
  "./autocomplete": {
13
- "types": "./dist/autocomplete.d.ts",
14
- "import": "./dist/autocomplete.esm.js",
15
- "require": "./dist/autocomplete.cjs.js"
10
+ "types": "./src/autocomplete.tsx",
11
+ "import": "./src/autocomplete.tsx"
16
12
  },
17
13
  "./blog-card": {
18
- "types": "./dist/blog-card.d.ts",
19
- "import": "./dist/blog-card.esm.js",
20
- "require": "./dist/blog-card.cjs.js"
14
+ "types": "./src/blog-card.tsx",
15
+ "import": "./src/blog-card.tsx"
21
16
  },
22
17
  "./blur-image": {
23
- "types": "./dist/blur-image.d.ts",
24
- "import": "./dist/blur-image.esm.js",
25
- "require": "./dist/blur-image.cjs.js"
18
+ "types": "./src/blur-image.tsx",
19
+ "import": "./src/blur-image.tsx"
26
20
  },
27
21
  "./breadcrumb": {
28
- "types": "./dist/breadcrumb.d.ts",
29
- "import": "./dist/breadcrumb.esm.js",
30
- "require": "./dist/breadcrumb.cjs.js"
22
+ "types": "./src/breadcrumb.tsx",
23
+ "import": "./src/breadcrumb.tsx"
31
24
  },
32
25
  "./empty": {
33
- "types": "./dist/empty.d.ts",
34
- "import": "./dist/empty.esm.js",
35
- "require": "./dist/empty.cjs.js"
26
+ "types": "./src/empty.tsx",
27
+ "import": "./src/empty.tsx"
36
28
  },
37
29
  "./navbar": {
38
- "types": "./dist/navbar.d.ts",
39
- "import": "./dist/navbar.esm.js",
40
- "require": "./dist/navbar.cjs.js"
30
+ "types": "./src/navbar.tsx",
31
+ "import": "./src/navbar.tsx"
41
32
  },
42
- "./search-wrapper": {
43
- "types": "./dist/providers/search-state-wrapper.d.ts",
44
- "import": "./dist/providers/search-state-wrapper.esm.js",
45
- "require": "./dist/providers/search-state-wrapper.cjs.js"
33
+ "./providers/search-state-wrapper": {
34
+ "types": "./src/providers/search-state-wrapper.tsx",
35
+ "import": "./src/providers/search-state-wrapper.tsx"
46
36
  },
47
37
  "./result-list": {
48
- "types": "./dist/result-list.d.ts",
49
- "import": "./dist/result-list.esm.js",
50
- "require": "./dist/result-list.cjs.js"
38
+ "types": "./src/result-list.tsx",
39
+ "import": "./src/result-list.tsx"
51
40
  },
52
41
  "./result-view/blog": {
53
- "types": "./dist/result-view/blog.d.ts",
54
- "import": "./dist/result-view/blog.esm.js",
55
- "require": "./dist/result-view/blog.cjs.js"
42
+ "types": "./src/result-view/blog.tsx",
43
+ "import": "./src/result-view/blog.tsx"
56
44
  },
57
45
  "./result-view/table": {
58
- "types": "./dist/result-view/table.d.ts",
59
- "import": "./dist/result-view/table.esm.js",
60
- "require": "./dist/result-view/table.cjs.js"
46
+ "types": "./src/result-view/table.tsx",
47
+ "import": "./src/result-view/table.tsx"
61
48
  },
62
49
  "./sidebar": {
63
- "types": "./dist/sidebar.d.ts",
64
- "import": "./dist/sidebar.esm.js",
65
- "require": "./dist/sidebar.cjs.js"
66
- },
67
- "./package.json": "./package.json"
50
+ "types": "./src/sidebar.tsx",
51
+ "import": "./src/sidebar.tsx"
52
+ }
68
53
  },
69
54
  "scripts": {
70
- "dev": "tsup --watch",
71
- "build": "tsup",
72
55
  "storybook": "storybook dev -p 6006",
73
56
  "build-storybook": "storybook build"
74
57
  },
@@ -82,7 +65,6 @@
82
65
  "@storybook/nextjs": "^8.6.12",
83
66
  "@storybook/react": "^8.6.12",
84
67
  "@storybook/test": "^8.6.12",
85
- "@swc/core": "^1.11.21",
86
68
  "@turbo/gen": "^2.4.4",
87
69
  "@types/node": "^22.13.10",
88
70
  "@types/react": "19.0.10",
@@ -97,12 +79,12 @@
97
79
  "typescript": "latest"
98
80
  },
99
81
  "dependencies": {
100
- "@c-rex/config": "*",
101
82
  "@c-rex/contexts": "*",
102
83
  "@c-rex/interfaces": "*",
103
84
  "@c-rex/services": "*",
104
85
  "@c-rex/ui": "*",
105
86
  "@c-rex/utils": "*",
87
+ "@c-rex/config": "*",
106
88
  "next": "^14",
107
89
  "react": "^18",
108
90
  "react-dom": "^18",
@@ -0,0 +1,113 @@
1
+ import { Command as CommandPrimitive } from "cmdk";
2
+ import { Check } from "lucide-react";
3
+ import { useEffect, useState } from "react";
4
+ import { Input } from "@c-rex/ui/input";
5
+ import {
6
+ Command,
7
+ CommandEmpty,
8
+ CommandGroup,
9
+ CommandItem,
10
+ CommandList
11
+ } from "@c-rex/ui/command";
12
+ import {
13
+ Popover,
14
+ PopoverAnchor,
15
+ PopoverContent
16
+ } from "@c-rex/ui/popover";
17
+
18
+ type Props = {
19
+ initialValue: string;
20
+ onSelect: (value: string) => void;
21
+ onSearch: (value: string) => Promise<string[]>;
22
+ };
23
+
24
+ export const AutoComplete = ({
25
+ initialValue,
26
+ onSearch,
27
+ onSelect,
28
+ }: Props) => {
29
+ const [query, setQuery] = useState(initialValue);
30
+ const [suggestions, setSuggestions] = useState<string[]>([]);
31
+
32
+ const [open, setOpen] = useState(false);
33
+
34
+ useEffect(() => {
35
+ const debounceFetch = setTimeout(() => {
36
+ if (query) {
37
+ onSearch(query).then(setSuggestions);
38
+ } else {
39
+ setSuggestions([]);
40
+ }
41
+ }, 300);
42
+
43
+ return () => clearTimeout(debounceFetch);
44
+ }, [onSearch, query]);
45
+
46
+ return (
47
+ <div className="flex items-center">
48
+ <Popover open={open} onOpenChange={setOpen}>
49
+ <Command shouldFilter={false}>
50
+ <PopoverAnchor asChild>
51
+ <CommandPrimitive.Input
52
+ asChild
53
+ value={query}
54
+ onValueChange={setQuery}
55
+ onKeyDown={(e) => setOpen(e.key !== "Escape")}
56
+ onMouseDown={() => setOpen(false)}
57
+ onFocus={() => setOpen(true)}
58
+ >
59
+ <Input />
60
+ </CommandPrimitive.Input>
61
+ </PopoverAnchor>
62
+
63
+ {!open && <CommandList aria-hidden="true" className="hidden" />}
64
+
65
+ <PopoverContent
66
+ asChild
67
+ onOpenAutoFocus={(e) => e.preventDefault()}
68
+ onInteractOutside={(e) => {
69
+ if (
70
+ e.target instanceof Element &&
71
+ e.target.hasAttribute("cmdk-input")
72
+ ) {
73
+ e.preventDefault();
74
+ }
75
+ }}
76
+ className="w-[--radix-popover-trigger-width] p-0"
77
+ >
78
+ <CommandList>
79
+ {/*isLoading && (
80
+ <CommandPrimitive.Loading>
81
+ <div className="p-1">
82
+ <Skeleton className="h-6 w-full" />
83
+ </div>
84
+ </CommandPrimitive.Loading>
85
+ )*/}
86
+
87
+ {suggestions.length > 0 ? (
88
+ <CommandGroup>
89
+ {suggestions.map((option) => (
90
+ <CommandItem
91
+ key={option}
92
+ value={option}
93
+ onMouseDown={(e) => e.preventDefault()}
94
+ onSelect={(inputValue) => {
95
+ setOpen(false);
96
+ onSelect(inputValue ?? "");
97
+ }}
98
+ >
99
+ <Check className="mr-2 h-4 w-4 opacity-0" />
100
+ {option}
101
+ </CommandItem>
102
+ ))}
103
+ </CommandGroup>
104
+ ) : (
105
+ <CommandEmpty>No suggestions.</CommandEmpty>
106
+ )}
107
+ </CommandList>
108
+ </PopoverContent>
109
+ </Command>
110
+ </Popover>
111
+ </div>
112
+ );
113
+ }
@@ -0,0 +1,87 @@
1
+ import Link from "next/link";
2
+ import { cn } from "@c-rex/utils";
3
+ import { BlurImage } from "./blur-image";
4
+
5
+ //import Author from "./author";
6
+
7
+ interface BlogCardProp {
8
+ data: {
9
+ title: string;
10
+ blurDataURL: string;
11
+ image: string;
12
+ description: string;
13
+ authors: string;
14
+ _id: string;
15
+ date: string;
16
+ slug: string;
17
+ };
18
+ priority?: boolean;
19
+ horizontal?: boolean;
20
+ }
21
+
22
+ export const BlogCard = ({
23
+ data,
24
+ priority,
25
+ horizontal = false,
26
+ }: BlogCardProp) => {
27
+ return (
28
+ <article
29
+ className={cn(
30
+ "group relative",
31
+ horizontal
32
+ ? "grid grid-cols-1 gap-3 md:grid-cols-2 md:gap-6"
33
+ : "flex flex-col space-y-2",
34
+ )}
35
+ >
36
+ {data.image && (
37
+ <div className="w-full overflow-hidden rounded-xl border">
38
+ <BlurImage
39
+ alt={data.title}
40
+ blurDataURL={data.blurDataURL}
41
+ className={cn(
42
+ "size-full object-cover object-center",
43
+ horizontal ? "lg:h-72" : null,
44
+ )}
45
+ width={800}
46
+ height={400}
47
+ priority={priority}
48
+ placeholder="blur"
49
+ src={data.image}
50
+ sizes="(max-width: 768px) 750px, 600px"
51
+ />
52
+ </div>
53
+ )}
54
+ <div
55
+ className={cn(
56
+ "flex flex-1 flex-col",
57
+ horizontal ? "justify-center" : "justify-between",
58
+ )}
59
+ >
60
+ <div className="w-full">
61
+ <h2 className="my-1.5 line-clamp-2 font-heading text-2xl">
62
+ {data.title}
63
+ </h2>
64
+ {data.description && (
65
+ <p className="line-clamp-2 text-muted-foreground">
66
+ {data.description}
67
+ </p>
68
+ )}
69
+ </div>
70
+ <div className="mt-4 flex items-center space-x-3">
71
+ <div className="flex items-center -space-x-2">
72
+ {data.authors && (
73
+ <p className="text-sm text-muted-foreground">{data.authors}</p>
74
+ )}
75
+ </div>
76
+
77
+ {data.date && (
78
+ <p className="text-sm text-muted-foreground">{data.date}</p>
79
+ )}
80
+ </div>
81
+ </div>
82
+ <Link href={data.slug} className="absolute inset-0" target="_blank">
83
+ <span className="sr-only">View Article</span>
84
+ </Link>
85
+ </article>
86
+ );
87
+ };
@@ -0,0 +1,23 @@
1
+ "use client";
2
+
3
+ import { useState } from "react";
4
+ import type { ComponentProps } from "react";
5
+ import Image from "next/image";
6
+ import { cn } from "@c-rex/utils";
7
+
8
+ export const BlurImage = (props: ComponentProps<typeof Image>) => {
9
+ const [isLoading, setLoading] = useState(true);
10
+
11
+ return (
12
+ <Image
13
+ {...props}
14
+ alt={props.alt}
15
+ className={cn(
16
+ props.className,
17
+ "duration-500 ease-in-out",
18
+ isLoading ? "blur-sm" : "blur-0",
19
+ )}
20
+ onLoad={() => setLoading(false)}
21
+ />
22
+ );
23
+ }
@@ -0,0 +1,81 @@
1
+ import { FC, ReactNode } from "react";
2
+ import {
3
+ Breadcrumb as BreadcrumbComponent,
4
+ BreadcrumbItem,
5
+ BreadcrumbLink,
6
+ BreadcrumbList,
7
+ BreadcrumbPage,
8
+ BreadcrumbSeparator
9
+ } from "@c-rex/ui/breadcrumb";
10
+ import { Skeleton } from "@c-rex/ui/skeleton";
11
+ import { TreeOfContent } from "@c-rex/interfaces";
12
+
13
+ interface BreadcrumbProps {
14
+ items: TreeOfContent[];
15
+ loading?: boolean;
16
+ }
17
+
18
+ export const Breadcrumb: FC<BreadcrumbProps> = ({ items, loading }) => {
19
+ if (!items) {
20
+ return null;
21
+ }
22
+
23
+ if (loading) {
24
+ return (
25
+ <BreadcrumbComponent>
26
+ <BreadcrumbList>
27
+ <BreadcrumbItem>
28
+ <BreadcrumbPage>Home</BreadcrumbPage>
29
+ </BreadcrumbItem>
30
+ <BreadcrumbSeparator />
31
+ <BreadcrumbItem>
32
+ <Skeleton className="w-40 h-6" />
33
+ </BreadcrumbItem>
34
+ <BreadcrumbSeparator />
35
+ <BreadcrumbItem>
36
+ <Skeleton className="w-40 h-6" />
37
+ </BreadcrumbItem>
38
+ </BreadcrumbList>
39
+ </BreadcrumbComponent>
40
+ );
41
+ }
42
+
43
+ const homeItem: TreeOfContent = {
44
+ link: "/",
45
+ label: "Home",
46
+ id: "home",
47
+ active: false,
48
+ children: [],
49
+ };
50
+
51
+ const newItemList: TreeOfContent[] = [homeItem, ...items];
52
+
53
+ const renderLink = (showLink: boolean, item: TreeOfContent): ReactNode => {
54
+ if (showLink) {
55
+ return <BreadcrumbLink href={item.link}>{item.label}</BreadcrumbLink>;
56
+ }
57
+
58
+ return <BreadcrumbPage>{item.label}</BreadcrumbPage>;
59
+ };
60
+
61
+ return (
62
+ <BreadcrumbComponent>
63
+ <BreadcrumbList>
64
+ {newItemList.map((item, index) => {
65
+ const isLast = index === newItemList.length - 1;
66
+
67
+ return (
68
+ <>
69
+ <BreadcrumbItem key={`${item.label}-item`}>
70
+ {renderLink(!isLast, item)}
71
+ </BreadcrumbItem>
72
+ {!isLast && (
73
+ <BreadcrumbSeparator key={`${item.label}-separator`} />
74
+ )}
75
+ </>
76
+ );
77
+ })}
78
+ </BreadcrumbList>
79
+ </BreadcrumbComponent>
80
+ );
81
+ };
package/src/empty.tsx ADDED
@@ -0,0 +1,13 @@
1
+ import { FC } from "react";
2
+ import { Alert, AlertDescription, AlertTitle } from "@c-rex/ui/alert";
3
+
4
+ export const Empty: FC = () => {
5
+ return (
6
+ <Alert className="my-2">
7
+ <AlertTitle>No results</AlertTitle>
8
+ <AlertDescription>
9
+ No data available. Please try adjusting your search or filter criteria.
10
+ </AlertDescription>
11
+ </Alert>
12
+ );
13
+ };
package/src/navbar.tsx ADDED
@@ -0,0 +1,66 @@
1
+ import { FC } from "react";
2
+
3
+ import Link from "next/link";
4
+ import { Button } from "@c-rex/ui/button";
5
+ import Image from "next/image";
6
+
7
+ interface NavBarProps {
8
+ scroll?: boolean;
9
+ large?: boolean;
10
+ }
11
+
12
+ export const NavBar: FC<NavBarProps> = () => {
13
+ return (
14
+ <header className="sticky top-0 z-40 flex w-full bg-background/60 backdrop-blur-xl transition-all bg-transparent border-b justify-center py-4">
15
+ <div className="container flex justify-between">
16
+ <div className="flex gap-6 md:gap-10">
17
+ <Link href="/" className="flex items-center space-x-1.5">
18
+ <Image
19
+ src="/img/logo.png"
20
+ alt="C-rex Logo"
21
+ width={88}
22
+ height={50}
23
+ />
24
+ </Link>
25
+
26
+ <nav className="hidden gap-6 md:flex">
27
+ {/*
28
+ TODO: add map to load links
29
+ TODO: add function to validate active item
30
+ */}
31
+ <Link
32
+ href={"/blog"}
33
+ prefetch={true}
34
+ className={
35
+ "flex items-center text-lg font-medium transition-colors hover:text-foreground/80 sm:text-sm"
36
+ }
37
+ >
38
+ Blog
39
+ </Link>
40
+
41
+ <Link
42
+ href={"#"}
43
+ prefetch={true}
44
+ className={
45
+ "flex items-center text-lg font-medium transition-colors hover:text-foreground/80 sm:text-sm"
46
+ }
47
+ >
48
+ Documentation
49
+ </Link>
50
+ </nav>
51
+ </div>
52
+
53
+ <div className="flex items-center space-x-3">
54
+ <Button
55
+ className="hidden gap-2 px-5 md:flex"
56
+ variant="default"
57
+ size="sm"
58
+ rounded="full"
59
+ >
60
+ <span>Sign In</span>
61
+ </Button>
62
+ </div>
63
+ </div>
64
+ </header>
65
+ );
66
+ };
@@ -0,0 +1,21 @@
1
+ "use client";
2
+
3
+ import { SearchProvider } from "@c-rex/contexts";
4
+ import { FC, ReactNode } from "react";
5
+
6
+ interface SearchStateWrapperProps {
7
+ children: ReactNode;
8
+ filters: {
9
+ searchValue: string;
10
+ page: number;
11
+ selectedLanguage: string[];
12
+ availableLanguages: string[];
13
+ };
14
+ }
15
+
16
+ export const SearchStateWrapper: FC<SearchStateWrapperProps> = ({
17
+ children,
18
+ filters,
19
+ }) => {
20
+ return <SearchProvider value={{ ...filters }}>{children}</SearchProvider>;
21
+ };
@@ -0,0 +1,16 @@
1
+ import { FC } from "react";
2
+ import { informationUnitsItems } from "@c-rex/interfaces";
3
+ import { Empty } from "./empty";
4
+ //import { CUSTOMER_CONFIG } from '@/config/customerConfig';
5
+ //import { RESULT_VIEW_OPTIONS } from '@/constants/components';
6
+ import BlogView from './result-view/blog';
7
+
8
+ const ViewComponent = BlogView;
9
+
10
+ interface ResultListProps {
11
+ items: informationUnitsItems[];
12
+ }
13
+
14
+ export const ResultList: FC<ResultListProps> = ({ items }) => {
15
+ return <>{items.length == 0 ? <Empty /> : <ViewComponent items={items} />}</>;
16
+ };
@@ -0,0 +1,58 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+ import BlogView from '../result-view/blog';
3
+
4
+ const meta: Meta<typeof BlogView> = {
5
+ title: 'Components/ResultView/Blog',
6
+ component: BlogView,
7
+ parameters: {
8
+ layout: 'centered',
9
+ },
10
+ tags: ['autodocs'],
11
+ };
12
+
13
+ export default meta;
14
+ type Story = StoryObj<typeof BlogView>;
15
+
16
+ const mockItems = [
17
+ {
18
+ id: '1',
19
+ shortId: 'doc-1',
20
+ labels: [
21
+ { value: 'Getting Started with C-Rex', language: 'en-US' },
22
+ { value: 'Começando com C-Rex', language: 'pt-BR' }
23
+ ],
24
+ languages: ['pt-BR'],
25
+ type: 'document',
26
+ renditions: [],
27
+ directoryNodes: []
28
+ },
29
+ {
30
+ id: '2',
31
+ shortId: 'doc-2',
32
+ labels: [
33
+ { value: 'Advanced Configuration Guide', language: 'en-US' }
34
+ ],
35
+ languages: ['en-US'],
36
+ type: 'document',
37
+ renditions: [],
38
+ directoryNodes: []
39
+ },
40
+ {
41
+ id: '3',
42
+ shortId: 'doc-3',
43
+ labels: [
44
+ { value: 'API Documentation', language: 'en-US' },
45
+ { value: 'Documentation API', language: 'fr-FR' }
46
+ ],
47
+ languages: ['fr-FR'],
48
+ type: 'document',
49
+ renditions: [],
50
+ directoryNodes: []
51
+ }
52
+ ];
53
+
54
+ export const Default: Story = {
55
+ args: {
56
+ items: mockItems as any
57
+ }
58
+ };
@@ -0,0 +1,38 @@
1
+ import { FC } from "react";
2
+
3
+ import { BlogCard } from "../blog-card";
4
+ import { informationUnitsItems, Labels } from "@c-rex/interfaces";
5
+
6
+ interface BlogViewProps {
7
+ items: informationUnitsItems[];
8
+ }
9
+
10
+ const BlogView: FC<BlogViewProps> = ({ items }) => {
11
+ const getTitle = (labels: Labels[]): string => {
12
+ return labels.map((item) => item.value).join();
13
+ };
14
+
15
+ return (
16
+ <div className="grid gap-8 md:grid-cols-2 md:gap-x-6 md:gap-y-10 xl:grid-cols-3">
17
+ {items.map((item, index) => {
18
+ return (
19
+ <BlogCard
20
+ key={index}
21
+ data={{
22
+ title: getTitle(item.labels),
23
+ blurDataURL: "/img/blog-post-1.webp",
24
+ image: "/img/blog-post-1.webp",
25
+ description: "item.shortDescription",
26
+ authors: "item.authors",
27
+ _id: "item._id",
28
+ date: "item.date",
29
+ slug: `info/${item.shortId}`,
30
+ }}
31
+ />
32
+ );
33
+ })}
34
+ </div>
35
+ );
36
+ };
37
+
38
+ export default BlogView;