forked from shesha-io/shesha-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpreviewButton.tsx
More file actions
28 lines (24 loc) · 992 Bytes
/
previewButton.tsx
File metadata and controls
28 lines (24 loc) · 992 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import React, { FC } from 'react';
import { Button, ButtonProps } from 'antd';
import { EyeOutlined } from '@ant-design/icons';
import { useFormActions } from '@/providers';
import { useFormDesignerActions, useFormDesignerStateSelector } from '@/providers/formDesigner';
export interface IPreviewButtonProps extends Pick<ButtonProps, 'size'> {
}
export const PreviewButton: FC<IPreviewButtonProps> = (props) => {
const { setFormMode } = useFormActions();
const { setFormMode: setFormDesignerMode } = useFormDesignerActions();
const formMode = useFormDesignerStateSelector((x) => x.formMode);
return (
<Button
icon={<EyeOutlined />}
onClick={() => {
setFormMode(formMode === 'designer' ? 'edit' : 'designer');
setFormDesignerMode(formMode === 'designer' ? 'edit' : 'designer');
}}
type={formMode === 'designer' ? 'default' : 'primary'}
title="Preview"
size={props.size}
/>
);
};