Skip to content

Commit 8820d91

Browse files
committed
Add shadcn Tooltip
1 parent 1b5e689 commit 8820d91

File tree

8 files changed

+227
-3
lines changed

8 files changed

+227
-3
lines changed

.prettierrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2-
"proseWrap": "always"
2+
"proseWrap": "always",
3+
"plugins": ["prettier-plugin-tailwindcss"]
34
}

components.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"$schema": "https://ui.shadcn.com/schema.json",
3+
"style": "new-york",
4+
"rsc": false,
5+
"tsx": false,
6+
"tailwind": {
7+
"config": "tailwind.config.js",
8+
"css": "./src/pages/global.css",
9+
"baseColor": "neutral",
10+
"cssVariables": true,
11+
"prefix": ""
12+
},
13+
"aliases": {
14+
"components": "@/components",
15+
"utils": "@/lib/utils"
16+
}
17+
}

package.json

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,27 @@
88
"start": "next start"
99
},
1010
"dependencies": {
11+
"@radix-ui/react-icons": "^1.3.0",
12+
"@radix-ui/react-tooltip": "^1.0.7",
13+
"class-variance-authority": "^0.7.0",
14+
"clsx": "^2.1.1",
1115
"next": "^14.2.2",
1216
"nextra": "^2.13.4",
1317
"nextra-theme-docs": "^2.13.4",
1418
"react": "^18.2.0",
1519
"react-dom": "^18.2.0",
16-
"sharp": "^0.33.3"
20+
"sharp": "^0.33.3",
21+
"tailwind-merge": "^2.3.0",
22+
"tailwindcss-animate": "^1.0.7"
1723
},
1824
"devDependencies": {
25+
"autoprefixer": "^10.4.19",
1926
"git-format-staged": "^3.1.1",
2027
"gray-matter": "^4.0.3",
2128
"husky": "^9.0.11",
22-
"prettier": "3.2.5"
29+
"postcss": "^8.4.38",
30+
"prettier": "3.2.5",
31+
"prettier-plugin-tailwindcss": "^0.5.14",
32+
"tailwindcss": "^3.4.3"
2333
}
2434
}

postcss.config.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
plugins: {
3+
tailwindcss: {},
4+
autoprefixer: {},
5+
},
6+
};

src/components/ui/tooltip.jsx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import * as React from "react";
2+
import * as TooltipPrimitive from "@radix-ui/react-tooltip";
3+
4+
import { cn } from "@/lib/utils";
5+
6+
const TooltipProvider = TooltipPrimitive.Provider;
7+
8+
const Tooltip = TooltipPrimitive.Root;
9+
10+
const TooltipTrigger = TooltipPrimitive.Trigger;
11+
12+
const TooltipContent = React.forwardRef(
13+
({ className, sideOffset = 4, ...props }, ref) => (
14+
<TooltipPrimitive.Content
15+
ref={ref}
16+
sideOffset={sideOffset}
17+
className={cn(
18+
"z-50 overflow-hidden rounded-md bg-primary px-3 py-1.5 text-xs text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 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",
19+
className,
20+
)}
21+
{...props}
22+
/>
23+
),
24+
);
25+
TooltipContent.displayName = TooltipPrimitive.Content.displayName;
26+
27+
export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider };

src/lib/utils.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { clsx } from "clsx";
2+
import { twMerge } from "tailwind-merge";
3+
4+
export function cn(...inputs) {
5+
return twMerge(clsx(inputs));
6+
}

src/pages/global.css

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,80 @@
1+
@tailwind base;
2+
@tailwind components;
3+
@tailwind utilities;
4+
5+
@layer base {
6+
:root {
7+
--background: 0 0% 100%;
8+
--foreground: 0 0% 3.9%;
9+
10+
--card: 0 0% 100%;
11+
--card-foreground: 0 0% 3.9%;
12+
13+
--popover: 0 0% 100%;
14+
--popover-foreground: 0 0% 3.9%;
15+
16+
--primary: 0 0% 9%;
17+
--primary-foreground: 0 0% 98%;
18+
19+
--secondary: 0 0% 96.1%;
20+
--secondary-foreground: 0 0% 9%;
21+
22+
--muted: 0 0% 96.1%;
23+
--muted-foreground: 0 0% 45.1%;
24+
25+
--accent: 0 0% 96.1%;
26+
--accent-foreground: 0 0% 9%;
27+
28+
--destructive: 0 84.2% 60.2%;
29+
--destructive-foreground: 0 0% 98%;
30+
31+
--border: 0 0% 89.8%;
32+
--input: 0 0% 89.8%;
33+
--ring: 0 0% 3.9%;
34+
35+
--radius: 0.5rem;
36+
}
37+
38+
.dark {
39+
--background: 0 0% 3.9%;
40+
--foreground: 0 0% 98%;
41+
42+
--card: 0 0% 3.9%;
43+
--card-foreground: 0 0% 98%;
44+
45+
--popover: 0 0% 3.9%;
46+
--popover-foreground: 0 0% 98%;
47+
48+
--primary: 0 0% 98%;
49+
--primary-foreground: 0 0% 9%;
50+
51+
--secondary: 0 0% 14.9%;
52+
--secondary-foreground: 0 0% 98%;
53+
54+
--muted: 0 0% 14.9%;
55+
--muted-foreground: 0 0% 63.9%;
56+
57+
--accent: 0 0% 14.9%;
58+
--accent-foreground: 0 0% 98%;
59+
60+
--destructive: 0 62.8% 30.6%;
61+
--destructive-foreground: 0 0% 98%;
62+
63+
--border: 0 0% 14.9%;
64+
--input: 0 0% 14.9%;
65+
--ring: 0 0% 83.1%;
66+
}
67+
}
68+
69+
@layer base {
70+
* {
71+
@apply border-border;
72+
}
73+
body {
74+
@apply bg-background text-foreground;
75+
}
76+
}
77+
178
/* Hide How to Doc directory on the sidebar */
279
li:has(a > .how-to-doc-dir),
380
/* Hide links to How to Doc index, except the prevLink on the page after that */

tailwind.config.js

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/** @type {import('tailwindcss').Config} */
2+
module.exports = {
3+
darkMode: ["class"],
4+
content: [
5+
"./pages/**/*.{js,jsx}",
6+
"./components/**/*.{js,jsx}",
7+
"./app/**/*.{js,jsx}",
8+
"./src/**/*.{js,jsx}",
9+
],
10+
prefix: "",
11+
theme: {
12+
container: {
13+
center: true,
14+
padding: "2rem",
15+
screens: {
16+
"2xl": "1400px",
17+
},
18+
},
19+
extend: {
20+
colors: {
21+
border: "hsl(var(--border))",
22+
input: "hsl(var(--input))",
23+
ring: "hsl(var(--ring))",
24+
background: "hsl(var(--background))",
25+
foreground: "hsl(var(--foreground))",
26+
primary: {
27+
DEFAULT: "hsl(var(--primary))",
28+
foreground: "hsl(var(--primary-foreground))",
29+
},
30+
secondary: {
31+
DEFAULT: "hsl(var(--secondary))",
32+
foreground: "hsl(var(--secondary-foreground))",
33+
},
34+
destructive: {
35+
DEFAULT: "hsl(var(--destructive))",
36+
foreground: "hsl(var(--destructive-foreground))",
37+
},
38+
muted: {
39+
DEFAULT: "hsl(var(--muted))",
40+
foreground: "hsl(var(--muted-foreground))",
41+
},
42+
accent: {
43+
DEFAULT: "hsl(var(--accent))",
44+
foreground: "hsl(var(--accent-foreground))",
45+
},
46+
popover: {
47+
DEFAULT: "hsl(var(--popover))",
48+
foreground: "hsl(var(--popover-foreground))",
49+
},
50+
card: {
51+
DEFAULT: "hsl(var(--card))",
52+
foreground: "hsl(var(--card-foreground))",
53+
},
54+
},
55+
borderRadius: {
56+
lg: "var(--radius)",
57+
md: "calc(var(--radius) - 2px)",
58+
sm: "calc(var(--radius) - 4px)",
59+
},
60+
keyframes: {
61+
"accordion-down": {
62+
from: { height: "0" },
63+
to: { height: "var(--radix-accordion-content-height)" },
64+
},
65+
"accordion-up": {
66+
from: { height: "var(--radix-accordion-content-height)" },
67+
to: { height: "0" },
68+
},
69+
},
70+
animation: {
71+
"accordion-down": "accordion-down 0.2s ease-out",
72+
"accordion-up": "accordion-up 0.2s ease-out",
73+
},
74+
transitionProperty: {
75+
spacing: "margin, padding",
76+
},
77+
},
78+
},
79+
plugins: [require("tailwindcss-animate")],
80+
};

0 commit comments

Comments
 (0)