Skip to content

Commit

Permalink
Merge pull request #1067 from xieliuduo/dev-namelist
Browse files Browse the repository at this point in the history
feat:LayerList in left
  • Loading branch information
scottsut authored Mar 22, 2022
2 parents a1dc0b2 + c94f2d7 commit 0ecc1c7
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import { BoardActionContext } from 'app/pages/DashBoardPage/components/BoardProv
import React, { useContext } from 'react';
import styled from 'styled-components/macro';
import { BoardToolBar } from '../components/BoardToolBar/BoardToolBar';
import { LayerList } from '../components/LayerList/LayerList';
import SlideSetting from '../components/SlideSetting/SlideSetting';
import { AutoBoardEditor } from './AutoBoardEditor';
const AutoEditor: React.FC<{}> = () => {
Expand All @@ -45,6 +46,7 @@ const AutoEditor: React.FC<{}> = () => {
<Wrapper onClick={onClearActiveWidgets}>
<BoardToolBar />
<Editor>
<LayerList />
<AutoBoardEditor />
<SlideSetting />
</Editor>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import React from 'react';
import { useDispatch } from 'react-redux';
import styled from 'styled-components/macro';
import { BoardToolBar } from '../components/BoardToolBar/BoardToolBar';
import { LayerList } from '../components/LayerList/LayerList';
import SlideSetting from '../components/SlideSetting/SlideSetting';
import { editDashBoardInfoActions, editWidgetInfoActions } from '../slice';
import { FreeEditorWrapper } from './FreeEditorWrapper';
Expand All @@ -38,6 +39,7 @@ const FreeEditor: React.FC = () => {
<Wrapper>
<BoardToolBar />
<Editor>
<LayerList />
<FreeEditorWrapper />
<SlideSetting />
</Editor>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,21 @@
* limitations under the License.
*/
import { WidgetAllProvider } from 'app/pages/DashBoardPage/components/WidgetProvider/WidgetAllProvider';
import { WidgetType } from 'app/pages/DashBoardPage/pages/Board/slice/types';
import produce from 'immer';
import React, { useCallback, useEffect, useState } from 'react';
import { memo, useCallback, useEffect, useState } from 'react';
import { DndProvider } from 'react-dnd';
import { HTML5Backend } from 'react-dnd-html5-backend';
import { useDispatch, useSelector } from 'react-redux';
import styled from 'styled-components/macro';
import { editBoardStackActions, editWidgetInfoActions } from '../../../slice';
import { updateWidgetConf } from '../../../slice/childSlice/stackSlice';
import { WidgetType } from '../../../Board/slice/types';
import { editBoardStackActions, editWidgetInfoActions } from '../../slice';
import { updateWidgetConf } from '../../slice/childSlice/stackSlice';
import {
selectAllWidgetInfoMap,
selectSortAllWidgets,
} from '../../../slice/selectors';
} from '../../slice/selectors';
import NameItem from './NameItem';

export interface IProps {}
const withDnd: React.FC<IProps> = props => {
return (
<DndProvider backend={HTML5Backend}>
<WidgetNameList />
</DndProvider>
);
};

export default withDnd;

export type NameCard = {
index: number;
name: string;
Expand All @@ -50,7 +39,7 @@ export type NameCard = {
editing: boolean;
selected: boolean;
};
export const WidgetNameList: React.FC<IProps> = () => {
export const LayerList: React.FC<{}> = memo(() => {
const dispatch = useDispatch();
const allWidgetsInfo = useSelector(selectAllWidgetInfoMap);
const sortLayoutWidgets = useSelector(selectSortAllWidgets);
Expand Down Expand Up @@ -109,7 +98,6 @@ export const WidgetNameList: React.FC<IProps> = () => {
const clearSelectedWidgets = () => {
dispatch(editWidgetInfoActions.clearSelectedWidgets());
};
//

const nameList = cards
.sort((a, b) => b.index - a.index)
Expand All @@ -127,12 +115,35 @@ export const WidgetNameList: React.FC<IProps> = () => {
</WidgetAllProvider>
));
return (
<NamesWrap onClick={clearSelectedWidgets}>
<div>{nameList}</div>
</NamesWrap>
<DndProvider backend={HTML5Backend}>
<Wrap onClick={clearSelectedWidgets}>
<h3 className="title">组件</h3>
<div className="nameList">{nameList}</div>
<div className="bottom"></div>
</Wrap>
</DndProvider>
);
};
const NamesWrap = styled.div`
width: 100%;
height: 400px;
});
const Wrap = styled.div`
display: flex;
flex-direction: column;
width: 190px;
min-width: 190px;
overflow-y: auto;
background-color: ${p => p.theme.componentBackground};
box-shadow: ${p => p.theme.shadowSider};
& .title {
padding: 5px;
text-align: center;
}
& .nameList {
min-height: 0;
padding: 0 10px;
overflow-y: auto;
}
& .bottom {
padding: 5px;
text-align: center;
}
`;
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ import { DropTargetMonitor, useDrag, useDrop } from 'react-dnd';
import { useDispatch } from 'react-redux';
import styled from 'styled-components/macro';
import { PRIMARY } from 'styles/StyleConstants';
import { editWidgetInfoActions } from '../../../slice';
import { NameCard } from './WidgetNameList';
import { editWidgetInfoActions } from '../../slice';
import { NameCard } from './LayerList';

export interface NameItemProps {
index: number;
Expand Down Expand Up @@ -171,7 +171,10 @@ const NameItem: React.FC<NameItemProps> = ({
data-handler-id={handlerId}
style={{ opacity }}
>
{card.name || 'untitled-widget'}
<span className="name" title={card.name || 'untitled-widget'}>
{card.name || 'untitled-widget'}
</span>

<WidgetActionDropdown widget={widget} />
</div>
</ItemWrap>
Expand All @@ -190,6 +193,12 @@ const ItemWrap = styled.div<{ selected: boolean }>`
white-space: nowrap;
cursor: move;
background-color: ${p => p.theme.componentBackground};
.name {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
}
.selected-Item {
background-color: ${p => p.theme.emphasisBackground};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const NameSet: FC<{

return (
<>
<Form.Item label={t('title')} preserve name="name">
<Form.Item preserve name="name">
<Input className="datart-ant-input" placeholder="fill a name" />
</Form.Item>
<Form.Item valuePropName="checked" name={['nameConfig', 'show']}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ import BorderSet from './SettingItem/BorderSet';
import NameSet from './SettingItem/NameSet';
import PaddingSet from './SettingItem/PaddingSet';
import { Group, SettingPanel } from './SettingPanel';
import { WidgetNameList } from './WidgetList/WidgetNameList';

const { Panel } = Collapse;
export const WidgetSetting: FC = memo(() => {
Expand Down Expand Up @@ -117,7 +116,7 @@ export const WidgetSetting: FC = memo(() => {
preserve
>
<Collapse
defaultActiveKey={['widgetList']}
defaultActiveKey={['name', 'background']}
className="datart-config-panel"
ghost
>
Expand Down Expand Up @@ -174,11 +173,6 @@ export const WidgetSetting: FC = memo(() => {
<AutoUpdateSet />
</Group>
</Panel>
<Panel header={t('widgetList')} key="widgetList">
<Group>
<WidgetNameList />
</Group>
</Panel>
</Collapse>
</Form>
</SettingPanel>
Expand Down

0 comments on commit 0ecc1c7

Please sign in to comment.