ruler-components 0.1.0

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 (114) hide show
  1. package/AGENTS.md +9 -0
  2. package/CLAUDE.md +1 -0
  3. package/LICENSE +21 -0
  4. package/README.md +45 -0
  5. package/app/docs/[slug]/page.tsx +147 -0
  6. package/app/docs/layout.tsx +26 -0
  7. package/app/docs/page.tsx +148 -0
  8. package/app/favicon.ico +0 -0
  9. package/app/globals.css +168 -0
  10. package/app/icon.png +0 -0
  11. package/app/layout.tsx +90 -0
  12. package/app/opengraph-image.tsx +10 -0
  13. package/app/page.tsx +34 -0
  14. package/app/twitter-image.tsx +10 -0
  15. package/components/docs/accordion-doc-page.tsx +352 -0
  16. package/components/docs/alert-doc-page.tsx +293 -0
  17. package/components/docs/allinput-doc-page.tsx +183 -0
  18. package/components/docs/avatar-doc-page.tsx +424 -0
  19. package/components/docs/badge-doc-page.tsx +363 -0
  20. package/components/docs/button-doc-page.tsx +406 -0
  21. package/components/docs/card-doc-page.tsx +364 -0
  22. package/components/docs/checkbox-doc-page.tsx +277 -0
  23. package/components/docs/colors-doc-page.tsx +430 -0
  24. package/components/docs/dialog-doc-page.tsx +364 -0
  25. package/components/docs/docs-footer.tsx +11 -0
  26. package/components/docs/docs-mobile-menu-bar.tsx +22 -0
  27. package/components/docs/docs-mobile-nav-context.tsx +27 -0
  28. package/components/docs/docs-page.tsx +263 -0
  29. package/components/docs/docs-search.tsx +303 -0
  30. package/components/docs/docs-sidebar.tsx +165 -0
  31. package/components/docs/docs-topbar.tsx +32 -0
  32. package/components/docs/dropdown-doc-page.tsx +522 -0
  33. package/components/docs/getting-started-doc-page.tsx +205 -0
  34. package/components/docs/label-doc-page.tsx +173 -0
  35. package/components/docs/loaders-doc-page.tsx +244 -0
  36. package/components/docs/menu-doc-page.tsx +373 -0
  37. package/components/docs/modal-doc-page.tsx +436 -0
  38. package/components/docs/next-steps.tsx +53 -0
  39. package/components/docs/pagination-doc-page.tsx +316 -0
  40. package/components/docs/progress-doc-page.tsx +387 -0
  41. package/components/docs/radio-doc-page.tsx +270 -0
  42. package/components/docs/skeleton-doc-page.tsx +230 -0
  43. package/components/docs/stepper-doc-page.tsx +309 -0
  44. package/components/docs/switch-doc-page.tsx +264 -0
  45. package/components/docs/table-doc-page.tsx +689 -0
  46. package/components/docs/tabs-doc-page.tsx +359 -0
  47. package/components/docs/theming-doc-page.tsx +243 -0
  48. package/components/docs/tooltip-doc-page.tsx +357 -0
  49. package/components/docs/usage-section.tsx +21 -0
  50. package/components/icons/discord.tsx +9 -0
  51. package/components/icons/github.tsx +9 -0
  52. package/components/icons/x.tsx +9 -0
  53. package/components/installation-section.tsx +34 -0
  54. package/components/landing/feature-highlights.tsx +105 -0
  55. package/components/landing/footer-strip.tsx +45 -0
  56. package/components/landing/hero-card.tsx +14 -0
  57. package/components/landing/hero-spotlight.tsx +126 -0
  58. package/components/landing/hero.tsx +64 -0
  59. package/components/landing/navbar.tsx +44 -0
  60. package/components/landing/quick-start-section.tsx +59 -0
  61. package/components/landing/site-footer.tsx +55 -0
  62. package/components/theme-provider.tsx +60 -0
  63. package/components/ui/accordion.tsx +174 -0
  64. package/components/ui/alert.tsx +103 -0
  65. package/components/ui/allinput.tsx +210 -0
  66. package/components/ui/avatar.tsx +179 -0
  67. package/components/ui/badge.tsx +52 -0
  68. package/components/ui/button.tsx +75 -0
  69. package/components/ui/card.tsx +105 -0
  70. package/components/ui/checkbox.tsx +130 -0
  71. package/components/ui/code-block.tsx +60 -0
  72. package/components/ui/data-table.tsx +235 -0
  73. package/components/ui/dialog.tsx +173 -0
  74. package/components/ui/dropdown.tsx +78 -0
  75. package/components/ui/feature-card.tsx +38 -0
  76. package/components/ui/input.tsx +44 -0
  77. package/components/ui/label.tsx +110 -0
  78. package/components/ui/loaders.tsx +139 -0
  79. package/components/ui/menu.tsx +118 -0
  80. package/components/ui/modal.tsx +399 -0
  81. package/components/ui/package-manager-tabs.tsx +40 -0
  82. package/components/ui/pagination.tsx +200 -0
  83. package/components/ui/progress.tsx +134 -0
  84. package/components/ui/radio.tsx +262 -0
  85. package/components/ui/skeleton.tsx +102 -0
  86. package/components/ui/steppers.tsx +309 -0
  87. package/components/ui/switch.tsx +153 -0
  88. package/components/ui/table.tsx +58 -0
  89. package/components/ui/tabs.tsx +166 -0
  90. package/components/ui/theme-toggle.tsx +60 -0
  91. package/components/ui/tooltip.tsx +238 -0
  92. package/data/color-palette.ts +35 -0
  93. package/data/docs-nav.ts +84 -0
  94. package/eslint.config.mjs +18 -0
  95. package/index.ts +8 -0
  96. package/lib/cn.ts +4 -0
  97. package/lib/color.ts +85 -0
  98. package/lib/og-image.tsx +138 -0
  99. package/lib/theme.ts +33 -0
  100. package/next.config.ts +7 -0
  101. package/package.json +30 -0
  102. package/postcss.config.mjs +7 -0
  103. package/public/dark.png +0 -0
  104. package/public/dark1.png +0 -0
  105. package/public/dark2.png +0 -0
  106. package/public/file.svg +1 -0
  107. package/public/globe.svg +1 -0
  108. package/public/light.png +0 -0
  109. package/public/light1.png +0 -0
  110. package/public/next.svg +1 -0
  111. package/public/vercel.svg +1 -0
  112. package/public/video/hero-demo.mp4 +0 -0
  113. package/public/window.svg +1 -0
  114. package/tsconfig.json +34 -0
@@ -0,0 +1,316 @@
1
+ "use client";
2
+
3
+ import React from "react";
4
+ import { Check, Copy, FileText, MoreHorizontal } from "lucide-react";
5
+ import { Pagination, type PaginationProps } from "@/components/ui/pagination";
6
+ import { Card } from "@/components/ui/card";
7
+ import { Tooltip } from "@/components/ui/tooltip";
8
+ import {
9
+ DocsAccessibility,
10
+ DocsApiSection,
11
+ DocsApiTable,
12
+ DocsDemoPanel,
13
+ DocsPage,
14
+ DocsPageHeader,
15
+ DocsSection,
16
+ DocsSectionGrid,
17
+ DocsSubsection,
18
+ } from "@/components/docs/docs-page";
19
+ import { cn } from "@/lib/cn";
20
+
21
+ const API_ROWS = [
22
+ { prop: "page", type: "number", default: "—", description: "The current active page (1-indexed)" },
23
+ { prop: "totalPages", type: "number", default: "—", description: "The total number of pages" },
24
+ { prop: "onPageChange", type: "(page: number) => void", default: "—", description: "Called when the user selects a page" },
25
+ { prop: "siblingCount", type: "number", default: "1", description: "Page buttons shown on either side of the current page" },
26
+ { prop: "variant", type: '"default" | "simple"', default: '"default"', description: "Numbered page buttons, or a minimal previous/next control" },
27
+ { prop: "size", type: '"small" | "half" | "full"', default: '"small"', description: "How much horizontal space the control takes up — content width, half, or full width of its container" },
28
+ { prop: "className", type: "string", default: "—", description: "Additional CSS classes" },
29
+ ];
30
+
31
+ const ACCESSIBILITY_ITEMS = [
32
+ "The root <nav> carries aria-label=\"Pagination\" so assistive tech can identify the control.",
33
+ "The active page button is marked with aria-current=\"page\".",
34
+ "Previous and Next disable at the first and last page instead of wrapping around.",
35
+ "Ellipsis markers are decorative and hidden from screen readers.",
36
+ "Prefer the simple variant on narrow viewports where numbered buttons would wrap awkwardly.",
37
+ ];
38
+
39
+ type PlaygroundVariant = NonNullable<PaginationProps["variant"]>;
40
+ type PlaygroundSize = NonNullable<PaginationProps["size"]>;
41
+
42
+ const PLAYGROUND_VARIANTS: { value: PlaygroundVariant; label: string }[] = [
43
+ { value: "default", label: "Default" },
44
+ { value: "simple", label: "Simple" },
45
+ ];
46
+
47
+ const PLAYGROUND_SIZES: PlaygroundSize[] = ["small", "half", "full"];
48
+
49
+ const PLAYGROUND_TOTAL_PAGES = [5, 10, 20, 50];
50
+
51
+ function codeFor(page: number, totalPages: number, variant: PlaygroundVariant, size: PlaygroundSize) {
52
+ const props = [
53
+ `page={${page}}`,
54
+ `totalPages={${totalPages}}`,
55
+ "onPageChange={setPage}",
56
+ variant !== "default" && `variant="${variant}"`,
57
+ size !== "small" && `size="${size}"`,
58
+ ].filter(Boolean);
59
+ return `<Pagination\n ${props.join("\n ")}\n/>`;
60
+ }
61
+
62
+ const SEARCH_RESULTS = [
63
+ "Getting started with ruler.ui",
64
+ "Installing the CLI",
65
+ "Theming your design tokens",
66
+ "Building accessible forms",
67
+ "Customizing the Button component",
68
+ "Dark mode best practices",
69
+ "Data Table search and filters",
70
+ "Writing your first component",
71
+ "Migrating from v1 to v2",
72
+ "Understanding the Card variants",
73
+ "Icon usage guidelines",
74
+ "Typography scale reference",
75
+ "Spacing and layout primitives",
76
+ "Building a settings page",
77
+ "Handling async loading states",
78
+ "Composing Dropdown menus",
79
+ "Keyboard navigation patterns",
80
+ "Testing your components",
81
+ "Publishing to npm",
82
+ "Contributing guidelines",
83
+ ];
84
+ const RESULTS_PAGE_SIZE = 5;
85
+
86
+ export function PaginationDocPage() {
87
+ const [playgroundPage, setPlaygroundPage] = React.useState(4);
88
+ const [playgroundTotalPages, setPlaygroundTotalPages] = React.useState(10);
89
+ const [playgroundVariant, setPlaygroundVariant] = React.useState<PlaygroundVariant>("default");
90
+ const [playgroundSize, setPlaygroundSize] = React.useState<PlaygroundSize>("small");
91
+ const [copied, setCopied] = React.useState(false);
92
+
93
+ const playgroundSnippet = codeFor(playgroundPage, playgroundTotalPages, playgroundVariant, playgroundSize);
94
+
95
+ function copySnippet() {
96
+ navigator.clipboard.writeText(playgroundSnippet).catch(() => {});
97
+ setCopied(true);
98
+ setTimeout(() => setCopied(false), 1200);
99
+ }
100
+
101
+ function setPlaygroundTotal(total: number) {
102
+ setPlaygroundTotalPages(total);
103
+ setPlaygroundPage((p) => Math.min(p, total));
104
+ }
105
+
106
+ const [defaultPage, setDefaultPage] = React.useState(4);
107
+ const [simplePage, setSimplePage] = React.useState(2);
108
+ const [siblingPageA, setSiblingPageA] = React.useState(6);
109
+ const [siblingPageB, setSiblingPageB] = React.useState(6);
110
+ const [resultsPage, setResultsPage] = React.useState(1);
111
+ const [smallSizePage, setSmallSizePage] = React.useState(3);
112
+ const [halfSizePage, setHalfSizePage] = React.useState(3);
113
+ const [fullSizePage, setFullSizePage] = React.useState(3);
114
+
115
+ const resultsTotalPages = Math.ceil(SEARCH_RESULTS.length / RESULTS_PAGE_SIZE);
116
+ const pagedResults = SEARCH_RESULTS.slice(
117
+ (resultsPage - 1) * RESULTS_PAGE_SIZE,
118
+ resultsPage * RESULTS_PAGE_SIZE,
119
+ );
120
+
121
+ return (
122
+ <DocsPage>
123
+ <DocsPageHeader
124
+ icon={MoreHorizontal}
125
+ title="Pagination"
126
+ description="Lets people move through paged content — numbered pages, or a minimal previous/next control."
127
+ />
128
+
129
+ <DocsSection
130
+ first
131
+ title="Playground"
132
+ description="Build a pagination control and copy the exact markup — every combination, live."
133
+ >
134
+ <div className="overflow-hidden rounded-2xl border border-zinc-200 shadow-[0_2px_8px_rgba(0,0,0,0.04)] dark:border-zinc-800 dark:shadow-[0_2px_8px_rgba(0,0,0,0.2)]">
135
+ <div className="relative flex min-h-[11rem] items-center justify-center overflow-hidden bg-zinc-50 p-6 dark:bg-zinc-900/40">
136
+ <div
137
+ aria-hidden
138
+ className="pointer-events-none absolute inset-0 opacity-[0.4] dark:opacity-[0.15]"
139
+ style={{
140
+ backgroundImage:
141
+ "linear-gradient(to right, rgb(161 161 170 / 0.35) 1px, transparent 1px), linear-gradient(to bottom, rgb(161 161 170 / 0.35) 1px, transparent 1px)",
142
+ backgroundSize: "24px 24px",
143
+ }}
144
+ />
145
+ <div className="relative w-full max-w-md">
146
+ <Pagination
147
+ page={playgroundPage}
148
+ totalPages={playgroundTotalPages}
149
+ onPageChange={setPlaygroundPage}
150
+ variant={playgroundVariant}
151
+ size={playgroundSize}
152
+ />
153
+ </div>
154
+ </div>
155
+
156
+ <div className="flex flex-col gap-5 border-t border-zinc-200 p-5 dark:border-zinc-800">
157
+ <div className="flex flex-wrap items-start justify-between gap-6">
158
+ <div>
159
+ <p className="mb-2 text-xs font-medium uppercase tracking-wide text-zinc-400 dark:text-zinc-500">
160
+ Variant
161
+ </p>
162
+ <div className="flex flex-wrap items-center gap-1 rounded-lg border border-zinc-200 bg-zinc-50 p-1 dark:border-zinc-800 dark:bg-zinc-900/60">
163
+ {PLAYGROUND_VARIANTS.map((v) => (
164
+ <button
165
+ key={v.value}
166
+ type="button"
167
+ onClick={() => setPlaygroundVariant(v.value)}
168
+ className={cn(
169
+ "rounded-md px-3 py-1.5 text-xs font-medium uppercase tracking-wide transition-colors",
170
+ playgroundVariant === v.value
171
+ ? "bg-white text-zinc-900 shadow-sm dark:bg-zinc-800 dark:text-white"
172
+ : "text-zinc-500 hover:text-zinc-800 dark:text-zinc-400 dark:hover:text-zinc-200"
173
+ )}
174
+ >
175
+ {v.label}
176
+ </button>
177
+ ))}
178
+ </div>
179
+ </div>
180
+
181
+ <div>
182
+ <p className="mb-2 text-xs font-medium uppercase tracking-wide text-zinc-400 dark:text-zinc-500">
183
+ Size
184
+ </p>
185
+ <div className="flex flex-wrap items-center gap-1 rounded-lg border border-zinc-200 bg-zinc-50 p-1 dark:border-zinc-800 dark:bg-zinc-900/60">
186
+ {PLAYGROUND_SIZES.map((s) => (
187
+ <button
188
+ key={s}
189
+ type="button"
190
+ onClick={() => setPlaygroundSize(s)}
191
+ className={cn(
192
+ "rounded-md px-3 py-1.5 text-xs font-medium uppercase tracking-wide transition-colors",
193
+ playgroundSize === s
194
+ ? "bg-white text-zinc-900 shadow-sm dark:bg-zinc-800 dark:text-white"
195
+ : "text-zinc-500 hover:text-zinc-800 dark:text-zinc-400 dark:hover:text-zinc-200"
196
+ )}
197
+ >
198
+ {s}
199
+ </button>
200
+ ))}
201
+ </div>
202
+ </div>
203
+
204
+ <div>
205
+ <p className="mb-2 text-xs font-medium uppercase tracking-wide text-zinc-400 dark:text-zinc-500">
206
+ Total pages
207
+ </p>
208
+ <div className="flex flex-wrap items-center gap-1 rounded-lg border border-zinc-200 bg-zinc-50 p-1 dark:border-zinc-800 dark:bg-zinc-900/60">
209
+ {PLAYGROUND_TOTAL_PAGES.map((total) => (
210
+ <button
211
+ key={total}
212
+ type="button"
213
+ onClick={() => setPlaygroundTotal(total)}
214
+ className={cn(
215
+ "rounded-md px-3 py-1.5 text-xs font-medium tabular-nums transition-colors",
216
+ playgroundTotalPages === total
217
+ ? "bg-white text-zinc-900 shadow-sm dark:bg-zinc-800 dark:text-white"
218
+ : "text-zinc-500 hover:text-zinc-800 dark:text-zinc-400 dark:hover:text-zinc-200"
219
+ )}
220
+ >
221
+ {total}
222
+ </button>
223
+ ))}
224
+ </div>
225
+ </div>
226
+ </div>
227
+
228
+ <div className="flex items-center justify-between gap-3 rounded-xl bg-zinc-900 px-4 py-3 dark:bg-black">
229
+ <pre className="overflow-x-auto font-mono text-[13px] leading-relaxed text-zinc-100">
230
+ <code>{playgroundSnippet}</code>
231
+ </pre>
232
+ <Tooltip content={copied ? "Copied!" : "Copy code"}>
233
+ <button
234
+ type="button"
235
+ onClick={copySnippet}
236
+ className="flex h-8 w-8 shrink-0 items-center justify-center rounded-lg text-zinc-400 transition-colors hover:bg-white/10 hover:text-white"
237
+ >
238
+ {copied ? <Check className="h-4 w-4 text-emerald-400" /> : <Copy className="h-4 w-4" />}
239
+ </button>
240
+ </Tooltip>
241
+ </div>
242
+ </div>
243
+ </div>
244
+ </DocsSection>
245
+
246
+ <DocsSection
247
+ title="Default"
248
+ description="Numbered page buttons with automatic ellipses for long ranges."
249
+ >
250
+ <DocsDemoPanel>
251
+ <Pagination page={defaultPage} totalPages={12} onPageChange={setDefaultPage} />
252
+ </DocsDemoPanel>
253
+ </DocsSection>
254
+
255
+ <DocsSection
256
+ title="Sizes"
257
+ description="Control how much horizontal space the control takes up — content width, half, or full width of its container."
258
+ contentClassName="flex flex-col gap-6"
259
+ >
260
+ <DocsSubsection title="Small" description="Shrinks to fit its content — the default, ideal for inline placement.">
261
+ <Pagination size="small" page={smallSizePage} totalPages={8} onPageChange={setSmallSizePage} />
262
+ </DocsSubsection>
263
+ <DocsSubsection title="Half" description="Fills half of its container width.">
264
+ <Pagination size="half" page={halfSizePage} totalPages={8} onPageChange={setHalfSizePage} />
265
+ </DocsSubsection>
266
+ <DocsSubsection title="Full" description="Stretches to fill its container — great for table and card footers.">
267
+ <Pagination size="full" page={fullSizePage} totalPages={8} onPageChange={setFullSizePage} />
268
+ </DocsSubsection>
269
+ </DocsSection>
270
+
271
+ <DocsSection title="Simple" description="A compact previous/next control with a page indicator — ideal for tight spaces.">
272
+ <DocsDemoPanel>
273
+ <Pagination variant="simple" page={simplePage} totalPages={5} onPageChange={setSimplePage} className="w-full max-w-sm" />
274
+ </DocsDemoPanel>
275
+ </DocsSection>
276
+
277
+ <DocsSection title="Sibling Count" description="Control how many page buttons show on either side of the current page.">
278
+ <DocsSectionGrid>
279
+ <DocsSubsection title="siblingCount={0}" description="Only the current page, first, last, and ellipses.">
280
+ <Pagination page={siblingPageA} totalPages={20} onPageChange={setSiblingPageA} siblingCount={0} />
281
+ </DocsSubsection>
282
+ <DocsSubsection title="siblingCount={2}" description="Two pages on either side of the current page.">
283
+ <Pagination page={siblingPageB} totalPages={20} onPageChange={setSiblingPageB} siblingCount={2} />
284
+ </DocsSubsection>
285
+ </DocsSectionGrid>
286
+ </DocsSection>
287
+
288
+ <DocsSection title="In Context" description="Pagination works with any list, not just tables.">
289
+ <Card className="max-w-lg p-2">
290
+ <ul className="flex flex-col">
291
+ {pagedResults.map((result) => (
292
+ <li
293
+ key={result}
294
+ className="flex items-center gap-3 rounded-lg px-3 py-2.5 text-sm text-zinc-700 hover:bg-zinc-50 dark:text-zinc-300 dark:hover:bg-zinc-800/60"
295
+ >
296
+ <FileText className="h-4 w-4 shrink-0 text-zinc-400" />
297
+ {result}
298
+ </li>
299
+ ))}
300
+ </ul>
301
+ <div className="flex items-center justify-between gap-3 border-t border-zinc-100 px-3 pt-3 dark:border-zinc-800">
302
+ <p className="text-xs text-zinc-500 dark:text-zinc-400">
303
+ {SEARCH_RESULTS.length} results
304
+ </p>
305
+ <Pagination page={resultsPage} totalPages={resultsTotalPages} onPageChange={setResultsPage} siblingCount={0} />
306
+ </div>
307
+ </Card>
308
+ </DocsSection>
309
+
310
+ <DocsApiSection>
311
+ <DocsApiTable title="API Reference" rows={API_ROWS} />
312
+ <DocsAccessibility items={ACCESSIBILITY_ITEMS} />
313
+ </DocsApiSection>
314
+ </DocsPage>
315
+ );
316
+ }