From e6b2cd942cce4dc595c493d53ac91b321af4bd46 Mon Sep 17 00:00:00 2001
From: JOYCEQL <1449239013@qq.com>
Date: Sat, 15 Mar 2025 13:51:53 +0800
Subject: [PATCH] feat: add number input to sidepanel for spacing
---
src/app/globals.css | 13 ++
src/components/editor/SidePanel.tsx | 251 ++++++++++++++++++++++++++--
2 files changed, 254 insertions(+), 10 deletions(-)
diff --git a/src/app/globals.css b/src/app/globals.css
index c825e57..5e4eeab 100644
--- a/src/app/globals.css
+++ b/src/app/globals.css
@@ -2,6 +2,19 @@
@tailwind components;
@tailwind utilities;
+/* 隐藏数字输入框自带的上下箭头 */
+@layer utilities {
+ .no-spinner::-webkit-inner-spin-button,
+ .no-spinner::-webkit-outer-spin-button {
+ -webkit-appearance: none;
+ margin: 0;
+ }
+
+ .no-spinner {
+ -moz-appearance: textfield;
+ }
+}
+
@layer base {
:root {
--background: 0 0% 100%;
diff --git a/src/components/editor/SidePanel.tsx b/src/components/editor/SidePanel.tsx
index 8418dba..dd4e138 100644
--- a/src/components/editor/SidePanel.tsx
+++ b/src/components/editor/SidePanel.tsx
@@ -14,6 +14,7 @@ import {
import { Slider } from "@/components/ui/slider";
import { Label } from "@/components/ui/label";
import { Switch } from "@/components/ui/switch";
+import { Input } from "@/components/ui/input";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import LayoutSetting from "./layout/LayoutSetting";
import { useResumeStore } from "@/store/useResumeStore";
@@ -402,10 +403,85 @@ export function SidePanel() {
onValueChange={([value]) =>
updateGlobalSettings?.({ pagePadding: value })
}
+ className="flex-1"
/>
-
- {globalSettings?.pagePadding}px
-
+
+
+
) => {
+ const value = Number(e.target.value);
+ if (!isNaN(value) && value >= 0 && value <= 100) {
+ updateGlobalSettings?.({ pagePadding: value });
+ }
+ }}
+ className="h-full w-12 border-0 text-center focus-visible:ring-0 focus-visible:ring-offset-0 no-spinner"
+ />
+
+
+
+
+
+
+ px
+
+
@@ -422,10 +498,87 @@ export function SidePanel() {
onValueChange={([value]) =>
updateGlobalSettings?.({ sectionSpacing: value })
}
+ className="flex-1"
/>
-
- {globalSettings?.sectionSpacing}px
-
+
+
+
) => {
+ const value = Number(e.target.value);
+ if (!isNaN(value) && value >= 1 && value <= 100) {
+ updateGlobalSettings?.({ sectionSpacing: value });
+ }
+ }}
+ className="h-full w-12 border-0 text-center focus-visible:ring-0 focus-visible:ring-offset-0 no-spinner"
+ />
+
+
+
+
+
+
+ px
+
+
@@ -437,14 +590,92 @@ export function SidePanel() {
updateGlobalSettings?.({ paragraphSpacing: value })
}
+ className="flex-1"
/>
-
- {globalSettings?.paragraphSpacing}px
-
+
+
+
) => {
+ const value = Number(e.target.value);
+ if (!isNaN(value) && value >= 1) {
+ updateGlobalSettings?.({ paragraphSpacing: value });
+ }
+ }}
+ className="h-full w-12 border-0 text-center focus-visible:ring-0 focus-visible:ring-offset-0 no-spinner"
+ />
+
+
+
+
+
+
+ px
+
+