-
-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add text-align and text-shadow
- Loading branch information
1 parent
5a4f9ae
commit 54992f2
Showing
3 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
.../pages/templateEditor/TemplateGraphicalEditor/WebgalClassEditor/propertyEditor/WGText.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { IPropertyEditorProps } from '@/pages/templateEditor/TemplateGraphicalEditor/WebgalClassEditor/editorTable'; | ||
import { Button, Input, Select, useId } from '@fluentui/react-components'; | ||
import s from '../propertyEditor.module.scss'; | ||
import { t } from '@lingui/macro'; | ||
import { useState } from 'react'; | ||
|
||
export default function WGTextAlignEditor(props: IPropertyEditorProps) { | ||
const initialValue = props.prop.propValue; | ||
const [align, setAlign] = useState(initialValue); | ||
|
||
const submit = () => { | ||
props.prop.propValue = align; | ||
props.onSubmit(); | ||
}; | ||
|
||
return ( | ||
<div className={s.propertyEditor}> | ||
<Select value={align} onChange={(_, data) => setAlign(data.value)}> | ||
<option value="left">{t`左对齐`}</option> | ||
<option value="center">{t`居中对齐`}</option> | ||
<option value="right">{t`右对齐`}</option> | ||
<option value="justify">{t`两端对齐`}</option> | ||
</Select> | ||
<Button style={{ marginLeft: 8 }} onClick={submit}>{t`提交修改`}</Button> | ||
</div> | ||
); | ||
} | ||
|
||
|
33 changes: 33 additions & 0 deletions
33
.../templateEditor/TemplateGraphicalEditor/WebgalClassEditor/propertyEditor/WGTextShadow.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { useState } from 'react'; | ||
import { Button, Input, Select } from '@fluentui/react-components'; | ||
import { t } from '@lingui/macro'; | ||
import s from '../propertyEditor.module.scss'; | ||
import { IPropertyEditorProps } from '@/pages/templateEditor/TemplateGraphicalEditor/WebgalClassEditor/editorTable'; | ||
|
||
export default function WGTextShadowEditor(props: IPropertyEditorProps) { | ||
const initialValue = props.prop.propValue || '0px 0px 0px rgba(0,0,0,0)'; // 默认值为无阴影 | ||
const [hOffset, setHOffset] = useState((initialValue.match(/(-?\d+)px/) || [, '0'])[1]); | ||
const [vOffset, setVOffset] = useState((initialValue.match(/-?\d+px\s+(-?\d+)px/) || [, '0'])[1]); | ||
const [blurRadius, setBlurRadius] = useState((initialValue.match(/(-?\d+)px\s+rgba/) || [, '0'])[1]); | ||
const [color, setColor] = useState((initialValue.match(/rgba\(.+\)/) || ['rgba(0,0,0,0)'])[0]); | ||
|
||
const submit = () => { | ||
props.prop.propValue = `${hOffset}px ${vOffset}px ${blurRadius}px ${color}`; | ||
props.onSubmit(); | ||
}; | ||
|
||
return ( | ||
<div className={s.propertyEditor}> | ||
<Input type="number" value={hOffset} onChange={(_, data) => setHOffset(data.value)} style={{ marginRight: 10 }} /> | ||
<Input type="number" value={vOffset} onChange={(_, data) => setVOffset(data.value)} style={{ marginRight: 10 }} /> | ||
<Input | ||
type="number" | ||
value={blurRadius} | ||
onChange={(_, data) => setBlurRadius(data.value)} | ||
style={{ marginRight: 10 }} | ||
/> | ||
<Input value={color} onChange={(_, data) => setColor(data.value)} style={{ marginRight: 10 }} /> | ||
<Button style={{ marginLeft: 8 }} onClick={submit}>{t`提交修改`}</Button> | ||
</div> | ||
); | ||
} |