Skip to content

Commit 0cd42ac

Browse files
authored
feat: update to tailwindcss v4 (#123)
* feat: update to tailwindcss v4 * Fix slack preview * Better previews
1 parent b8f612b commit 0cd42ac

File tree

10 files changed

+386
-400
lines changed

10 files changed

+386
-400
lines changed

apps/dashboard/package.json

+2-3
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,13 @@
4343
"@next/eslint-plugin-next": "15.2.0",
4444
"@ogstudio/eslint": "workspace:*",
4545
"@ogstudio/typescript": "workspace:*",
46+
"@tailwindcss/postcss": "^4.0.9",
4647
"@types/node": "^20",
4748
"@types/react": "19.0.7",
4849
"@types/react-dom": "19.0.3",
49-
"autoprefixer": "^10.4.19",
5050
"happy-dom": "^14.7.1",
5151
"postcss": "^8.4.38",
52-
"postcss-import": "^16.1.0",
53-
"tailwindcss": "^3.4.3",
52+
"tailwindcss": "^4.0.9",
5453
"tsx": "^4.19.0",
5554
"vitest": "^1.6.0"
5655
}

apps/dashboard/postcss.config.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
module.exports = {
22
plugins: {
3-
'postcss-import': {},
4-
tailwindcss: {},
5-
autoprefixer: {},
3+
'@tailwindcss/postcss': {},
64
},
75
}

apps/dashboard/src/app/globals.css

+27-16
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,38 @@
1-
@import url('https://fonts.bunny.net/css?family=inter:400');
2-
@import "tailwindcss/base";
3-
@import "@radix-ui/themes/styles.css";
4-
5-
@tailwind components;
6-
@tailwind utilities;
1+
@import url('https://fonts.bunny.net/css?family=inter:400') layer(base);
2+
@import 'tailwindcss';
3+
@import '@radix-ui/themes/styles.css' layer(base);
4+
5+
/*
6+
The default border color has changed to `currentColor` in Tailwind CSS v4,
7+
so we've added these compatibility styles to make sure everything still
8+
looks the same as it did with Tailwind CSS v3.
9+
10+
If we ever want to remove these styles, we need to add an explicit border
11+
color utility to any element that depends on these defaults.
12+
*/
13+
@layer base {
14+
*,
15+
::after,
16+
::before,
17+
::backdrop,
18+
::file-selector-button {
19+
border-color: var(--color-gray-200, currentColor);
20+
}
21+
}
722

823
/**
924
* https://github.com/tailwindlabs/tailwindcss/discussions/2394
1025
* https://github.com/tailwindlabs/tailwindcss/pull/5732
1126
*/
12-
@layer utilities {
13-
27+
@utility no-scrollbar {
1428
/* Chrome, Safari and Opera */
15-
.no-scrollbar::-webkit-scrollbar {
29+
&::-webkit-scrollbar {
1630
display: none;
1731
}
18-
19-
.no-scrollbar {
20-
-ms-overflow-style: none;
21-
/* IE and Edge */
22-
scrollbar-width: none;
23-
/* Firefox */
24-
}
32+
-ms-overflow-style: none;
33+
/* IE and Edge */
34+
scrollbar-width: none;
35+
/* Firefox */
2536
}
2637

2738
input[type=number] {

apps/dashboard/src/components/Element.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -315,10 +315,10 @@ export function Element({ element }: ElementProps) {
315315
<ContextMenu.Trigger>
316316
<div
317317
className={clsx(
318-
"element cursor-default select-none outline-1 outline-offset-[3px] hover:outline",
318+
"element cursor-default select-none outline-offset-[3px] hover:outline",
319319
{ "outline cursor-move": isSelected },
320-
{ "!outline !cursor-text": isEditing },
321-
{ "!outline-dashed": element.tag === "span" },
320+
{ "outline cursor-text!": isEditing },
321+
{ "outline-dashed outline-1": element.tag === "span" },
322322
)}
323323
id={`element-${element.id}`}
324324
style={style.elementStyle}

apps/dashboard/src/components/ExportModal/ExportURL.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export function ExportURL({ exportedKey, dynamicTexts }: ExportURLProps) {
2424
const { data } = useUser();
2525
const isSignedIn = Boolean(data && "user" in data);
2626

27-
const key = exportedKey ?? <span className="blur-sm">{"x".repeat(32)}</span>;
27+
const key = exportedKey ?? <span className="blur-xs">{"x".repeat(32)}</span>;
2828
let url = (
2929
<>
3030
{typeof window !== "undefined" ? window.location.origin : ""}/api/og/{key}

apps/dashboard/src/components/ExportModal/Preview.tsx

+15-9
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import { Flex, Heading, Text, TextField } from "@radix-ui/themes";
2-
import { startTransition } from "react";
1+
import { Flex, Heading, Skeleton, Text, TextField } from "@radix-ui/themes";
2+
import { startTransition, useEffect, useState } from "react";
33
import { OgImage } from "../OgImage";
44
import { useElementsStore } from "../../stores/elementsStore";
55
import { usePreviewControls } from "../../lib/hooks/usePreviewControls";
6+
import { renderToImg } from "../../lib/export";
67

78
interface PreviewProps {
89
dynamicTexts: Record<string, string>;
@@ -12,6 +13,15 @@ interface PreviewProps {
1213
export function Preview({ dynamicTexts, setDynamicTexts }: PreviewProps) {
1314
const { preview, PreviewControls } = usePreviewControls();
1415
const elements = useElementsStore((state) => state.elements);
16+
const [src, setSrc] = useState<string | undefined>();
17+
18+
useEffect(() => {
19+
async function render() {
20+
setSrc(await renderToImg(elements, dynamicTexts));
21+
}
22+
23+
void render();
24+
}, [elements, dynamicTexts]);
1525

1626
return (
1727
<Flex direction="column" gap="4">
@@ -21,13 +31,9 @@ export function Preview({ dynamicTexts, setDynamicTexts }: PreviewProps) {
2131
<Flex gap="6" justify="between" align="start" minHeight="353px">
2232
<Flex direction="column" gap="2">
2333
<PreviewControls />
24-
<OgImage
25-
client
26-
dynamicTexts={dynamicTexts}
27-
elements={elements}
28-
preview={preview}
29-
size="medium"
30-
/>
34+
<OgImage preview={preview} size="medium" src={src}>
35+
{src ? null : <Skeleton height="10%" width="60%" />}
36+
</OgImage>
3137
</Flex>
3238
<Flex direction="column" flexGrow="1" gap="4" mt="7">
3339
{Object.keys(dynamicTexts).length === 0 ? (

apps/dashboard/src/components/LeftPanel/ElementRow.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ export const ElementRow = memo(({ element }: ElementRowProps) => {
145145
</Button>
146146
<IconButton
147147
className={clsx("opacity-0 group-hover:opacity-100", {
148-
"!opacity-100": !element.visible,
148+
"opacity-100!": !element.visible,
149149
})}
150150
color="gray"
151151
mr="1"

apps/dashboard/src/components/OgImage.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ export function OgImage({
116116
return function Wrapper(props: { children: ReactNode }) {
117117
return (
118118
<Flex gap="3" className="w-[480px]">
119-
<div className="bg-[#DDDDDD] dark:bg-[#35373B] min-w-1 h-full rounded" />
119+
<div className="bg-[#DDDDDD] dark:bg-[#35373B] min-w-1 h-min-content rounded-sm" />
120120
<Flex direction="column" className="gap-0.5">
121121
<p className="text-[#1D1C1D] dark:text-[#D1D2D3] text-[15px] font-black">
122122
{previewSite}
@@ -153,7 +153,7 @@ export function OgImage({
153153
<Tag
154154
className={clsx(
155155
className,
156-
"min-h-[157px] w-[300px] min-w-[300px] flex flex-col items-center justify-center rounded relative group overflow-hidden",
156+
"min-h-[157px] w-[300px] min-w-[300px] flex flex-col items-center justify-center rounded-sm relative group overflow-hidden",
157157
{
158158
"min-h-[157px] w-[300px] min-w-[300px]": size === "small",
159159
"min-h-[252px] w-[480px] min-w-[480px]": size === "medium",
@@ -233,7 +233,7 @@ export function OgImage({
233233
) : null}
234234
{preview === "x" ? (
235235
<span
236-
className="absolute bottom-2.5 left-2.5 text-white h-5 px-2 rounded text-[12px]"
236+
className="absolute bottom-2.5 left-2.5 text-white h-5 px-2 rounded-sm text-[12px]"
237237
style={{ backgroundColor: "rgba(0, 0, 0, 0.77)" }}
238238
>
239239
{previewTitle}

apps/dashboard/tailwind.config.ts

-11
This file was deleted.

0 commit comments

Comments
 (0)