mirror of
https://github.com/MrXujiang/h5-Dooring.git
synced 2025-12-13 19:12:50 +00:00
add: 新增按钮组建
This commit is contained in:
parent
75facb2b2a
commit
86d7b15b47
@ -0,0 +1,9 @@
|
|||||||
|
import React, { memo } from 'react';
|
||||||
|
import { IButtonConfig } from './schema';
|
||||||
|
import { Button } from 'antd';
|
||||||
|
const button = memo((props: IButtonConfig) => {
|
||||||
|
const { text, type } = props;
|
||||||
|
return <Button type={type}>{text}</Button>;
|
||||||
|
});
|
||||||
|
|
||||||
|
export default button;
|
||||||
89
src/components/BasicPcShop/BasicComponents/Button/schema.ts
Normal file
89
src/components/BasicPcShop/BasicComponents/Button/schema.ts
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
import {
|
||||||
|
IColorConfigType,
|
||||||
|
INumberConfigType,
|
||||||
|
ISelectConfigType,
|
||||||
|
ITextConfigType,
|
||||||
|
TColorDefaultType,
|
||||||
|
TNumberDefaultType,
|
||||||
|
TSelectDefaultType,
|
||||||
|
TTextDefaultType,
|
||||||
|
} from '@/components/PanelComponents/FormEditor/types';
|
||||||
|
|
||||||
|
export type TButtonSelectKeyType = 'left' | 'center' | 'right';
|
||||||
|
|
||||||
|
export type TButtonEditData = Array<
|
||||||
|
IColorConfigType | INumberConfigType | ITextConfigType | ISelectConfigType<TButtonSelectKeyType>
|
||||||
|
>;
|
||||||
|
export interface IButtonConfig {
|
||||||
|
bgColor: TColorDefaultType;
|
||||||
|
text: TTextDefaultType;
|
||||||
|
color: TColorDefaultType;
|
||||||
|
align: TSelectDefaultType<TButtonSelectKeyType>;
|
||||||
|
fontSize: TNumberDefaultType;
|
||||||
|
height: TNumberDefaultType;
|
||||||
|
type: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IButtonSchema {
|
||||||
|
editData: TButtonEditData;
|
||||||
|
config: IButtonConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Button: IButtonSchema = {
|
||||||
|
editData: [
|
||||||
|
{
|
||||||
|
key: 'bgColor',
|
||||||
|
name: '背景色',
|
||||||
|
type: 'Color',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'height',
|
||||||
|
name: '高度',
|
||||||
|
type: 'Number',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'text',
|
||||||
|
name: '文字',
|
||||||
|
type: 'Text',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'fontSize',
|
||||||
|
name: '字体大小',
|
||||||
|
type: 'Number',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'color',
|
||||||
|
name: '文字颜色',
|
||||||
|
type: 'Color',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'align',
|
||||||
|
name: '对齐方式',
|
||||||
|
type: 'Select',
|
||||||
|
range: [
|
||||||
|
{
|
||||||
|
key: 'left',
|
||||||
|
text: '左对齐',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'center',
|
||||||
|
text: '居中对齐',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'right',
|
||||||
|
text: '右对齐',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
config: {
|
||||||
|
bgColor: 'rgba(0,0,0,1)',
|
||||||
|
text: '按钮 button 按钮 button 按钮 button',
|
||||||
|
color: 'rgba(255,255,255,1)',
|
||||||
|
align: 'center',
|
||||||
|
fontSize: 16,
|
||||||
|
height: 48,
|
||||||
|
type: 'primary',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
export default Button;
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
const template = {
|
||||||
|
type: 'Button',
|
||||||
|
h: 24,
|
||||||
|
x: 12,
|
||||||
|
};
|
||||||
|
export default template;
|
||||||
@ -6,6 +6,7 @@ import List from './List/schema';
|
|||||||
import LongText from './LongText/schema';
|
import LongText from './LongText/schema';
|
||||||
import Qrcode from './Qrcode/schema';
|
import Qrcode from './Qrcode/schema';
|
||||||
import Text from './Text/schema';
|
import Text from './Text/schema';
|
||||||
|
import Button from './Button/schema';
|
||||||
|
|
||||||
const basicSchema = {
|
const basicSchema = {
|
||||||
Footer,
|
Footer,
|
||||||
@ -15,6 +16,7 @@ const basicSchema = {
|
|||||||
List,
|
List,
|
||||||
LongText,
|
LongText,
|
||||||
Qrcode,
|
Qrcode,
|
||||||
Text
|
Text,
|
||||||
|
Button,
|
||||||
};
|
};
|
||||||
export default basicSchema;
|
export default basicSchema;
|
||||||
|
|||||||
@ -6,17 +6,9 @@ import List from './List/template';
|
|||||||
import LongText from './LongText/template';
|
import LongText from './LongText/template';
|
||||||
import Qrcode from './Qrcode/template';
|
import Qrcode from './Qrcode/template';
|
||||||
import Text from './Text/template';
|
import Text from './Text/template';
|
||||||
|
import Button from './Button/template';
|
||||||
|
|
||||||
const basicTemplate = [
|
const basicTemplate = [Footer, Header, Icon, Image, List, LongText, Qrcode, Text, Button];
|
||||||
Footer,
|
|
||||||
Header,
|
|
||||||
Icon,
|
|
||||||
Image,
|
|
||||||
List,
|
|
||||||
LongText,
|
|
||||||
Qrcode,
|
|
||||||
Text,
|
|
||||||
];
|
|
||||||
const BasicTemplate = basicTemplate.map(v => {
|
const BasicTemplate = basicTemplate.map(v => {
|
||||||
return { ...v, category: 'base' };
|
return { ...v, category: 'base' };
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,3 +1,5 @@
|
|||||||
|
import { type } from 'os';
|
||||||
|
|
||||||
////////////////////
|
////////////////////
|
||||||
export interface IUploadConfigType {
|
export interface IUploadConfigType {
|
||||||
key: string;
|
key: string;
|
||||||
@ -199,6 +201,13 @@ export type baseFormDateTpl = {
|
|||||||
placeholder: string;
|
placeholder: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type baseFormButtonTpl = {
|
||||||
|
key: string;
|
||||||
|
name: string;
|
||||||
|
type: 'Button';
|
||||||
|
icons: Array<any>;
|
||||||
|
};
|
||||||
|
|
||||||
export type baseFormUnion =
|
export type baseFormUnion =
|
||||||
| baseFormTextTpl
|
| baseFormTextTpl
|
||||||
| baseFormNumberTpl
|
| baseFormNumberTpl
|
||||||
@ -206,7 +215,8 @@ export type baseFormUnion =
|
|||||||
| baseFormMyRadioTpl
|
| baseFormMyRadioTpl
|
||||||
| baseFormMyCheckboxTpl
|
| baseFormMyCheckboxTpl
|
||||||
| baseFormMySelectTpl
|
| baseFormMySelectTpl
|
||||||
| baseFormDateTpl;
|
| baseFormDateTpl
|
||||||
|
| baseFormButtonTpl;
|
||||||
export type baseFormUnionType =
|
export type baseFormUnionType =
|
||||||
| baseFormTextTpl['type']
|
| baseFormTextTpl['type']
|
||||||
| baseFormNumberTpl['type']
|
| baseFormNumberTpl['type']
|
||||||
@ -214,6 +224,7 @@ export type baseFormUnionType =
|
|||||||
| baseFormMyRadioTpl['type']
|
| baseFormMyRadioTpl['type']
|
||||||
| baseFormMyCheckboxTpl['type']
|
| baseFormMyCheckboxTpl['type']
|
||||||
| baseFormMySelectTpl['type']
|
| baseFormMySelectTpl['type']
|
||||||
| baseFormDateTpl['type'];
|
| baseFormDateTpl['type']
|
||||||
|
| baseFormButtonTpl['type'];
|
||||||
|
|
||||||
export type TFormItemsDefaultType = Array<baseFormUnion>;
|
export type TFormItemsDefaultType = Array<baseFormUnion>;
|
||||||
|
|||||||
@ -84,7 +84,7 @@ export default function Layout({ children }: IRouteComponentProps) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const [state, setState] = useState<dooringContextType>('h5');
|
const [state, setState] = useState<dooringContextType>('h5');
|
||||||
|
debugger;
|
||||||
return (
|
return (
|
||||||
<dooringContext.Provider
|
<dooringContext.Provider
|
||||||
value={{
|
value={{
|
||||||
|
|||||||
@ -1,7 +1,9 @@
|
|||||||
import React, { useMemo, memo, ReactNode } from 'react';
|
import React, { useMemo, memo, ReactNode, useContext } from 'react';
|
||||||
import { useDrag } from 'react-dnd';
|
import { useDrag } from 'react-dnd';
|
||||||
import schema from 'components/BasicShop/schema';
|
import schemaH5 from 'components/BasicShop/schema';
|
||||||
|
import schemaPc from 'components/BasicPcShop/schema';
|
||||||
import styles from './index.less';
|
import styles from './index.less';
|
||||||
|
import { dooringContext } from '@/layouts';
|
||||||
|
|
||||||
interface TargetBoxProps {
|
interface TargetBoxProps {
|
||||||
item: any;
|
item: any;
|
||||||
@ -11,6 +13,14 @@ interface TargetBoxProps {
|
|||||||
|
|
||||||
const TargetBox = memo((props: TargetBoxProps) => {
|
const TargetBox = memo((props: TargetBoxProps) => {
|
||||||
const { item } = props;
|
const { item } = props;
|
||||||
|
const context = useContext(dooringContext);
|
||||||
|
const schema = useMemo(() => {
|
||||||
|
if (context.theme === 'h5') {
|
||||||
|
return schemaH5;
|
||||||
|
} else {
|
||||||
|
return schemaPc;
|
||||||
|
}
|
||||||
|
}, [context.theme]);
|
||||||
const [{ isDragging }, drag] = useDrag({
|
const [{ isDragging }, drag] = useDrag({
|
||||||
item: {
|
item: {
|
||||||
type: item.type,
|
type: item.type,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user