Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: official-layer 新增收起展开功能 #31

Merged
merged 3 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
185 changes: 104 additions & 81 deletions src/components/map-control-group/official-layer-control/index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import {
CaretRightOutlined,
DeleteOutlined,
FormOutlined,
MinusCircleOutlined,
PlusOutlined,
UploadOutlined,
} from '@ant-design/icons';
import { CustomControl, RasterLayer } from '@antv/larkmap';
import { useLocalStorageState } from 'ahooks';
import type { UploadFile, UploadProps } from 'antd';
import { Button, Form, Input, Modal, Popconfirm, Space, Upload } from 'antd';
import classNames from 'classnames';
Expand Down Expand Up @@ -43,6 +45,12 @@ export function OfficialLayerControl() {
const [editIndex, setEditIndex] = useState(-1);
const [base64, setBase64] = useState<any>(null);
const [fileList, setFileList] = useState<UploadFile[]>([]);
const [hideOfficeLayer, setHideOfficeLayer] = useLocalStorageState<boolean>(
'hideOfficeLayer',
{
defaultValue: true,
},
);

const handleOk = () => {
form.submit();
Expand Down Expand Up @@ -230,103 +238,118 @@ export function OfficialLayerControl() {
<>
<CustomControl position="bottomleft">
<div className={styles.mapTab}>
<div className={styles.amapInfo}>
{officeLayerGroup.map((item, index) => {
return (
<div
key={item.type}
className={classNames([
styles.amapInfoItem,
item.type === radioValue
? styles.itemBorderActive
: styles.itemBorder,
index === officeLayerGroup.length - 1 ? 'item-hover' : '',
])}
onClick={() => {
onItemClick(item);
}}
>
{index > 1 && (
<Popconfirm
title={t('official_layer_control.index.shanChuDiTu')}
onConfirm={(e) => onConfirm(e, item)}
onCancel={(
e: React.MouseEvent<HTMLElement> | undefined,
) => {
e?.stopPropagation();
}}
>
<div
className={styles.hideOfficeLayerBtn}
onClick={() => {
setHideOfficeLayer(!hideOfficeLayer);
}}
>
<CaretRightOutlined
style={{
transform: hideOfficeLayer ? 'rotate(-180deg)' : undefined,
}}
/>
</div>
{hideOfficeLayer && (
<div className={styles.amapInfo}>
{officeLayerGroup.map((item, index) => {
return (
<div
key={item.type}
className={classNames([
styles.amapInfoItem,
item.type === radioValue
? styles.itemBorderActive
: styles.itemBorder,
index === officeLayerGroup.length - 1 ? 'item-hover' : '',
])}
onClick={() => {
onItemClick(item);
}}
>
{index > 1 && (
<Popconfirm
title={t('official_layer_control.index.shanChuDiTu')}
onConfirm={(e) => onConfirm(e, item)}
onCancel={(
e: React.MouseEvent<HTMLElement> | undefined,
) => {
e?.stopPropagation();
}}
>
<div
className={'item-clear'}
onClick={(e) => {
e.stopPropagation();
}}
>
<DeleteOutlined />
</div>
</Popconfirm>
)}
{index > 1 && (
<div
className={'item-clear'}
className={'item-edit'}
onClick={(e) => {
setEditIndex(index);
e.stopPropagation();
}}
>
<DeleteOutlined />
</div>
</Popconfirm>
)}
{index > 1 && (
<div
className={'item-edit'}
onClick={(e) => {
setEditIndex(index);
e.stopPropagation();
setIsEdit(true);
setIsModalOpen(true);
setFileList([
{
uid: '-1',
name: `${item.title}`,
status: 'done',
url: item.image,
},
]);
form.setFieldsValue({
name: item.title,
urls: item.layers,
img: [
setIsEdit(true);
setIsModalOpen(true);
setFileList([
{
uid: '-1',
name: `${item.title}`,
status: 'done',
url: item.image,
},
],
});
}}
]);
form.setFieldsValue({
name: item.title,
urls: item.layers,
img: [
{
uid: '-1',
name: `${item.title}`,
status: 'done',
url: item.image,
},
],
});
}}
>
<FormOutlined />
</div>
)}
<img
src={item.image}
alt=""
className={styles.amapInfoItemImage}
/>
<div
className={styles.amapInfoItemTitle}
style={{ marginTop: 0 }}
>
<FormOutlined />
{item.title}
</div>
)}
<img
src={item.image}
alt=""
className={styles.amapInfoItemImage}
/>
<div
className={styles.amapInfoItemTitle}
style={{ marginTop: 0 }}
>
{item.title}
</div>
</div>
);
})}
<div className={classNames(['add-map'])}>
<div
onClick={() => {
setIsModalOpen(true);
form.resetFields();
}}
>
<div className={styles.addMapIcon}>
<PlusOutlined />
);
})}
<div className="add-map">
<div
onClick={() => {
setIsModalOpen(true);
form.resetFields();
}}
>
<div className={styles.addMapIcon}>
<PlusOutlined />
</div>
</div>
</div>
</div>
</div>
)}
</div>

<Modal
title={t('official_layer_control.index.tianJiaDitu')}
open={isModalOpen}
Expand Down
22 changes: 20 additions & 2 deletions src/components/map-control-group/official-layer-control/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ import { theme } from 'antd';
const useStyle = () => {
const { useToken } = theme;
const { token } = useToken();
const { colorBgElevated, colorBgContainer, colorText } = token;
const { colorBgElevated, colorBgContainer, colorText, colorIcon } = token;
return {
mapTab: css`
background-color: ${colorBgElevated};
border-radius: 4px;
display: flex;
align-items: center;
&:hover .add-map {
display: block;
}
Expand All @@ -21,6 +23,22 @@ const useStyle = () => {
}
}
`,
hideOfficeLayerBtn: css`
height: 127px;
width: 20px;
display: flex;
align-items: center;
justify-content: center;
background: ${colorBgElevated};
border-radius: 4px;
cursor: pointer;
font-size: 16px;
z-index: 2;
.anticon {
transition: all 0.2s;
}
color: ${colorIcon};
`,
amapInfo: css`
display: flex;
align-items: center;
Expand Down Expand Up @@ -65,7 +83,7 @@ const useStyle = () => {

&:hover {
color: #1677ff;
}
}
}

.item-clear {
Expand Down
Loading