feat(title): 预设卡片预览联动用户选择的字体 #1238
@@ -13,9 +13,15 @@ interface TitlePresetsGridProps {
|
||||
presets: TitlePresetItem[]
|
||||
activePreset: string | null
|
||||
onApply: (presetKey: string) => void
|
||||
fontFamily?: string
|
||||
}
|
||||
|
||||
const TitlePresetsGrid: React.FC<TitlePresetsGridProps> = ({ presets, activePreset, onApply }) => {
|
||||
const TitlePresetsGrid: React.FC<TitlePresetsGridProps> = ({
|
||||
presets,
|
||||
activePreset,
|
||||
onApply,
|
||||
fontFamily,
|
||||
}) => {
|
||||
return (
|
||||
<div className="xx-title-presets-grid">
|
||||
{presets.map((p) => {
|
||||
@@ -27,7 +33,10 @@ const TitlePresetsGrid: React.FC<TitlePresetsGridProps> = ({ presets, activePres
|
||||
onClick={() => onApply(p.key)}
|
||||
title={p.label}
|
||||
>
|
||||
<span className="xx-title-preset-preview-text" style={p.previewStyle}>
|
||||
<span
|
||||
className="xx-title-preset-preview-text"
|
||||
style={{ ...p.previewStyle, ...(fontFamily ? { fontFamily } : {}) }}
|
||||
>
|
||||
标题
|
||||
</span>
|
||||
<span className="xx-title-preset-card-label">{p.label}</span>
|
||||
|
||||
@@ -107,6 +107,7 @@ const TitleStylePanel: React.FC<TitleStylePanelProps> = ({
|
||||
presets={titlePresets}
|
||||
activePreset={activePreset}
|
||||
onApply={onApplyPreset}
|
||||
fontFamily={settings.font}
|
||||
/>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, it, vi } from "vitest"
|
||||
import { render } from "@testing-library/react"
|
||||
import { afterEach, describe, expect, it, vi } from "vitest"
|
||||
import { render, cleanup } from "@testing-library/react"
|
||||
import TtsPanel from "@/pages/editing-planner/components/TtsPanel"
|
||||
import { DEFAULT_TTS_CONFIG } from "@/pages/editing-planner/types"
|
||||
|
||||
@@ -16,6 +16,10 @@ const defaultProps = {
|
||||
}
|
||||
|
||||
describe("TtsPanel", () => {
|
||||
afterEach(() => {
|
||||
cleanup()
|
||||
})
|
||||
|
||||
it("should render without crashing", () => {
|
||||
const { container } = render(<TtsPanel {...defaultProps} />)
|
||||
expect(container).toBeTruthy()
|
||||
|
||||
Reference in New Issue
Block a user