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

Migrate to tailwind v4 #370

Merged
merged 1 commit into from
Mar 20, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
1,180 changes: 528 additions & 652 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,18 @@
"usehooks-ts": "^3.1.0"
},
"devDependencies": {
"@tailwindcss/postcss": "^4.0.14",
"@types/react": "^18.2.43",
"@types/react-dom": "^18.2.17",
"@vitejs/plugin-react": "^4.2.1",
"autoprefixer": "^10.4.16",
"eslint": "^8.55.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.5",
"postcss": "^8.4.32",
"prettier": "3.2.5",
"tailwindcss": "^3.3.6",
"tailwindcss": "^4.0.14",
"vite": "^5.4.1"
},
"overrides": {
Expand Down
3 changes: 1 addition & 2 deletions postcss.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
export default {
plugins: {
tailwindcss: {},
autoprefixer: {},
'@tailwindcss/postcss': {},
},
}
64 changes: 30 additions & 34 deletions src/components/EditorCanvas/Area.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,45 +105,41 @@ export default function Area({
onPointerDown={onPointerDown}
>
<div
className={`border-2 ${
className={`w-full h-full p-2 rounded cursor-move border-2 ${
isHovered
? "border-dashed border-blue-500"
: selectedElement.element === ObjectType.AREA &&
selectedElement.id === data.id
? "border-blue-500"
: "border-slate-400"
} w-full h-full cursor-move rounded`}
? "border-blue-500 opacity-100"
: "border-slate-400 opacity-100"
}`}
style={{ backgroundColor: `${data.color}66` }}
>
<div
className="w-fill p-2 h-full"
style={{ backgroundColor: `${data.color}66` }}
>
<div className="flex justify-between gap-1 w-full">
<div className="text-color select-none overflow-hidden text-ellipsis">
{data.name}
</div>
{(isHovered || (areaIsSelected() && !layout.sidebar)) && (
<Popover
visible={areaIsSelected() && !layout.sidebar}
onClickOutSide={onClickOutSide}
stopPropagation
content={<EditPopoverContent data={data} />}
trigger="custom"
position="rightTop"
showArrow
>
<Button
icon={<IconEdit />}
size="small"
theme="solid"
style={{
backgroundColor: "#2F68ADB3",
}}
onClick={edit}
/>
</Popover>
)}
<div className="flex justify-between gap-1 w-full">
<div className="text-color select-none overflow-hidden text-ellipsis">
{data.name}
</div>
{(isHovered || (areaIsSelected() && !layout.sidebar)) && (
<Popover
visible={areaIsSelected() && !layout.sidebar}
onClickOutSide={onClickOutSide}
stopPropagation
content={<EditPopoverContent data={data} />}
trigger="custom"
position="rightTop"
showArrow
>
<Button
icon={<IconEdit />}
size="small"
theme="solid"
style={{
backgroundColor: "#2F68ADB3",
}}
onClick={edit}
/>
</Popover>
)}
</div>
</div>
</foreignObject>
Expand Down Expand Up @@ -269,7 +265,7 @@ function EditPopoverContent({ data }) {
showArrow
>
<div
className="h-[32px] w-[32px] rounded"
className="h-[32px] w-[32px] rounded-sm"
style={{ backgroundColor: data.color }}
/>
</Popover>
Expand Down
4 changes: 2 additions & 2 deletions src/components/EditorCanvas/Canvas.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ export default function Canvas() {
const theme = localStorage.getItem("theme");

return (
<div className="flex-grow h-full touch-none" id="canvas">
<div className="grow h-full touch-none" id="canvas">
<div
className="w-full h-full"
style={{
Expand Down Expand Up @@ -587,7 +587,7 @@ export default function Canvas() {
</svg>
</div>
{settings.showDebugCoordinates && (
<div className="fixed flex flex-col flex-wrap gap-6 bg-[rgba(var(--semi-grey-1),var(--tw-bg-opacity))]/40 border border-color bottom-4 right-4 p-4 rounded-xl backdrop-blur-sm pointer-events-none select-none">
<div className="fixed flex flex-col flex-wrap gap-6 bg-[rgba(var(--semi-grey-1),var(--tw-bg-opacity))]/40 border border-color bottom-4 right-4 p-4 rounded-xl backdrop-blur-xs pointer-events-none select-none">
<table className="table-auto grow">
<thead>
<tr>
Expand Down
4 changes: 2 additions & 2 deletions src/components/EditorCanvas/Note.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ export default function Note({ data, onPointerDown }) {
showArrow
>
<div
className="h-[32px] w-[32px] rounded"
className="h-[32px] w-[32px] rounded-sm"
style={{ backgroundColor: data.color }}
/>
</Popover>
Expand Down Expand Up @@ -302,7 +302,7 @@ export default function Note({ data, onPointerDown }) {
})
}
onBlur={handleBlur}
className="w-full resize-none outline-none overflow-y-hidden border-none select-none"
className="w-full resize-none outline-hidden overflow-y-hidden border-none select-none"
style={{ backgroundColor: data.color }}
/>
</div>
Expand Down
19 changes: 12 additions & 7 deletions src/components/EditorCanvas/Table.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState } from "react";
import { useMemo, useState } from "react";
import {
Tab,
ObjectType,
Expand Down Expand Up @@ -37,8 +37,14 @@ export default function Table(props) {
const { t } = useTranslation();
const { selectedElement, setSelectedElement } = useSelect();

const borderColor = useMemo(
() => (settings.mode === "light" ? "border-zinc-300" : "border-zinc-600"),
[settings.mode],
);

const height =
tableData.fields.length * tableFieldHeight + tableHeaderHeight + 7;

const openEditor = () => {
if (!layout.sidebar) {
setSelectedElement((prev) => ({
Expand Down Expand Up @@ -84,7 +90,7 @@ export default function Table(props) {
selectedElement.id === tableData.id &&
selectedElement.element === ObjectType.TABLE
? "border-solid border-blue-500"
: "border-zinc-500"
: borderColor
}`}
style={{ direction: "ltr" }}
>
Expand Down Expand Up @@ -313,7 +319,7 @@ export default function Table(props) {
} flex items-center gap-2 overflow-hidden`}
>
<button
className="flex-shrink-0 w-[10px] h-[10px] bg-[#2f68adcc] rounded-full"
className="shrink-0 w-[10px] h-[10px] bg-[#2f68adcc] rounded-full"
onPointerDown={(e) => {
if (!e.isPrimary) return;

Expand Down Expand Up @@ -362,14 +368,13 @@ export default function Table(props) {
{fieldData.type +
((dbToTypes[database][fieldData.type].isSized ||
dbToTypes[database][fieldData.type].hasPrecision) &&
fieldData.size &&
fieldData.size !== ""
fieldData.size &&
fieldData.size !== ""
? `(${fieldData.size})`
: "")}
</span>
</div>
) : null
}
) : null}
</div>
</div>
);
Expand Down
31 changes: 17 additions & 14 deletions src/components/EditorHeader/ControlPanel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -1218,7 +1218,10 @@ export default function ControlPanel({
<i className="bi bi-toggle-off" />
),
function: () =>
setSettings((prev) => ({ ...prev, showDataTypes: !prev.showDataTypes })),
setSettings((prev) => ({
...prev,
showDataTypes: !prev.showDataTypes,
})),
},
show_grid: {
state: settings.showGrid ? (
Expand Down Expand Up @@ -1414,7 +1417,7 @@ export default function ControlPanel({
{window.name.split(" ")[0] !== "t" && (
<Button
type="primary"
className="text-base me-2 pe-6 ps-5 py-[18px] rounded-md"
className="!text-base me-2 !pe-6 !ps-5 !py-[18px] !rounded-md"
size="default"
icon={<IconShareStroked />}
onClick={() => setModal(MODAL.SHARE)}
Expand Down Expand Up @@ -1497,7 +1500,7 @@ export default function ControlPanel({
}
trigger="click"
>
<div className="py-1 px-2 hover-2 rounded flex items-center justify-center">
<div className="py-1 px-2 hover-2 rounded-sm flex items-center justify-center">
<div className="w-[40px]">
{Math.floor(transform.zoom * 100)}%
</div>
Expand All @@ -1508,7 +1511,7 @@ export default function ControlPanel({
</Dropdown>
<Tooltip content={t("zoom_in")} position="bottom">
<button
className="py-1 px-2 hover-2 rounded text-lg"
className="py-1 px-2 hover-2 rounded-sm text-lg"
onClick={() =>
setTransform((prev) => ({ ...prev, zoom: prev.zoom * 1.2 }))
}
Expand All @@ -1518,7 +1521,7 @@ export default function ControlPanel({
</Tooltip>
<Tooltip content={t("zoom_out")} position="bottom">
<button
className="py-1 px-2 hover-2 rounded text-lg"
className="py-1 px-2 hover-2 rounded-sm text-lg"
onClick={() =>
setTransform((prev) => ({ ...prev, zoom: prev.zoom / 1.2 }))
}
Expand All @@ -1529,7 +1532,7 @@ export default function ControlPanel({
<Divider layout="vertical" margin="8px" />
<Tooltip content={t("undo")} position="bottom">
<button
className="py-1 px-2 hover-2 rounded flex items-center"
className="py-1 px-2 hover-2 rounded-sm flex items-center"
onClick={undo}
>
<IconUndo
Expand All @@ -1540,7 +1543,7 @@ export default function ControlPanel({
</Tooltip>
<Tooltip content={t("redo")} position="bottom">
<button
className="py-1 px-2 hover-2 rounded flex items-center"
className="py-1 px-2 hover-2 rounded-sm flex items-center"
onClick={redo}
>
<IconRedo
Expand All @@ -1552,23 +1555,23 @@ export default function ControlPanel({
<Divider layout="vertical" margin="8px" />
<Tooltip content={t("add_table")} position="bottom">
<button
className="flex items-center py-1 px-2 hover-2 rounded"
className="flex items-center py-1 px-2 hover-2 rounded-sm"
onClick={() => addTable()}
>
<IconAddTable />
</button>
</Tooltip>
<Tooltip content={t("add_area")} position="bottom">
<button
className="py-1 px-2 hover-2 rounded flex items-center"
className="py-1 px-2 hover-2 rounded-sm flex items-center"
onClick={() => addArea()}
>
<IconAddArea />
</button>
</Tooltip>
<Tooltip content={t("add_note")} position="bottom">
<button
className="py-1 px-2 hover-2 rounded flex items-center"
className="py-1 px-2 hover-2 rounded-sm flex items-center"
onClick={() => addNote()}
>
<IconAddNote />
Expand All @@ -1577,15 +1580,15 @@ export default function ControlPanel({
<Divider layout="vertical" margin="8px" />
<Tooltip content={t("save")} position="bottom">
<button
className="py-1 px-2 hover-2 rounded flex items-center"
className="py-1 px-2 hover-2 rounded-sm flex items-center"
onClick={save}
>
<IconSaveStroked size="extra-large" />
</button>
</Tooltip>
<Tooltip content={t("to_do")} position="bottom">
<button
className="py-1 px-2 hover-2 rounded text-xl -mt-0.5"
className="py-1 px-2 hover-2 rounded-sm text-xl -mt-0.5"
onClick={() => setSidesheet(SIDESHEET.TODO)}
>
<i className="fa-regular fa-calendar-check" />
Expand All @@ -1594,7 +1597,7 @@ export default function ControlPanel({
<Divider layout="vertical" margin="8px" />
<Tooltip content={t("theme")} position="bottom">
<button
className="py-1 px-2 hover-2 rounded text-xl -mt-0.5"
className="py-1 px-2 hover-2 rounded-sm text-xl -mt-0.5"
onClick={() => {
const body = document.body;
if (body.hasAttribute("theme-mode")) {
Expand Down Expand Up @@ -1782,7 +1785,7 @@ export default function ControlPanel({
</Dropdown.Menu>
}
>
<div className="px-3 py-1 hover-2 rounded">
<div className="px-3 py-1 hover-2 rounded-sm">
{t(category)}
</div>
</Dropdown>
Expand Down
2 changes: 1 addition & 1 deletion src/components/EditorHeader/LayoutDropdown.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export default function LayoutDropdown() {
}
trigger="click"
>
<div className="py-1 px-2 hover-2 rounded flex items-center justify-center">
<div className="py-1 px-2 hover-2 rounded-sm flex items-center justify-center">
<IconRowsStroked size="extra-large" />
<div>
<IconCaretdown />
Expand Down
2 changes: 1 addition & 1 deletion src/components/EditorHeader/Modal/Code.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default function Code({ value, language }) {
/>
<button
onClick={copyCode}
className={`absolute right-4 top-2 px-2 py-1 rounded ${settings.mode === "dark" ? "bg-zinc-700" : "bg-zinc-200"}`}
className={`absolute right-4 top-2 px-2 py-1 rounded-sm ${settings.mode === "dark" ? "bg-zinc-700" : "bg-zinc-200"}`}
>
<i className={`bi bi-clipboard${copied ? "-check" : ""} me-2`} />
{t("copy")}
Expand Down
2 changes: 1 addition & 1 deletion src/components/EditorHeader/Modal/Open.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export default function Open({ selectedDiagramId, setSelectedDiagramId }) {
key={d.id}
className={`${
selectedDiagramId === d.id
? "bg-blue-300 bg-opacity-30"
? "bg-blue-300/30"
: "hover-1"
}`}
onClick={() => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/EditorSidePanel/AreasTab/AreaDetails.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export default function AreaInfo({ data, i }) {
showArrow
>
<div
className="h-[32px] w-[32px] rounded"
className="h-[32px] w-[32px] rounded-sm"
style={{ backgroundColor: data.color }}
/>
</Popover>
Expand Down
2 changes: 1 addition & 1 deletion src/components/EditorSidePanel/NotesTab/NoteInfo.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export default function NoteInfo({ data, nid }) {
showArrow
>
<div
className="h-[32px] w-[32px] rounded mb-2"
className="h-[32px] w-[32px] rounded-sm mb-2"
style={{ backgroundColor: data.color }}
/>
</Popover>
Expand Down
2 changes: 1 addition & 1 deletion src/components/EditorSidePanel/TablesTab/TableInfo.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ export default function TableInfo({ data }) {
showArrow
>
<div
className="h-[32px] w-[32px] rounded"
className="h-[32px] w-[32px] rounded-sm"
style={{ backgroundColor: data.color }}
/>
</Popover>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Thumbnail.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export default function Thumbnail({ diagram, i, zoom, theme }) {
width={a.width > 0 ? a.width : 0}
height={a.height > 0 ? a.height : 0}
>
<div className="border border-slate-400 w-full h-full rounded-sm relative">
<div className="border border-slate-400 w-full h-full rounded-xs relative">
<div
className="opacity-40 w-fill h-full"
style={{ backgroundColor: a.color }}
Expand Down
Loading