fix: replace document.querySelector with useState for image url input
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 1m11s
CI/CD Pipeline / Validate - Type Check (mypy) (pull_request) Successful in 2m12s
Preview Deploy / Deploy Preview Environment (pull_request) Failing after 49s
CI/CD Pipeline / Validate - Migration (alembic) (pull_request) Successful in 1m55s
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 1m27s
CI/CD Pipeline / Validate - Code Quality (pull_request) Successful in 3m57s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 3m30s
CI/CD Pipeline / Frontend Unit Tests (pull_request) Successful in 35s
CI/CD Pipeline / Frontend Lint (pull_request) Failing after 51s
AI Code Review / AI Code Review (pull_request) Failing after 5m6s
CI/CD Pipeline / PR Build Web Image (pull_request) Failing after 3m8s
CI/CD Pipeline / Build Production API Image (pull_request) Has been cancelled
CI/CD Pipeline / Build Production Web Image (pull_request) Has been cancelled
CI/CD Pipeline / Build Production Worker Image (pull_request) Has been cancelled
CI/CD Pipeline / Deploy Production (pull_request) Has been cancelled
CI/CD Pipeline / Production Browser E2E (pull_request) Has been cancelled
CI/CD Pipeline / Canary Release to Production (pull_request) Has been cancelled
CI/CD Pipeline / CI Gate (pull_request) Has been cancelled
CI/CD Pipeline / ACR Image Cleanup (pull_request) Failing after 1157h31m57s
CI/CD Pipeline / Staging E2E Tests (pull_request) Failing after 1157h32m1s
CI/CD Pipeline / Integration Tests (pull_request) Failing after 1157h32m3s
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Failing after 1157h36m31s
CI/CD Pipeline / PR Build API Image (pull_request) Failing after 1157h36m43s
CI/CD Pipeline / Unit Tests (pull_request) Failing after 1157h36m58s
CI/CD Pipeline / Build Staging Worker Image (pull_request) Failing after 1157h40m1s
CI/CD Pipeline / Build Staging API Image (pull_request) Failing after 1157h40m5s
CI/CD Pipeline / Staging API Integration Tests (pull_request) Failing after 1158h5m6s
CI/CD Pipeline / PR Build Worker Image (pull_request) Failing after 1158h9m40s
CI/CD Pipeline / Build Staging Web Image (pull_request) Failing after 1158h13m10s
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 1m11s
CI/CD Pipeline / Validate - Type Check (mypy) (pull_request) Successful in 2m12s
Preview Deploy / Deploy Preview Environment (pull_request) Failing after 49s
CI/CD Pipeline / Validate - Migration (alembic) (pull_request) Successful in 1m55s
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 1m27s
CI/CD Pipeline / Validate - Code Quality (pull_request) Successful in 3m57s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 3m30s
CI/CD Pipeline / Frontend Unit Tests (pull_request) Successful in 35s
CI/CD Pipeline / Frontend Lint (pull_request) Failing after 51s
AI Code Review / AI Code Review (pull_request) Failing after 5m6s
CI/CD Pipeline / PR Build Web Image (pull_request) Failing after 3m8s
CI/CD Pipeline / Build Production API Image (pull_request) Has been cancelled
CI/CD Pipeline / Build Production Web Image (pull_request) Has been cancelled
CI/CD Pipeline / Build Production Worker Image (pull_request) Has been cancelled
CI/CD Pipeline / Deploy Production (pull_request) Has been cancelled
CI/CD Pipeline / Production Browser E2E (pull_request) Has been cancelled
CI/CD Pipeline / Canary Release to Production (pull_request) Has been cancelled
CI/CD Pipeline / CI Gate (pull_request) Has been cancelled
CI/CD Pipeline / ACR Image Cleanup (pull_request) Failing after 1157h31m57s
CI/CD Pipeline / Staging E2E Tests (pull_request) Failing after 1157h32m1s
CI/CD Pipeline / Integration Tests (pull_request) Failing after 1157h32m3s
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Failing after 1157h36m31s
CI/CD Pipeline / PR Build API Image (pull_request) Failing after 1157h36m43s
CI/CD Pipeline / Unit Tests (pull_request) Failing after 1157h36m58s
CI/CD Pipeline / Build Staging Worker Image (pull_request) Failing after 1157h40m1s
CI/CD Pipeline / Build Staging API Image (pull_request) Failing after 1157h40m5s
CI/CD Pipeline / Staging API Integration Tests (pull_request) Failing after 1158h5m6s
CI/CD Pipeline / PR Build Worker Image (pull_request) Failing after 1158h9m40s
CI/CD Pipeline / Build Staging Web Image (pull_request) Failing after 1158h13m10s
This commit is contained in:
-133
@@ -1,133 +0,0 @@
|
||||
import React from "react"
|
||||
import type { StickerType, TextStickerPreset } from "../../../types"
|
||||
import { TEXT_STICKER_PRESET_LABELS } from "../../../types"
|
||||
import { EMOJI_LIST, TEXT_PRESET_STYLES } from "../constants"
|
||||
|
||||
export interface StickerTabsProps {
|
||||
activeTab: StickerType
|
||||
onTabChange: (tab: StickerType) => void
|
||||
textInput: string
|
||||
onTextInputChange: (val: string) => void
|
||||
onAddEmoji: (emoji: string) => void
|
||||
onAddImage: (url: string) => void
|
||||
onAddText: (text: string) => void
|
||||
}
|
||||
|
||||
export const StickerTabs: React.FC<StickerTabsProps> = ({
|
||||
activeTab,
|
||||
onTabChange,
|
||||
textInput,
|
||||
onTextInputChange,
|
||||
onAddEmoji,
|
||||
onAddImage,
|
||||
onAddText,
|
||||
}) => {
|
||||
const handleImageAdd = () => {
|
||||
const input = document.querySelector<HTMLInputElement>(".sticker-url-input")
|
||||
if (input?.value.trim()) {
|
||||
onAddImage(input.value.trim())
|
||||
input.value = ""
|
||||
}
|
||||
}
|
||||
|
||||
const handleTextAdd = () => {
|
||||
if (textInput.trim()) {
|
||||
onAddText(textInput.trim())
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
{/* 类型 Tab */}
|
||||
<div className="sticker-tabs">
|
||||
{(["emoji", "image", "text"] as StickerType[]).map((t) => (
|
||||
<button
|
||||
key={t}
|
||||
className={`sticker-tab${activeTab === t ? " active" : ""}`}
|
||||
onClick={() => onTabChange(t)}
|
||||
>
|
||||
{t === "emoji" ? "表情贴纸" : t === "image" ? "图片贴纸" : "文字花字"}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{/* Tab 内容区 */}
|
||||
<div className="sticker-tab-content">
|
||||
{/* Emoji 素材库 */}
|
||||
{activeTab === "emoji" && (
|
||||
<div className="sticker-emoji-grid">
|
||||
{EMOJI_LIST.map((emoji) => (
|
||||
<button key={emoji} className="sticker-emoji-btn" onClick={() => onAddEmoji(emoji)}>
|
||||
{emoji}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* 图片贴纸 */}
|
||||
{activeTab === "image" && (
|
||||
<div className="sticker-image-input">
|
||||
<input
|
||||
type="text"
|
||||
className="sticker-url-input"
|
||||
placeholder="输入图片 URL 添加贴纸..."
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === "Enter" && e.currentTarget.value.trim()) {
|
||||
onAddImage(e.currentTarget.value.trim())
|
||||
e.currentTarget.value = ""
|
||||
}
|
||||
}}
|
||||
/>
|
||||
<button className="sticker-url-add-btn" onClick={handleImageAdd}>
|
||||
添加
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* 文字花字 */}
|
||||
{activeTab === "text" && (
|
||||
<div className="sticker-text-section">
|
||||
<div className="sticker-text-input-row">
|
||||
<input
|
||||
type="text"
|
||||
className="sticker-text-input"
|
||||
placeholder="输入文字内容..."
|
||||
value={textInput}
|
||||
onChange={(e) => onTextInputChange(e.target.value)}
|
||||
/>
|
||||
<button
|
||||
className="sticker-text-add-btn"
|
||||
disabled={!textInput.trim()}
|
||||
onClick={handleTextAdd}
|
||||
>
|
||||
添加
|
||||
</button>
|
||||
</div>
|
||||
<div className="sticker-text-presets">
|
||||
<div className="sticker-preset-title">花字预设预览</div>
|
||||
<div className="sticker-preset-grid">
|
||||
{(Object.keys(TEXT_STICKER_PRESET_LABELS) as TextStickerPreset[]).map((p) => (
|
||||
<div
|
||||
key={p}
|
||||
className="sticker-preset-preview"
|
||||
style={{
|
||||
background:
|
||||
p === "bubble"
|
||||
? "rgba(0,0,0,0.5)"
|
||||
: p === "gradient"
|
||||
? "linear-gradient(90deg,#f093fb,#f5576c)"
|
||||
: "#1a1a2e",
|
||||
}}
|
||||
>
|
||||
<span style={TEXT_PRESET_STYLES[p]}>示例</span>
|
||||
<div className="sticker-preset-name">{TEXT_STICKER_PRESET_LABELS[p]}</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user