@sikka/hawa 0.1.16 → 0.1.18

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sikka/hawa",
3
- "version": "0.1.16",
3
+ "version": "0.1.18",
4
4
  "description": "SaaS Oriented UI Kit",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.es.js",
@@ -107,6 +107,7 @@
107
107
  "dependencies": {
108
108
  "@radix-ui/react-dropdown-menu": "^2.0.5",
109
109
  "@radix-ui/react-label": "^2.0.2",
110
+ "@radix-ui/react-popover": "^1.0.6",
110
111
  "@radix-ui/react-tooltip": "^1.0.6",
111
112
  "class-variance-authority": "^0.7.0",
112
113
  "clsx": "^1.2.1",
@@ -11,6 +11,7 @@ const buttonVariants = cva(
11
11
  variants: {
12
12
  variant: {
13
13
  default: "bg-primary text-primary-foreground hover:bg-primary/90",
14
+ light: "bg-primary/20 text-primary hover:bg-primary/40",
14
15
  destructive:
15
16
  "bg-destructive text-destructive-foreground hover:bg-destructive/90",
16
17
  outline:
@@ -27,6 +28,7 @@ const buttonVariants = cva(
27
28
  lg: "h-11 rounded-md px-8",
28
29
  xl: "h-14 rounded-md px-10",
29
30
  icon: "h-10 w-10",
31
+ smallIcon: "h-7 w-7",
30
32
  },
31
33
  },
32
34
  defaultVariants: {
@@ -222,16 +222,24 @@ type ExtendedDropdownMenuContentProps = Partial<
222
222
  // Add any additional types or overrides here, for example:
223
223
  // side?: "left" | "right" | "top" | "bottom"
224
224
  }
225
+ type ExtendedDropdownMenuTriggerProps = Partial<
226
+ React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Trigger>
227
+ > & {
228
+ // Add any additional types or overrides here, for example:
229
+ // side?: "left" | "right" | "top" | "bottom"
230
+ }
225
231
 
226
232
  type SubItem = {
227
233
  label: string
228
234
  value: string
235
+ action?: () => void
229
236
  highlighted?: boolean
230
237
  }
231
238
 
232
239
  type Item = {
233
240
  label: string
234
241
  value: string
242
+ action?: () => void
235
243
  highlighted?: boolean
236
244
  subitems?: SubItem[] // Note the use of the optional modifier
237
245
  }
@@ -244,6 +252,7 @@ export const DropdownMenu = ({
244
252
  sideOffset,
245
253
  side,
246
254
  className,
255
+ triggerClassname,
247
256
  align,
248
257
  alignOffset,
249
258
  }: {
@@ -253,6 +262,7 @@ export const DropdownMenu = ({
253
262
  direction?: "rtl" | "ltr"
254
263
  onItemSelect?: any
255
264
  className?: ExtendedDropdownMenuContentProps["className"]
265
+ triggerClassname?: ExtendedDropdownMenuTriggerProps["className"]
256
266
  sideOffset?: ExtendedDropdownMenuContentProps["sideOffset"]
257
267
  side?: ExtendedDropdownMenuContentProps["side"]
258
268
  align?: ExtendedDropdownMenuContentProps["align"]
@@ -261,7 +271,7 @@ export const DropdownMenu = ({
261
271
  }) => {
262
272
  return (
263
273
  <DropdownMenuRoot dir={direction}>
264
- <DropdownMenuTrigger className="focus:ring-0">
274
+ <DropdownMenuTrigger className={triggerClassname}>
265
275
  {trigger}
266
276
  </DropdownMenuTrigger>
267
277
  <DropdownMenuPortal>
@@ -282,7 +292,7 @@ export const DropdownMenu = ({
282
292
  <DropdownMenuSubContent>
283
293
  {item.subitems.map((subitem, subIndex) => (
284
294
  <DropdownMenuItem
285
- onSelect={() => onItemSelect(subitem.value)}
295
+ onSelect={() => subitem.action()}
286
296
  key={subIndex}
287
297
  >
288
298
  {subitem.label}
@@ -292,10 +302,7 @@ export const DropdownMenu = ({
292
302
  </DropdownMenuPortal>
293
303
  </DropdownMenuSub>
294
304
  ) : (
295
- <DropdownMenuItem
296
- key={index}
297
- onSelect={() => onItemSelect(item.value)}
298
- >
305
+ <DropdownMenuItem key={index} onSelect={() => item.action()}>
299
306
  {item.label}
300
307
  </DropdownMenuItem>
301
308
  )
@@ -32,7 +32,7 @@ export const HawaStats: FC<StatTypes> = ({ variant = "default", ...props }) => {
32
32
  ) : (
33
33
  <div className="text-2xl font-bold">{props.number}</div>
34
34
  )}
35
- {props.isLoading ? (
35
+ {props.isLoading && props.helperText ? (
36
36
  <Skeleton className="mt-2 h-4 w-1/2" />
37
37
  ) : (
38
38
  props.helperText && (
@@ -0,0 +1,50 @@
1
+ "use client"
2
+
3
+ import * as React from "react"
4
+ import * as PopoverPrimitive from "@radix-ui/react-popover"
5
+
6
+ import { cn } from "../util"
7
+
8
+ interface PopoverProps {
9
+ trigger: React.ReactNode
10
+ children: React.ReactNode
11
+ className?: string
12
+ align?: "start" | "center" | "end"
13
+ sideOffset?: number
14
+ }
15
+
16
+ const Popover: React.FC<PopoverProps> = ({
17
+ trigger,
18
+ children,
19
+ className,
20
+ align = "center",
21
+ sideOffset = 4,
22
+ }) => (
23
+ <PopoverPrimitive.Root>
24
+ <PopoverPrimitive.Trigger>{trigger}</PopoverPrimitive.Trigger>
25
+ <PopoverContent className={className} align={align} sideOffset={sideOffset}>
26
+ {children}
27
+ </PopoverContent>
28
+ </PopoverPrimitive.Root>
29
+ )
30
+
31
+ const PopoverContent = React.forwardRef<
32
+ React.ElementRef<typeof PopoverPrimitive.Content>,
33
+ React.ComponentPropsWithoutRef<typeof PopoverPrimitive.Content>
34
+ >(({ className, align = "center", sideOffset = 4, ...props }, ref) => (
35
+ <PopoverPrimitive.Portal>
36
+ <PopoverPrimitive.Content
37
+ ref={ref}
38
+ align={align}
39
+ sideOffset={sideOffset}
40
+ className={cn(
41
+ "z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
42
+ className
43
+ )}
44
+ {...props}
45
+ />
46
+ </PopoverPrimitive.Portal>
47
+ ))
48
+ PopoverContent.displayName = PopoverPrimitive.Content.displayName
49
+
50
+ export { Popover }
@@ -63,3 +63,4 @@ export * from "./Card"
63
63
  export * from "./Skeleton"
64
64
  export * from "./InterfaceSettings"
65
65
  export * from "./DropdownMenu"
66
+ export * from "./Popover"
@@ -208,13 +208,14 @@ export const HawaAppLayoutSimplified: React.FunctionComponent<
208
208
  </div>
209
209
  </HawaMenu> */}
210
210
  <DropdownMenu
211
+ triggerClassname="mx-2"
211
212
  align="end"
212
- alignOffset={10}
213
+ alignOffset={8}
213
214
  side={"bottom"}
214
- sideOffset={10}
215
+ sideOffset={5}
215
216
  direction={isRTL ? "rtl" : "ltr"}
216
217
  trigger={
217
- <div className="relative mx-2 h-8 w-8 cursor-pointer overflow-hidden rounded ring-1 ring-primary dark:bg-gray-600">
218
+ <div className="relative h-8 w-8 cursor-pointer overflow-clip rounded ring-1 ring-primary/30 dark:bg-gray-600">
218
219
  <AvatarIcon />
219
220
  </div>
220
221
  }
@@ -333,7 +334,7 @@ export const HawaAppLayoutSimplified: React.FunctionComponent<
333
334
  dItem.subItems?.find(
334
335
  (e) => e.slug === props.currentPage
335
336
  )
336
- ? "bg-primary text-white"
337
+ ? "bg-primary text-primary-foreground "
337
338
  : "hover:bg-primary/20",
338
339
  "my-1 flex cursor-pointer flex-row items-center justify-between overflow-x-clip rounded p-2 pl-3 transition-all ",
339
340
  isRTL ? "flex-row-reverse pr-3" : "",
@@ -341,12 +342,12 @@ export const HawaAppLayoutSimplified: React.FunctionComponent<
341
342
  )}
342
343
  >
343
344
  <div className="flex flex-row" dir={direction}>
344
- <div className="flex items-center justify-center dark:text-white">
345
+ <div className="flex items-center justify-center ">
345
346
  {dItem.icon}
346
347
  </div>
347
348
  <div
348
349
  className={clsx(
349
- "mx-2 whitespace-nowrap text-sm transition-all dark:text-white",
350
+ "mx-2 whitespace-nowrap text-sm transition-all",
350
351
  openSideMenu ? "opacity-100" : "opacity-0"
351
352
  )}
352
353
  >
@@ -426,8 +427,7 @@ export const HawaAppLayoutSimplified: React.FunctionComponent<
426
427
  {/* Drawer Footer */}
427
428
  <div
428
429
  className={clsx(
429
- "fixed bottom-0 flex h-14 w-full items-center justify-center gap-2 overflow-clip bg-primary-foreground transition-all",
430
-
430
+ "fixed bottom-0 flex h-14 w-full items-center justify-center gap-2 overflow-clip bg-primary-foreground transition-all",
431
431
  direction === "rtl" ? "flex-row-reverse" : "flex-row"
432
432
  )}
433
433
  style={{
@@ -437,14 +437,16 @@ export const HawaAppLayoutSimplified: React.FunctionComponent<
437
437
  : `${openSideMenu ? openDrawerWidth : 0}px`,
438
438
  }}
439
439
  >
440
- {size > 600 && DrawerFooterActions && openSideMenu ? (
440
+ {DrawerFooterActions && openSideMenu ? (
441
441
  <>{DrawerFooterActions}</>
442
442
  ) : null}
443
443
 
444
444
  {/* Expand Button */}
445
445
  {size > 600 && openSideMenu ? (
446
446
  <div
447
- className={clsx("w-fit transition-all")}
447
+ className={clsx(
448
+ "flex w-fit flex-col items-center justify-center transition-all"
449
+ )}
448
450
  style={
449
451
  isRTL
450
452
  ? {
@@ -463,43 +465,42 @@ export const HawaAppLayoutSimplified: React.FunctionComponent<
463
465
  }
464
466
  }
465
467
  >
466
- <div
467
- dir={direction}
468
- className={clsx(
469
- "relative left-0 top-0 transition-all",
470
- openSideMenu ? " opacity-100" : " opacity-0"
471
- )}
468
+ <Tooltip
469
+ side={"left"}
470
+ delayDuration={300}
471
+ content={
472
+ keepOpen
473
+ ? props.texts?.collapseSidebar || "Collapse Sidebar"
474
+ : props.texts?.expandSidebar || "Expand Sidebar"
475
+ }
472
476
  >
473
- <Tooltip
474
- side={"left"}
475
- delayDuration={300}
476
- content={
477
- keepOpen
478
- ? props.texts?.collapseSidebar || "Collapse Sidebar"
479
- : props.texts?.expandSidebar || "Expand Sidebar"
480
- // || "Expand Sidebar"
481
- }
477
+ <Button
478
+ variant="light"
479
+ onClick={() => setKeepOpen(!keepOpen)}
480
+ size="smallIcon"
482
481
  >
483
- <Button
484
- variant="secondary"
485
- onClick={() => setKeepOpen(!keepOpen)}
486
- size="icon"
482
+ <svg
483
+ className={clsx(
484
+ "h-6 w-6 shrink-0 text-primary transition-all disabled:bg-gray-200 ",
485
+ keepOpen
486
+ ? isRTL
487
+ ? "-rotate-90"
488
+ : "rotate-90"
489
+ : isRTL
490
+ ? "rotate-90"
491
+ : "-rotate-90"
492
+ )}
493
+ fill="currentColor"
494
+ viewBox="0 0 20 20"
487
495
  >
488
- <ArrowIcon
489
- // color={"black"}
490
- pointing={
491
- keepOpen
492
- ? isRTL
493
- ? "right"
494
- : "left"
495
- : isRTL
496
- ? "left"
497
- : "right"
498
- }
499
- />
500
- </Button>
501
- </Tooltip>
502
- </div>
496
+ <path
497
+ fillRule="evenodd"
498
+ d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z"
499
+ clipRule="evenodd"
500
+ ></path>
501
+ </svg>
502
+ </Button>
503
+ </Tooltip>
503
504
  </div>
504
505
  ) : null}
505
506
  </div>
@@ -567,10 +568,9 @@ const ArrowIcon = ({ pointing }) => {
567
568
  return (
568
569
  <svg
569
570
  className={clsx(
570
- "h-6 w-6 shrink-0 transition-all disabled:bg-gray-200 dark:text-white",
571
+ "h-6 w-6 shrink-0 text-primary-foreground transition-all disabled:bg-gray-200 ",
571
572
  directionStyle
572
573
  )}
573
- // fill={color}
574
574
  fill="currentColor"
575
575
  viewBox="0 0 20 20"
576
576
  >
package/src/styles.css CHANGED
@@ -1220,6 +1220,9 @@ video {
1220
1220
  .w-7 {
1221
1221
  width: 1.75rem;
1222
1222
  }
1223
+ .w-72 {
1224
+ width: 18rem;
1225
+ }
1223
1226
  .w-8 {
1224
1227
  width: 2rem;
1225
1228
  }
@@ -2584,12 +2587,12 @@ video {
2584
2587
  .ring-buttonPrimary-500 {
2585
2588
  --tw-ring-color: hsl(var(--button-primary-500));
2586
2589
  }
2587
- .ring-primary {
2588
- --tw-ring-color: hsl(var(--primary));
2589
- }
2590
2590
  .ring-primary\/20 {
2591
2591
  --tw-ring-color: hsl(var(--primary) / 0.2);
2592
2592
  }
2593
+ .ring-primary\/30 {
2594
+ --tw-ring-color: hsl(var(--primary) / 0.3);
2595
+ }
2593
2596
  .ring-offset-1 {
2594
2597
  --tw-ring-offset-width: 1px;
2595
2598
  }
@@ -2957,6 +2960,9 @@ body {
2957
2960
  .hover\:bg-primary\/20:hover {
2958
2961
  background-color: hsl(var(--primary) / 0.2);
2959
2962
  }
2963
+ .hover\:bg-primary\/40:hover {
2964
+ background-color: hsl(var(--primary) / 0.4);
2965
+ }
2960
2966
  .hover\:bg-primary\/90:hover {
2961
2967
  background-color: hsl(var(--primary) / 0.9);
2962
2968
  }
@@ -3060,11 +3066,6 @@ body {
3060
3066
  outline: 2px solid transparent;
3061
3067
  outline-offset: 2px;
3062
3068
  }
3063
- .focus\:ring-0:focus {
3064
- --tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);
3065
- --tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(0px + var(--tw-ring-offset-width)) var(--tw-ring-color);
3066
- box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow, 0 0 #0000);
3067
- }
3068
3069
  .focus\:ring-2:focus {
3069
3070
  --tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);
3070
3071
  --tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);