Skip to content

Commit 820133c

Browse files
committed
feat: 添加锤子SVG图标替换编译按钮的emoji
- 创建HammerIcon组件,使用倾斜25度的锤子SVG图标 - 更新ToolbarButton支持ReactNode类型的label(支持图标+文字) - 工具栏按钮增加flex布局和gap间距 - 主题切换按钮文案优化 - 默认面板宽度调整为300px 🤖 Generated with Claude Code
1 parent 725fa8e commit 820133c

5 files changed

Lines changed: 41 additions & 6 deletions

File tree

apps/app-pc/src/pages/home.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const sampleCode = `def run(request){
1212
`;
1313

1414
const HomePage = () => {
15-
const [theme, setTheme] = useState<'dark' | 'light'>('dark');
15+
const [theme, setTheme] = useState<'dark' | 'light'>('light');
1616

1717
return (
1818
<div

packages/script-engine/src/components/toolbar-button.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { useState } from 'react';
22

33
export interface ToolbarButtonProps {
4-
label: string;
4+
label: React.ReactNode;
55
title: string;
66
bg: string;
77
hoverBg: string;
@@ -18,6 +18,9 @@ export const ToolbarButton: React.FC<ToolbarButtonProps> = ({ label, title, bg,
1818
onMouseEnter={() => setHovered(true)}
1919
onMouseLeave={() => setHovered(false)}
2020
style={{
21+
display: 'inline-flex',
22+
alignItems: 'center',
23+
gap: 4,
2124
background: hovered ? hoverBg : bg,
2225
border: `1px solid ${border}`,
2326
color,

packages/script-engine/src/components/toolbar.tsx

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,33 @@
11
import React from 'react';
22
import { ToolbarButton } from './toolbar-button';
33

4+
// 锤子图标(编译/构建)
5+
const HammerIcon: React.FC<{ color: string }> = ({ color }) => (
6+
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" style={{ flexShrink: 0 }}>
7+
{/* 锤头(倾斜) */}
8+
<rect
9+
x="3"
10+
y="6"
11+
width="12"
12+
height="5"
13+
rx="1"
14+
fill={color}
15+
transform="rotate(-25 9 8.5)"
16+
/>
17+
{/* 锤柄 */}
18+
<rect
19+
x="11"
20+
y="9"
21+
width="2.5"
22+
height="11"
23+
rx="1"
24+
fill={color}
25+
opacity={0.8}
26+
transform="rotate(-25 12.25 14.5)"
27+
/>
28+
</svg>
29+
);
30+
431
export interface ToolbarProps {
532
title?: string;
633
theme: 'dark' | 'light';
@@ -57,7 +84,7 @@ export const Toolbar: React.FC<ToolbarProps> = ({
5784
{!title && <span style={{ marginRight: 'auto' }} />}
5885

5986
<ToolbarButton
60-
label={isDark ? '☀ 浅色' : '🌙 深色'}
87+
label={isDark ? '🌞 浅色模式' : '🌙 深色模式'}
6188
title={isDark ? '切换到浅色主题' : '切换到深色主题'}
6289
bg={btnBg}
6390
hoverBg={btnHoverBg}
@@ -68,7 +95,12 @@ export const Toolbar: React.FC<ToolbarProps> = ({
6895

6996
{onCompile && (
7097
<ToolbarButton
71-
label="✔ 编译验证"
98+
label={
99+
<>
100+
<HammerIcon color={isDark ? '#98c379' : '#389e0d'} />
101+
编译验证
102+
</>
103+
}
72104
title="编译并验证脚本"
73105
bg={isDark ? '#2d5a27' : '#e6f4e5'}
74106
hoverBg={isDark ? '#3a7033' : '#d4ecd3'}

packages/script-engine/src/script-code.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ export const ScriptCodeEditor: React.FC<ScriptCodeEditorProps> = (props) => {
155155
const [sidebarOpen, setSidebarOpen] = useState(
156156
defaultSidebarOpen ?? (metadata != null)
157157
);
158-
const [panelWidth, setPanelWidth] = useState(260);
158+
const [panelWidth, setPanelWidth] = useState(300);
159159

160160
// ── 创建编辑器(仅在首次挂载和布局属性变化时) ──────────
161161
useEffect(() => {

packages/script-engine/src/type-panel/type-panel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export interface TypePanelProps {
2323

2424
// ── 宽度约束 ──────────────────────────────────────────────────
2525

26-
const DEFAULT_WIDTH = 260;
26+
const DEFAULT_WIDTH = 300;
2727
const MIN_WIDTH = 180;
2828
const MAX_WIDTH = 600;
2929

0 commit comments

Comments
 (0)