Skip to content

Commit

Permalink
chore: remove border
Browse files Browse the repository at this point in the history
  • Loading branch information
anig1scur committed Oct 31, 2024
1 parent ffac81b commit f0decb4
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 102 deletions.
95 changes: 7 additions & 88 deletions src/components/ThemeConfigForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,84 +79,6 @@ const MarginFields = ({ control, name, label }: MarginFieldsProps) => (
</div>
);

interface BackgroundFieldsProps {
control: any;
name: string;
label: string;
}

const BackgroundFields = ({ control, name, label }: BackgroundFieldsProps) => (
<Card>
<CardHeader>
<CardTitle>{ label }</CardTitle>
</CardHeader>
<CardContent className="space-y-4 flex items-baseline gap-12">
<FormField
control={ control }
name={ `${ name }.color` }
render={ ({ field }) => (
<FormItem>
<FormLabel>背景颜色</FormLabel>
<FormControl>
<Input type="color" { ...field } className="h-10 w-20" />
</FormControl>
</FormItem>
) }
/>
<FormField
control={ control }
name={ `${ name }.borderColor` }
render={ ({ field }) => (
<FormItem>
<FormLabel>边框颜色</FormLabel>
<FormControl>
<Input type="color" { ...field } className="h-10 w-20" />
</FormControl>
</FormItem>
) }
/>
<FormField
control={ control }
name={ `${ name }.borderWidth` }
render={ ({ field }) => (
<FormItem>
<FormLabel>边框宽度 ({ field.value }px)</FormLabel>
<FormControl>
<Slider
min={ 0 }
max={ 10 }
step={ 1 }
value={ [field.value] }
onValueChange={ (value) => field.onChange(value[0]) }
/>
</FormControl>
</FormItem>
) }
/>
{/* <FormField
control={control}
name={`${name}.gravity`}
render={({ field }) => (
<FormItem>
<FormLabel>叠加层位置</FormLabel>
<Select onValueChange={field.onChange} value={field.value}>
<SelectTrigger>
<SelectValue placeholder="选择位置" />
</SelectTrigger>
<SelectContent>
<SelectItem value="Top Left">左上</SelectItem>
<SelectItem value="Top Right">右上</SelectItem>
<SelectItem value="Bottom Left">左下</SelectItem>
<SelectItem value="Bottom Right">右下</SelectItem>
</SelectContent>
</Select>
</FormItem>
)}
/> */}
{/* <MarginFields control={control} name={`${name}.margin`} label="边距设置" /> */ }
</CardContent>
</Card>
);

interface ThemeConfigFormProps {
initialConfig: ThemeConfig;
Expand Down Expand Up @@ -248,10 +170,10 @@ export function ThemeConfigForm({ initialConfig, onConfigChange, onConfigExport
/>
<FormField
control={ form.control }
name="highlightColor"
name={ `background.color` }
render={ ({ field }) => (
<FormItem>
<FormLabel>高亮文字颜色</FormLabel>
<FormLabel>背景颜色</FormLabel>
<FormControl>
<Input type="color" { ...field } className="h-10 w-20" />
</FormControl>
Expand All @@ -260,22 +182,23 @@ export function ThemeConfigForm({ initialConfig, onConfigChange, onConfigExport
/>
<FormField
control={ form.control }
name="highlightBackgroundColor"
name="highlightColor"
render={ ({ field }) => (
<FormItem>
<FormLabel>高亮背景颜色</FormLabel>
<FormLabel>高亮文字颜色</FormLabel>
<FormControl>
<Input type="color" { ...field } className="h-10 w-20" />
</FormControl>
</FormItem>
) }
/>

<FormField
control={ form.control }
name="highlightCandidateColor"
name={ `highlight.color` }
render={ ({ field }) => (
<FormItem>
<FormLabel>候选词高亮颜色</FormLabel>
<FormLabel>高亮背景颜色</FormLabel>
<FormControl>
<Input type="color" { ...field } className="h-10 w-20" />
</FormControl>
Expand Down Expand Up @@ -355,10 +278,6 @@ export function ThemeConfigForm({ initialConfig, onConfigChange, onConfigExport
</CardContent>
</Card> */}

{/* Background and Highlight */ }
<BackgroundFields control={ form.control } name="background" label="背景设置" />
<BackgroundFields control={ form.control } name="highlight" label="高亮设置" />

<div className="flex justify-end">
<Button onClick={ exportTheme }>导出主题</Button>
</div>
Expand Down
7 changes: 3 additions & 4 deletions src/components/ThemePreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ interface ThemePreviewProps {
export function ThemePreview({ config, direction = 'vertical' }: ThemePreviewProps) {
const inputPanelStyle = {
backgroundColor: config.background.color,
border: `${ config.background.borderWidth }px solid ${ config.background.borderColor }`,
margin: '20px',
marginBottom: '20px',
width: direction === 'vertical' ? '300px' : 'fit-content',
position: 'relative' as const,
};
Expand All @@ -33,8 +32,8 @@ export function ThemePreview({ config, direction = 'vertical' }: ThemePreviewPro
const highlightStyle = {
backgroundColor: config.highlight.color,
whiteSpace: "nowrap",
border: `${ config.highlight.borderWidth }px solid ${ config.highlight.borderColor }`,
padding: `${ config.highlight.margin.top }px ${ config.highlight.margin.right }px ${ config.highlight.margin.bottom }px ${ config.highlight.margin.left }px`,
// padding: `${ config.highlight.margin.top }px ${ config.highlight.margin.right }px ${ config.highlight.margin.bottom }px ${ config.highlight.margin.left }px`,
padding: `${ config.textMargin.top }px ${ config.textMargin.right }px ${ config.textMargin.bottom }px ${ config.textMargin.left }px`,
};

const candidatesContainerStyle = {
Expand Down
4 changes: 0 additions & 4 deletions src/lib/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,17 +111,13 @@ export function parseThemeFile(content: string): ThemeConfig {
// Background
background: {
color: sections['InputPanel/Background']?.['Color'] || '#ffffff',
borderColor: '#000000',
borderWidth: 0,
gravity: 'Center',
margin: parseMargin(sections['InputPanel/Background/Margin'] || {}),
},

// Highlight
highlight: {
color: sections['InputPanel/Highlight']?.['Color'] || '#ffffff',
borderColor: '#000000',
borderWidth: 0,
gravity: 'Center',
margin: parseMargin(sections['InputPanel/Highlight/Margin'] || {}),
},
Expand Down
6 changes: 0 additions & 6 deletions src/types/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ export interface Margin {
export interface Background {
image?: string;
color: string;
borderColor: string;
borderWidth: number;
overlay?: string;
gravity: string;
overlayOffsetX?: number;
Expand Down Expand Up @@ -94,8 +92,6 @@ export const defaultConfig: ThemeConfig = {

background: {
color: '#e5e9f0',
borderColor: '',
borderWidth: 0,
gravity: '',
margin: {
left: 2,
Expand All @@ -107,8 +103,6 @@ export const defaultConfig: ThemeConfig = {

highlight: {
color: '#d8dee9',
borderColor: '',
borderWidth: 0,
gravity: '',
margin: {
left: 10,
Expand Down

0 comments on commit f0decb4

Please sign in to comment.