[Work in progress] A Reactjs-based web app to help with ricing: designing beautiful unix desktop environments.
git clone https://mcol.xyz/code/unix.sexy
Log | Files | Refs

commit 9d106d30e03e7aea09d6f1e7246a2c383033ab75
parent db9a87279c8c7363b1fb5b31aeee8fc767ce4ede
Author: mcol <mcol@posteo.net>
Date:   Tue, 30 Jun 2020 17:43:46 +0100

key -> id for windows; only draw textarea sample in window 0

Diffstat:
Msrc/features/window_content/index.js | 10++++++----
Msrc/features/windows/index.js | 16++++++++--------
Msrc/features/windows/slice.js | 8++++----
3 files changed, 18 insertions(+), 16 deletions(-)

diff --git a/src/features/window_content/index.js b/src/features/window_content/index.js @@ -22,16 +22,17 @@ export default function WindowContent(props) { style.height = `calc(100% - ${titleBars.width}px)` }; - //let text = "[charlie@chocfactory ~]$\n[charlie@chocfactory ~]$ scrot"; - - let text = "[charlie@chocfactory ~]$ sb () {\n> sed 's/.*/\L&/g; s/\(.\{1\}\)\(.\)/\\1\U\\2/g' <<< \"$@\"\n> }\n[charlie@chocfactory ~]$ sb btw i use arch\nbTw i uSe aRcH"; - + var text = ""; + if (props.id === 0) { + text = "[charlie@chocfactory ~]$ sb () {\n> sed 's/.*/\L&/g; s/\(.\{1\}\)\(.\)/\\1\U\\2/g' <<< \"$@\"\n> }\n[charlie@chocfactory ~]$ sb btw i use arch\nbTw i uSe aRcH"; + }; return ( <div className="window-content" style={style} > + {windowContent.text && <textarea style={{ ...windowContentCSS, @@ -39,6 +40,7 @@ export default function WindowContent(props) { > {text} </textarea> + } </div> ); }; diff --git a/src/features/windows/index.js b/src/features/windows/index.js @@ -31,7 +31,7 @@ export default function Windows() { }; return ( - positions.map((position, key) => { + positions.map((position, id) => { return ( <Rnd bounds="parent" @@ -47,22 +47,22 @@ export default function Windows() { x: position.x, y: position.y }} onDragStop={ - (e, d) => {dispatch(dragWindow({key: key, x: d.x, y: d.y}))} + (e, d) => {dispatch(dragWindow({key: id, x: d.x, y: d.y}))} } onResizeStop={ - (e, dir, ref, d, pos) => {dispatch(resizeWindow({key: key, d:d }))} + (e, dir, ref, d, pos) => {dispatch(resizeWindow({key: id, d:d }))} } - id={key} + id={id} className="Window" - style={(key === focussed) ? focusStyle : style} - onClick={() => setFocus(key)} + style={(id === focussed) ? focusStyle : style} + onClick={() => setFocus(id)} > <TitleBar - focussed={(key === focussed)} + focussed={(id === focussed)} /> - <WindowContent /> + <WindowContent id={id}/> </Rnd> ) diff --git a/src/features/windows/slice.js b/src/features/windows/slice.js @@ -26,13 +26,13 @@ export const windowSlice = createSlice({ }, dragWindow: (state, action) => { - state[action.payload.key].x = action.payload.x - state[action.payload.key].y = action.payload.y + state[action.payload.id].x = action.payload.x + state[action.payload.id].y = action.payload.y }, resizeWindow: (state, action) => { - state[action.payload.key].width += action.payload.d.width - state[action.payload.key].height += action.payload.d.height + state[action.payload.id].width += action.payload.d.width + state[action.payload.id].height += action.payload.d.height }, }, });