@nayhoo/ui 0.3.1 → 0.4.1

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/README.md ADDED
@@ -0,0 +1,138 @@
1
+ # @nayhoo/ui
2
+
3
+ A collection of React components, built with [Radix Primitives](https://www.radix-ui.com/primitives), styled with [vanilla-extract](https://vanilla-extract.style).
4
+
5
+ ## Installation
6
+
7
+ ```sh
8
+ npm install @nayhoo/ui
9
+ ```
10
+
11
+ ## Configuration
12
+
13
+ ### Next.js
14
+
15
+ ```sh
16
+ npm install @vanilla-extract/next-plugin
17
+ ```
18
+
19
+ ```ts
20
+ // next.config.ts
21
+
22
+ import { createVanillaExtractPlugin } from "@vanilla-extract/next-plugin";
23
+ import type { NextConfig } from "next";
24
+
25
+ const withVanillaExtract = createVanillaExtractPlugin();
26
+
27
+ const nextConfig: NextConfig = {
28
+ // https://vanilla-extract.style/documentation/integrations/next/
29
+ transpilePackages: ["@nayhoo/ui"],
30
+ };
31
+
32
+ export default withVanillaExtract(nextConfig);
33
+ ```
34
+
35
+ ```tsx
36
+ // src/app/layout.tsx
37
+
38
+ import "@nayhoo/ui/css"; // REQUIRED
39
+ import type { Metadata } from "next";
40
+ import "./globals.css";
41
+ import { AppProvider } from "./provider";
42
+
43
+ export const metadata: Metadata = {
44
+ title: "Create Next App",
45
+ description: "Generated by create next app",
46
+ };
47
+
48
+ export default function RootLayout({
49
+ children,
50
+ }: Readonly<{
51
+ children: React.ReactNode;
52
+ }>) {
53
+ return (
54
+ <html lang="en">
55
+ <body>
56
+ <AppProvider>{children}</AppProvider>
57
+ </body>
58
+ </html>
59
+ );
60
+ }
61
+ ```
62
+
63
+ ```tsx
64
+ // src/app/provider.tsx
65
+
66
+ "use client";
67
+
68
+ import { ThemeProvider } from "@nayhoo/ui/providers";
69
+ import React from "react";
70
+
71
+ type AppProviderProps = {
72
+ children: React.ReactNode;
73
+ };
74
+
75
+ export const AppProvider = ({ children }: AppProviderProps) => {
76
+ return <ThemeProvider>{children}</ThemeProvider>;
77
+ };
78
+ ```
79
+
80
+ ### Vite
81
+
82
+ ```sh
83
+ npm install @vanilla-extract/vite-plugin
84
+ ```
85
+
86
+ ```ts
87
+ // vite.config.ts
88
+
89
+ import { vanillaExtractPlugin } from "@vanilla-extract/vite-plugin";
90
+ import react from "@vitejs/plugin-react";
91
+ import { defineConfig } from "vite";
92
+
93
+ // https://vite.dev/config/
94
+ export default defineConfig({
95
+ plugins: [react(), vanillaExtractPlugin()],
96
+ optimizeDeps: {
97
+ include: ["@nayhoo/ui"],
98
+ },
99
+ });
100
+ ```
101
+
102
+ ```tsx
103
+ // src/main.tsx
104
+
105
+ import "@nayhoo/ui/css"; // REQUIRED
106
+ import { StrictMode } from "react";
107
+ import { createRoot } from "react-dom/client";
108
+ import "./index.css";
109
+ import App from "./App.tsx";
110
+
111
+ createRoot(document.getElementById("root")!).render(
112
+ <StrictMode>
113
+ <App />
114
+ </StrictMode>,
115
+ );
116
+ ```
117
+
118
+ ```tsx
119
+ // src/app.tsx
120
+
121
+ import { ThemeProvider } from "@nayhoo/ui/providers";
122
+
123
+ function App({ children }: { children: React.ReactNode }) {
124
+ return <ThemeProvider>{children}</ThemeProvider>;
125
+ }
126
+ ```
127
+
128
+ ## Usage
129
+
130
+ ```tsx
131
+ "use client";
132
+
133
+ import { Button } from "@nayhoo/ui";
134
+
135
+ export const Component = () => {
136
+ return <Button onClick={() => alert("Hello!")}>Press me</Button>;
137
+ };
138
+ ```