@sikka/hawa 0.1.26 → 0.1.27

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.26",
3
+ "version": "0.1.27",
4
4
  "description": "SaaS Oriented UI Kit",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.es.js",
@@ -1,5 +1,5 @@
1
1
  import React, { useState, FC } from "react"
2
- import { HawaTabs } from "../../elements"
2
+ import { HawaRadio } from "../../elements"
3
3
  import { Tooltip } from "../../elements/Tooltip"
4
4
 
5
5
  const CheckMark = () => (
@@ -65,29 +65,23 @@ type ComparingPlansTypes = {
65
65
  direction?: "rtl" | "ltr"
66
66
  }
67
67
  export const ComparingPlans: FC<ComparingPlansTypes> = (props) => {
68
- const [currentCurrency, setCurrentCurrency] = useState("SAR")
68
+ const [currentCurrency, setCurrentCurrency] = useState("sar")
69
69
  const [currentCycle, setCurrentCycle] = useState("month")
70
70
 
71
71
  return (
72
72
  <div id="detailed-pricing" className="w-full overflow-x-auto">
73
73
  <div className="mb-2 flex w-full justify-between">
74
- <HawaTabs
75
- pill
74
+ <HawaRadio
75
+ design="tabs"
76
76
  defaultValue={currentCycle}
77
77
  options={props.billingCycles}
78
- onChangeTab={(e: any) => {
79
- // setCurrentCycle(e.label)
80
- props.onCycleChange(e)
81
- }}
78
+ onChangeTab={(e: any) => props.onCycleChange(e)}
82
79
  />
83
- <HawaTabs
84
- pill
80
+ <HawaRadio
81
+ design="tabs"
85
82
  defaultValue={currentCurrency}
86
83
  options={props.currencies}
87
- onChangeTab={(e: any) => {
88
- // setCurrentCurrency(e.label)
89
- props.onCurrencyChange(e)
90
- }}
84
+ onChangeTab={(e: any) => props.onCurrencyChange(e)}
91
85
  />
92
86
  </div>
93
87
  <div className=" overflow-hidden rounded">
@@ -1,5 +1,5 @@
1
1
  import React, { FC } from "react"
2
- import { HawaPricingCard, HawaTabs } from "../../elements"
2
+ import { HawaPricingCard, HawaRadio } from "../../elements"
3
3
 
4
4
  type PricingPlansTypes = {
5
5
  plans: [
@@ -46,14 +46,14 @@ export const PricingPlans: FC<PricingPlansTypes> = (props) => {
46
46
  return (
47
47
  <div>
48
48
  <div className="mb-2 flex w-full justify-between">
49
- <HawaTabs
50
- pill
49
+ <HawaRadio
50
+ design="tabs"
51
51
  defaultValue={props.currentCycle}
52
52
  options={props.billingCycles}
53
53
  onChangeTab={(e: any) => props.onCycleChange(e)}
54
54
  />
55
- <HawaTabs
56
- pill
55
+ <HawaRadio
56
+ design="tabs"
57
57
  defaultValue={props.currentCurrency}
58
58
  options={props.currencies}
59
59
  onChangeTab={(e: any) => props.onCurrencyChange(e)}
@@ -1,5 +1,5 @@
1
1
  import React, { useState, FC } from "react"
2
- import clsx from "clsx"
2
+ import { cn } from "../util"
3
3
 
4
4
  // TODO: fix wrapping issue when small screen
5
5
 
@@ -62,13 +62,13 @@ export const HawaTabs: FC<TabsTypes> = ({
62
62
  return (
63
63
  <div
64
64
  dir={direction}
65
- className={clsx(
65
+ className={cn(
66
66
  containerStyle[orientation],
67
67
  props.options[selectedOption] ? "border-b-2" : "border-b-0"
68
68
  )}
69
69
  >
70
70
  <ul
71
- className={clsx(
71
+ className={cn(
72
72
  "w-full border-primary",
73
73
  marginBetween
74
74
  ? orientation === "vertical"
@@ -98,35 +98,33 @@ export const HawaTabs: FC<TabsTypes> = ({
98
98
  )}
99
99
  >
100
100
  {props.options?.map((opt: any, o) => (
101
- <li key={o}>
102
- <button
103
- aria-current="page"
104
- onClick={() => {
105
- setSelectedOption(opt.value)
106
- props?.onChangeTab(opt)
107
- }}
108
- className={clsx(
109
- "flex flex-row items-center gap-2 ",
110
- opt.value === selectedOption
111
- ? // props.options[selectedOption].value === opt.value
112
- [
113
- activeTabStyle[orientation],
114
- direction === "rtl" ? "rounded-r" : "rounded-l",
115
- ]
116
- : inactiveTabStyle[orientation],
117
- "w-full transition-all",
118
- pill
119
- ? "rounded"
120
- : orientation === "vertical"
121
- ? "rounded rounded-bl-none rounded-tl-none"
122
- : "rounded sm:rounded-b-none"
123
- // direction === "rtl" ? "bg-yellow-400" : "bg-yellow-400"
124
- )}
125
- >
126
- {opt.icon}
127
- {opt.label}
128
- </button>
129
- </li>
101
+ <button
102
+ key={o}
103
+ aria-current="page"
104
+ onClick={() => {
105
+ setSelectedOption(opt.value)
106
+ props?.onChangeTab(opt)
107
+ }}
108
+ className={cn(
109
+ opt.value === selectedOption
110
+ ? // props.options[selectedOption].value === opt.value
111
+ [
112
+ activeTabStyle[orientation],
113
+ direction === "rtl" ? "rounded-r" : "rounded-l",
114
+ ]
115
+ : inactiveTabStyle[orientation],
116
+ pill
117
+ ? "rounded"
118
+ : orientation === "vertical"
119
+ ? "rounded rounded-bl-none rounded-tl-none"
120
+ : "rounded sm:rounded-b-none",
121
+ // direction === "rtl" ? "bg-yellow-400" : "bg-yellow-400"
122
+ "flex w-fit flex-row items-center gap-2 transition-all "
123
+ )}
124
+ >
125
+ {opt.icon}
126
+ {opt.label}
127
+ </button>
130
128
  ))}
131
129
  </ul>
132
130
 
@@ -134,7 +132,7 @@ export const HawaTabs: FC<TabsTypes> = ({
134
132
  {props.options.map((tab, i) => (
135
133
  <div
136
134
  key={i}
137
- className={clsx(selectedOption === tab.value ? "" : "hidden")}
135
+ className={cn(selectedOption === tab.value ? "" : "hidden")}
138
136
  >
139
137
  {tab.content}
140
138
  </div>
@@ -3,36 +3,80 @@ import * as TabsPrimitive from "@radix-ui/react-tabs"
3
3
 
4
4
  import { cn } from "../util"
5
5
 
6
- const Tabs = TabsPrimitive.Root
6
+ const TabsContext = React.createContext<{
7
+ orientation?: "vertical" | "horizontal"
8
+ }>({
9
+ orientation: "vertical", // default value
10
+ })
7
11
 
8
- const TabsList = React.forwardRef<
9
- React.ElementRef<typeof TabsPrimitive.List>,
10
- React.ComponentPropsWithoutRef<typeof TabsPrimitive.List>
11
- >(({ className, ...props }, ref) => (
12
- <TabsPrimitive.List
12
+ // const Tabs = TabsPrimitive.Root
13
+ type TabsRootProps = React.ComponentPropsWithoutRef<
14
+ typeof TabsPrimitive.Root
15
+ > & {
16
+ orientation?: "vertical" | "horizontal"
17
+ }
18
+
19
+ const Tabs = React.forwardRef<
20
+ React.ElementRef<typeof TabsPrimitive.Root>,
21
+ TabsRootProps
22
+ >(({ className, orientation, ...props }, ref) => (
23
+ <TabsPrimitive.Root
13
24
  ref={ref}
14
25
  className={cn(
15
- "inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",
16
- className
26
+ className,
27
+ "flex gap-2",
28
+ orientation === "horizontal" ? "flex-row" : "flex-col"
17
29
  )}
18
30
  {...props}
19
- />
31
+ >
32
+ <TabsContext.Provider value={{ orientation }}>
33
+ {props.children}
34
+ </TabsContext.Provider>
35
+ </TabsPrimitive.Root>
20
36
  ))
37
+ Tabs.displayName = TabsPrimitive.Root.displayName
38
+
39
+ // type TabsListProps = React.ComponentPropsWithoutRef<
40
+ // typeof TabsPrimitive.List
41
+ // > & {
42
+ // // orientation?: "vertical" | "horizontal"
43
+ // }
44
+
45
+ const TabsList = React.forwardRef<
46
+ React.ElementRef<typeof TabsPrimitive.List>,
47
+ React.ComponentPropsWithoutRef<typeof TabsPrimitive.List>
48
+ >(({ className, ...props }, ref) => {
49
+ const { orientation } = React.useContext(TabsContext)
50
+
51
+ return (
52
+ <TabsPrimitive.List
53
+ ref={ref}
54
+ className={cn(
55
+ "flex w-fit flex-wrap items-center justify-start gap-1 rounded bg-muted p-1 text-muted-foreground ",
56
+ orientation === "horizontal" ? "flex-col" : "flex-row",
57
+ className
58
+ )}
59
+ {...props}
60
+ />
61
+ )
62
+ })
21
63
  TabsList.displayName = TabsPrimitive.List.displayName
22
64
 
23
65
  const TabsTrigger = React.forwardRef<
24
66
  React.ElementRef<typeof TabsPrimitive.Trigger>,
25
67
  React.ComponentPropsWithoutRef<typeof TabsPrimitive.Trigger>
26
- >(({ className, ...props }, ref) => (
27
- <TabsPrimitive.Trigger
28
- ref={ref}
29
- className={cn(
30
- "inline-flex select-none items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-primary data-[state=active]:text-primary-foreground data-[state=active]:shadow-sm",
31
- className
32
- )}
33
- {...props}
34
- />
35
- ))
68
+ >(({ className, ...props }, ref) => {
69
+ return (
70
+ <TabsPrimitive.Trigger
71
+ ref={ref}
72
+ className={cn(
73
+ "inline-flex w-full flex-1 select-none items-center justify-center whitespace-nowrap rounded border px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-primary data-[state=active]:text-primary-foreground data-[state=active]:shadow-sm ",
74
+ className
75
+ )}
76
+ {...props}
77
+ />
78
+ )
79
+ })
36
80
  TabsTrigger.displayName = TabsPrimitive.Trigger.displayName
37
81
 
38
82
  const TabsContent = React.forwardRef<
@@ -42,7 +86,7 @@ const TabsContent = React.forwardRef<
42
86
  <TabsPrimitive.Content
43
87
  ref={ref}
44
88
  className={cn(
45
- "mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
89
+ "w-full ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
46
90
  className
47
91
  )}
48
92
  {...props}