@softure-ai/theme-notion 0.9.0 → 0.10.2

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 (64) hide show
  1. package/CHANGELOG.md +51 -0
  2. package/README.md +102 -8
  3. package/dist/index.d.ts +5 -1
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.js +4 -0
  6. package/dist/index.js.map +1 -1
  7. package/dist/notion/FoldRow.d.ts +2 -0
  8. package/dist/notion/FoldRow.d.ts.map +1 -1
  9. package/dist/notion/FoldRow.js +3 -2
  10. package/dist/notion/FoldRow.js.map +1 -1
  11. package/dist/notion/InstallBar.d.ts +23 -0
  12. package/dist/notion/InstallBar.d.ts.map +1 -0
  13. package/dist/notion/InstallBar.js +16 -0
  14. package/dist/notion/InstallBar.js.map +1 -0
  15. package/dist/notion/LaunchScreen.d.ts +13 -0
  16. package/dist/notion/LaunchScreen.d.ts.map +1 -0
  17. package/dist/notion/LaunchScreen.js +11 -0
  18. package/dist/notion/LaunchScreen.js.map +1 -0
  19. package/dist/notion/MiniProgress.d.ts +13 -0
  20. package/dist/notion/MiniProgress.d.ts.map +1 -0
  21. package/dist/notion/MiniProgress.js +24 -0
  22. package/dist/notion/MiniProgress.js.map +1 -0
  23. package/dist/notion/Timeline.d.ts +15 -3
  24. package/dist/notion/Timeline.d.ts.map +1 -1
  25. package/dist/notion/Timeline.js +16 -4
  26. package/dist/notion/Timeline.js.map +1 -1
  27. package/dist/notion/UpdatePrompt.d.ts +13 -0
  28. package/dist/notion/UpdatePrompt.d.ts.map +1 -0
  29. package/dist/notion/UpdatePrompt.js +16 -0
  30. package/dist/notion/UpdatePrompt.js.map +1 -0
  31. package/dist/ui/accordion.d.ts +3 -1
  32. package/dist/ui/accordion.d.ts.map +1 -1
  33. package/dist/ui/accordion.js +2 -2
  34. package/dist/ui/accordion.js.map +1 -1
  35. package/dist/ui/button.d.ts +1 -1
  36. package/dist/ui/dialog.d.ts +5 -2
  37. package/dist/ui/dialog.d.ts.map +1 -1
  38. package/dist/ui/dialog.js +5 -4
  39. package/dist/ui/dialog.js.map +1 -1
  40. package/dist/ui/dropdown-menu.d.ts +14 -5
  41. package/dist/ui/dropdown-menu.d.ts.map +1 -1
  42. package/dist/ui/dropdown-menu.js +21 -10
  43. package/dist/ui/dropdown-menu.js.map +1 -1
  44. package/dist/ui/scroll-area.d.ts +2 -1
  45. package/dist/ui/scroll-area.d.ts.map +1 -1
  46. package/dist/ui/scroll-area.js +2 -2
  47. package/dist/ui/scroll-area.js.map +1 -1
  48. package/dist/ui/tabs.d.ts +7 -2
  49. package/dist/ui/tabs.d.ts.map +1 -1
  50. package/dist/ui/tabs.js +47 -5
  51. package/dist/ui/tabs.js.map +1 -1
  52. package/package.json +1 -1
  53. package/src/index.ts +5 -1
  54. package/src/notion/FoldRow.tsx +8 -2
  55. package/src/notion/InstallBar.tsx +75 -0
  56. package/src/notion/LaunchScreen.tsx +37 -0
  57. package/src/notion/MiniProgress.tsx +67 -0
  58. package/src/notion/Timeline.tsx +65 -12
  59. package/src/notion/UpdatePrompt.tsx +47 -0
  60. package/src/ui/accordion.tsx +5 -1
  61. package/src/ui/dialog.tsx +16 -2
  62. package/src/ui/dropdown-menu.tsx +55 -16
  63. package/src/ui/scroll-area.tsx +5 -1
  64. package/src/ui/tabs.tsx +66 -8
@@ -5,6 +5,18 @@ import { cn } from "../lib/utils.js"
5
5
  import { CheckIcon, ChevronRightIcon, CircleIcon } from "lucide-react"
6
6
  import { DropdownMenu as DropdownMenuPrimitive } from "radix-ui"
7
7
 
8
+ type DropdownMenuItemSize = "default" | "touch"
9
+
10
+ // The items render in a portal, so a menu's size reaches them through context, not the DOM.
11
+ const DropdownMenuItemSizeContext =
12
+ React.createContext<DropdownMenuItemSize>("default")
13
+
14
+ // One height or the other: `cn` does not merge `min-h-7` with the theme's `touch-target` spacing.
15
+ function useItemHeight(size: DropdownMenuItemSize | undefined) {
16
+ const menuSize = React.useContext(DropdownMenuItemSizeContext)
17
+ return (size ?? menuSize) === "touch" ? "min-h-touch-target" : "min-h-7"
18
+ }
19
+
8
20
  function DropdownMenu({
9
21
  ...props
10
22
  }: React.ComponentProps<typeof DropdownMenuPrimitive.Root>) {
@@ -33,19 +45,24 @@ function DropdownMenuTrigger({
33
45
  function DropdownMenuContent({
34
46
  className,
35
47
  sideOffset = 4,
48
+ size = "default",
36
49
  ...props
37
- }: React.ComponentProps<typeof DropdownMenuPrimitive.Content>) {
50
+ }: React.ComponentProps<typeof DropdownMenuPrimitive.Content> & {
51
+ size?: DropdownMenuItemSize
52
+ }) {
38
53
  return (
39
54
  <DropdownMenuPrimitive.Portal>
40
- <DropdownMenuPrimitive.Content
41
- data-slot="dropdown-menu-content"
42
- sideOffset={sideOffset}
43
- className={cn(
44
- "z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-xl bg-popover p-1 text-popover-foreground shadow-menu 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 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95",
45
- className
46
- )}
47
- {...props}
48
- />
55
+ <DropdownMenuItemSizeContext.Provider value={size}>
56
+ <DropdownMenuPrimitive.Content
57
+ data-slot="dropdown-menu-content"
58
+ sideOffset={sideOffset}
59
+ className={cn(
60
+ "z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-xl bg-popover p-1 text-popover-foreground shadow-menu 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 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95",
61
+ className
62
+ )}
63
+ {...props}
64
+ />
65
+ </DropdownMenuItemSizeContext.Provider>
49
66
  </DropdownMenuPrimitive.Portal>
50
67
  )
51
68
  }
@@ -62,18 +79,23 @@ function DropdownMenuItem({
62
79
  className,
63
80
  inset,
64
81
  variant = "default",
82
+ size,
65
83
  ...props
66
84
  }: React.ComponentProps<typeof DropdownMenuPrimitive.Item> & {
67
85
  inset?: boolean
68
86
  variant?: "default" | "destructive"
87
+ size?: DropdownMenuItemSize
69
88
  }) {
89
+ const height = useItemHeight(size)
90
+
70
91
  return (
71
92
  <DropdownMenuPrimitive.Item
72
93
  data-slot="dropdown-menu-item"
73
94
  data-inset={inset}
74
95
  data-variant={variant}
75
96
  className={cn(
76
- "relative flex cursor-default items-center gap-2 rounded-md min-h-7 px-2 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/10 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground data-[variant=destructive]:*:[svg]:text-destructive!",
97
+ "relative flex cursor-default items-center gap-2 rounded-md px-2 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/10 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground data-[variant=destructive]:*:[svg]:text-destructive!",
98
+ height,
77
99
  className
78
100
  )}
79
101
  {...props}
@@ -85,13 +107,19 @@ function DropdownMenuCheckboxItem({
85
107
  className,
86
108
  children,
87
109
  checked,
110
+ size,
88
111
  ...props
89
- }: React.ComponentProps<typeof DropdownMenuPrimitive.CheckboxItem>) {
112
+ }: React.ComponentProps<typeof DropdownMenuPrimitive.CheckboxItem> & {
113
+ size?: DropdownMenuItemSize
114
+ }) {
115
+ const height = useItemHeight(size)
116
+
90
117
  return (
91
118
  <DropdownMenuPrimitive.CheckboxItem
92
119
  data-slot="dropdown-menu-checkbox-item"
93
120
  className={cn(
94
- "relative flex cursor-default items-center gap-2 rounded-md min-h-7 py-1 pr-2 pl-8 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
121
+ "relative flex cursor-default items-center gap-2 rounded-md py-1 pr-2 pl-8 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
122
+ height,
95
123
  className
96
124
  )}
97
125
  checked={checked}
@@ -121,13 +149,19 @@ function DropdownMenuRadioGroup({
121
149
  function DropdownMenuRadioItem({
122
150
  className,
123
151
  children,
152
+ size,
124
153
  ...props
125
- }: React.ComponentProps<typeof DropdownMenuPrimitive.RadioItem>) {
154
+ }: React.ComponentProps<typeof DropdownMenuPrimitive.RadioItem> & {
155
+ size?: DropdownMenuItemSize
156
+ }) {
157
+ const height = useItemHeight(size)
158
+
126
159
  return (
127
160
  <DropdownMenuPrimitive.RadioItem
128
161
  data-slot="dropdown-menu-radio-item"
129
162
  className={cn(
130
- "relative flex cursor-default items-center gap-2 rounded-md min-h-7 py-1 pr-2 pl-8 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
163
+ "relative flex cursor-default items-center gap-2 rounded-md py-1 pr-2 pl-8 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
164
+ height,
131
165
  className
132
166
  )}
133
167
  {...props}
@@ -201,16 +235,21 @@ function DropdownMenuSubTrigger({
201
235
  className,
202
236
  inset,
203
237
  children,
238
+ size,
204
239
  ...props
205
240
  }: React.ComponentProps<typeof DropdownMenuPrimitive.SubTrigger> & {
206
241
  inset?: boolean
242
+ size?: DropdownMenuItemSize
207
243
  }) {
244
+ const height = useItemHeight(size)
245
+
208
246
  return (
209
247
  <DropdownMenuPrimitive.SubTrigger
210
248
  data-slot="dropdown-menu-sub-trigger"
211
249
  data-inset={inset}
212
250
  className={cn(
213
- "flex cursor-default items-center gap-2 rounded-md min-h-7 px-2 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[inset]:pl-8 data-[state=open]:bg-accent data-[state=open]:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground",
251
+ "flex cursor-default items-center gap-2 rounded-md px-2 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[inset]:pl-8 data-[state=open]:bg-accent data-[state=open]:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground",
252
+ height,
214
253
  className
215
254
  )}
216
255
  {...props}
@@ -8,9 +8,12 @@ function ScrollArea({
8
8
  className,
9
9
  children,
10
10
  viewportProps,
11
+ scrollbars = "vertical",
11
12
  ...props
12
13
  }: React.ComponentProps<typeof ScrollAreaPrimitive.Root> & {
13
14
  viewportProps?: React.ComponentProps<typeof ScrollAreaPrimitive.Viewport>
15
+ // Which bars it draws: `horizontal` for a strip wider than its box, `both` for a table.
16
+ scrollbars?: "vertical" | "horizontal" | "both"
14
17
  }) {
15
18
  return (
16
19
  <ScrollAreaPrimitive.Root
@@ -30,7 +33,8 @@ function ScrollArea({
30
33
  >
31
34
  {children}
32
35
  </ScrollAreaPrimitive.Viewport>
33
- <ScrollBar />
36
+ {scrollbars !== "horizontal" && <ScrollBar />}
37
+ {scrollbars !== "vertical" && <ScrollBar orientation="horizontal" />}
34
38
  <ScrollAreaPrimitive.Corner />
35
39
  </ScrollAreaPrimitive.Root>
36
40
  )
package/src/ui/tabs.tsx CHANGED
@@ -5,6 +5,11 @@ import { cva, type VariantProps } from "class-variance-authority"
5
5
  import { cn } from "../lib/utils.js"
6
6
  import { Tabs as TabsPrimitive } from "radix-ui"
7
7
 
8
+ type TabsTriggerSize = "default" | "touch"
9
+
10
+ // A list's size reaches its triggers through context, so a trigger's own size can win over it.
11
+ const TabsTriggerSizeContext = React.createContext<TabsTriggerSize>("default")
12
+
8
13
  function Tabs({
9
14
  className,
10
15
  orientation = "horizontal",
@@ -16,7 +21,7 @@ function Tabs({
16
21
  data-orientation={orientation}
17
22
  orientation={orientation}
18
23
  className={cn(
19
- "group/tabs flex gap-2 data-[orientation=horizontal]:flex-col",
24
+ "group/tabs flex gap-2 data-[orientation=horizontal]:flex-col has-data-[scrollable=true]:min-w-0",
20
25
  className
21
26
  )}
22
27
  {...props}
@@ -32,33 +37,85 @@ const tabsListVariants = cva(
32
37
  default: "bg-muted",
33
38
  line: "gap-1 bg-transparent",
34
39
  },
40
+ size: {
41
+ default: "",
42
+ // The triggers set the height: a fixed one would cap them at 35 px.
43
+ touch: "group-data-[orientation=horizontal]/tabs:h-auto",
44
+ },
45
+ // Keeps to its container's width and scrolls sideways; the line variant keeps room for the active underline.
46
+ scrollable: {
47
+ false: "",
48
+ true: "relative w-full max-w-full min-w-0 justify-start overflow-x-auto overflow-y-hidden overscroll-x-contain [scrollbar-width:thin] group-data-[orientation=horizontal]/tabs:h-auto data-[variant=line]:pb-1.5 *:flex-none",
49
+ },
35
50
  },
36
51
  defaultVariants: {
37
52
  variant: "line",
53
+ size: "default",
54
+ scrollable: false,
38
55
  },
39
56
  }
40
57
  )
41
58
 
59
+ // Scrolls a scrollable list so its active trigger sits in the middle, now and whenever the active tab changes.
60
+ function useCentredActiveTrigger(list: React.RefObject<HTMLDivElement | null>, isScrollable: boolean) {
61
+ React.useEffect(() => {
62
+ const element = list.current
63
+ if (!isScrollable || element === null) return
64
+ const centreActiveTrigger = () => {
65
+ const active = element.querySelector<HTMLElement>('[data-slot="tabs-trigger"][data-state="active"]')
66
+ if (active === null) return
67
+ element.scrollLeft = active.offsetLeft - (element.clientWidth - active.offsetWidth) / 2
68
+ }
69
+ centreActiveTrigger()
70
+ const observer = new MutationObserver(centreActiveTrigger)
71
+ observer.observe(element, { subtree: true, attributeFilter: ["data-state"] })
72
+ return () => observer.disconnect()
73
+ }, [list, isScrollable])
74
+ }
75
+
42
76
  function TabsList({
43
77
  className,
44
78
  variant = "line",
79
+ size = "default",
80
+ scrollable = false,
81
+ ref,
45
82
  ...props
46
83
  }: React.ComponentProps<typeof TabsPrimitive.List> &
47
84
  VariantProps<typeof tabsListVariants>) {
85
+ const listRef = React.useRef<HTMLDivElement | null>(null)
86
+ const setListRef = React.useCallback(
87
+ (node: HTMLDivElement | null) => {
88
+ listRef.current = node
89
+ if (typeof ref === "function") ref(node)
90
+ else if (ref) ref.current = node
91
+ },
92
+ [ref]
93
+ )
94
+ useCentredActiveTrigger(listRef, scrollable === true)
95
+
48
96
  return (
49
- <TabsPrimitive.List
50
- data-slot="tabs-list"
51
- data-variant={variant}
52
- className={cn(tabsListVariants({ variant }), className)}
53
- {...props}
54
- />
97
+ <TabsTriggerSizeContext.Provider value={size ?? "default"}>
98
+ <TabsPrimitive.List
99
+ data-slot="tabs-list"
100
+ data-variant={variant}
101
+ data-scrollable={scrollable === true ? "true" : undefined}
102
+ ref={setListRef}
103
+ className={cn(tabsListVariants({ variant, size, scrollable }), className)}
104
+ {...props}
105
+ />
106
+ </TabsTriggerSizeContext.Provider>
55
107
  )
56
108
  }
57
109
 
58
110
  function TabsTrigger({
59
111
  className,
112
+ size,
60
113
  ...props
61
- }: React.ComponentProps<typeof TabsPrimitive.Trigger>) {
114
+ }: React.ComponentProps<typeof TabsPrimitive.Trigger> & {
115
+ size?: TabsTriggerSize
116
+ }) {
117
+ const listSize = React.useContext(TabsTriggerSizeContext)
118
+
62
119
  return (
63
120
  <TabsPrimitive.Trigger
64
121
  data-slot="tabs-trigger"
@@ -67,6 +124,7 @@ function TabsTrigger({
67
124
  "group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent group-data-[variant=line]/tabs-list:data-[state=active]:border-transparent dark:group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent",
68
125
  "bg-clip-padding data-[state=active]:border-input data-[state=active]:bg-background data-[state=active]:text-foreground focus-visible:data-[state=active]:border-ring dark:data-[state=active]:bg-accent/40 dark:data-[state=active]:text-foreground",
69
126
  "after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-[orientation=horizontal]/tabs:after:inset-x-0 group-data-[orientation=horizontal]/tabs:after:bottom-[-5px] group-data-[orientation=horizontal]/tabs:after:h-0.5 group-data-[orientation=vertical]/tabs:after:inset-y-0 group-data-[orientation=vertical]/tabs:after:-right-1 group-data-[orientation=vertical]/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-[state=active]:after:opacity-100",
127
+ (size ?? listSize) === "touch" && "min-h-touch-target min-w-touch-target",
70
128
  className
71
129
  )}
72
130
  {...props}