[go: nahoru, domu]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEAT]: use RSCs in @dub/ui Fixes #572

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions apps/web/app/app.dub.co/(auth)/welcome/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Background } from "@dub/ui";
import { constructMetadata } from "@dub/utils";
import { Background } from "@dub/ui";
import { Suspense } from "react";
import WelcomePageClient from "./page-client";

Expand All @@ -11,11 +11,11 @@ export const metadata = constructMetadata({

export default function WelcomePage() {
return (
<>
<div className="flex h-screen flex-col items-center">
<Background />
<Suspense>
<Suspense fallback={null}>
<WelcomePageClient />
</Suspense>
</>
</div>
);
}
1 change: 1 addition & 0 deletions apps/web/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ module.exports = {
"@react-email/tailwind",
],
},
transpilePackages: ["@dub/ui"],
webpack: (config, { webpack, isServer }) => {
if (isServer) {
config.plugins.push(
Expand Down
4 changes: 3 additions & 1 deletion apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"dependencies": {
"@boxyhq/saml-jackson": "^1.14.2",
"@dub/tailwind-config": "workspace:*",
"@dub/ui": "workspace:*",
"@dub/utils": "workspace:*",
"@next-auth/prisma-adapter": "^1.0.5",
"@planetscale/database": "^1.7.0",
Expand Down Expand Up @@ -90,6 +89,9 @@
"zod-error": "^1.5.0",
"zod-openapi": "^2.12.0"
},
"peerDependencies": {
"@dub/ui": "workspace:*"
},
"devDependencies": {
"@types/dotenv-flow": "^3.3.2",
"@types/he": "^1.2.3",
Expand Down
15 changes: 15 additions & 0 deletions packages/ui/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,18 @@ To install the package, run:
```bash
pnpm i @dub/ui
```

### Transpiling

As of version `0.1.0` the package is not bundled, this means transpiling the module is
highly recommended, this was done to support React Server Components.

If you are using NextJS this is as simple as:

```js
// next.config.js
/** @type {import('next').NextConfig} */
module.exports = {
transpilePackages: ["@dub/ui"]
}
```
11 changes: 2 additions & 9 deletions packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,10 @@
"description": "UI components for Dub.co",
"version": "0.0.57",
"sideEffects": false,
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"files": [
"dist/**"
],
"main": "./src/index.tsx",
"types": "./src/index.tsx",
"scripts": {
"build": "tsup",
"lint": "eslint src/",
"dev": "tsup --watch",
"check-types": "tsc --noEmit"
},
"peerDependencies": {
Expand All @@ -31,7 +25,6 @@
"react": "^18.2.0",
"tailwindcss": "^3.3.3",
"tsconfig": "workspace:*",
"tsup": "^6.1.3",
"typescript": "^5.1.6"
},
"dependencies": {
Expand Down
2 changes: 2 additions & 0 deletions packages/ui/src/accordion.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use client"

import { cn } from "@dub/utils";
import * as AccordionPrimitive from "@radix-ui/react-accordion";
import { ChevronDown } from "lucide-react";
Expand Down
2 changes: 2 additions & 0 deletions packages/ui/src/form.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use client";

import { cn } from "@dub/utils";
import { InputHTMLAttributes, ReactNode, useMemo, useState } from "react";
import { Button } from "./button";
Expand Down
2 changes: 2 additions & 0 deletions packages/ui/src/hooks/use-cookies.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use client";

import Cookies from "js-cookie";
import { useEffect, useState } from "react";

Expand Down
2 changes: 2 additions & 0 deletions packages/ui/src/hooks/use-current-anchor.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use client";

import { useEffect, useState } from "react";

export default function useCurrentAnchor() {
Expand Down
2 changes: 2 additions & 0 deletions packages/ui/src/hooks/use-intersection-observer.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use client";

import { RefObject, useEffect, useState } from "react";

interface Args extends IntersectionObserverInit {
Expand Down
2 changes: 2 additions & 0 deletions packages/ui/src/hooks/use-local-storage.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use client";

import { useEffect, useState } from "react";

export default function useLocalStorage<T>(
Expand Down
2 changes: 2 additions & 0 deletions packages/ui/src/hooks/use-media-query.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use client";

import { useEffect, useState } from "react";

export default function useMediaQuery() {
Expand Down
2 changes: 2 additions & 0 deletions packages/ui/src/hooks/use-router-stuff.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use client";

import { usePathname, useRouter, useSearchParams } from "next/navigation";

export default function useRouterStuff() {
Expand Down
2 changes: 2 additions & 0 deletions packages/ui/src/hooks/use-scroll.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use client";

import { useCallback, useEffect, useState } from "react";

export default function useScroll(threshold: number) {
Expand Down
2 changes: 2 additions & 0 deletions packages/ui/src/hooks/use-toast-with-undo.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use client";

import { useEffect } from "react";
import { toast } from "sonner";
import Success from "../icons/success";
Expand Down
15 changes: 0 additions & 15 deletions packages/ui/tsup.config.ts

This file was deleted.

11 changes: 3 additions & 8 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.