From 78704ebc0e1ffe1933b43504e3cfc46c4ab4e0aa Mon Sep 17 00:00:00 2001 From: teramotodaiki Date: Fri, 22 Nov 2019 11:39:50 +0900 Subject: [PATCH] feat: map thumbnail, remove officials --- src/FloorView.tsx | 5 ++- src/MapView.tsx | 64 +++++++++++++++++++------------------- src/example.tsx | 18 +++++++++-- src/store/floor.ts | 13 +++++--- src/store/types.ts | 2 +- src/styles/floor-view.scss | 1 + src/styles/map-view.scss | 1 + 7 files changed, 64 insertions(+), 40 deletions(-) diff --git a/src/FloorView.tsx b/src/FloorView.tsx index 54c8989..89be22b 100644 --- a/src/FloorView.tsx +++ b/src/FloorView.tsx @@ -51,7 +51,10 @@ export function FloorItem({ map, stage, selected }: FloorItemProps) { onClick={onClick} > {stage} -
+
); } diff --git a/src/MapView.tsx b/src/MapView.tsx index bc57177..74d2129 100644 --- a/src/MapView.tsx +++ b/src/MapView.tsx @@ -2,17 +2,17 @@ import classNames from 'classnames'; import * as React from 'react'; import { useDispatch, useSelector } from 'react-redux'; import { Button } from './Button'; +import { Scroller } from './Scroller'; +import { actions, EditorMode, GameMap, SS } from './store'; import flex from './styles/flex.scss'; -import map from './styles/map-view.scss'; +import style from './styles/map-view.scss'; import selector from './styles/selector.scss'; -import { Scroller } from './Scroller'; -import { actions, EditorMode, SS } from './store'; -export type Tab = 'mine' | 'official' | 'others'; +export type Tab = 'mine' | 'ours'; type Refs = { [tab in Tab]: React.RefObject; }; -export const tabs: Tab[] = ['mine', 'official', 'others']; +export const tabs: Tab[] = ['mine', 'ours']; export interface MapViewProps {} @@ -20,8 +20,7 @@ export function MapView({ }: MapViewProps) { const [tab, setTab] = React.useState('mine'); const refs: Refs = { mine: React.useRef(null), - official: React.useRef(null), - others: React.useRef(null) + ours: React.useRef(null) }; const handleScroll = React.useCallback((e: React.UIEvent) => { @@ -47,8 +46,13 @@ export function MapView({ }: MapViewProps) { const selected = useSelector((state: SS) => state.floor.selected); + const maps: { [key in Tab]: GameMap[] } = { + mine: useSelector((state: SS) => state.floor.mine), + ours: useSelector((state: SS) => state.floor.ours) + }; + return ( -
+

Choose background of map{selected}

-
- + {tabs.map(id => ( -
- {Array.from({ length: 15 }).map((_, i) => ( - +
+ {maps[id].map(map => ( + ))}
))} @@ -92,22 +87,27 @@ export function MapView({ }: MapViewProps) { ); } -export interface MapViewItemProps {} +export interface MapViewItemProps { + map: GameMap; +} -export function MapViewItem({ }: MapViewItemProps) { +export function MapViewItem({ map }: MapViewItemProps) { const dispatch = useDispatch(); const onClick = React.useCallback(() => { dispatch(actions.setEditorMode(EditorMode.Code)); }, []); return ( -
-
-
-
+
+
+
+
- TITLE - by Author + {map.name} + by {map.authorName}