diff --git a/src/editor/Catalog/index.tsx b/src/editor/Catalog/index.tsx index 4673222..2a916d4 100644 --- a/src/editor/Catalog/index.tsx +++ b/src/editor/Catalog/index.tsx @@ -1,20 +1,48 @@ import { Collapse } from "antd"; +import { useSelector } from "react-redux"; + +import { mapStateSelector } from "@store"; +import { IOverlay } from "@store"; import "./style.less"; const { Panel } = Collapse; +export type OverlayListProps = { + overlays: IOverlay[]; +}; + +const OverlayList = (props: OverlayListProps) => { + const { overlays } = props; + + return ( + <> + {overlays.map((overlay, index) => { + return ( +
+ {overlay.name} +
+ ); + })} + + ); +}; + const Catalog = () => { - const callback = (key: string | string[]) => console.log(key); + // const callback = (key: string | string[]) => console.log(key); + const { rectangles, polygons } = useSelector(mapStateSelector); return ( - - - + + + + + + ); }; diff --git a/src/editor/Catalog/style.less b/src/editor/Catalog/style.less index 7d9a586..2031058 100644 --- a/src/editor/Catalog/style.less +++ b/src/editor/Catalog/style.less @@ -2,4 +2,15 @@ padding: 6px 8px; font-size: 12px; background-color: #f7fafc; +} +.ant-collapse-content > .ant-collapse-content-box{ + padding: 4px 12px; + font-size: 12px; +} +.overlay-item{ + margin-bottom: 4px; + cursor: pointer; + &:hover, &[data-selected]{ + background-color: #f7fafc; + } } \ No newline at end of file diff --git a/src/store/index.ts b/src/store/index.ts index a9a29f0..025b589 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -1,10 +1,11 @@ import { createStore, Store } from "redux"; -import { createContext, Context, useContext } from "react"; +import { createContext, Context } from "react"; import { reducer, Action } from "./reducers"; import { IEditorState } from "./type"; import { EditorAction } from "./actions"; export * from "./type"; +export * from "./selectors"; type IStore = Store; const store: IStore = createStore(reducer); @@ -13,29 +14,8 @@ const store: IStore = createStore(reducer); export { store }; -// export class Store { -// // editorState: IEditorState; -// // mapState: IMapState; - -// constructor() { -// this.editorState = {}; -// this.mapState = { -// polygons: [], -// }; -// } - -// addPolygon() { -// // -// } -// } - export const editorAction = new EditorAction(); export const StoreContext = createContext( null ) as Context; - -// export const useStore = () => { -// const store = useReduxContext(StoreContext); -// return store; -// }; diff --git a/src/store/selectors.ts b/src/store/selectors.ts new file mode 100644 index 0000000..0fed680 --- /dev/null +++ b/src/store/selectors.ts @@ -0,0 +1,3 @@ +import { editorAction, IEditorState } from "@store"; + +export const mapStateSelector = (state: IEditorState) => state.map;