-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(app-board): add initial panel ui
- Loading branch information
Showing
12 changed files
with
190 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
packages/game-app/src/gameView/components/ConnectedCard/ConnectedCard.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import React from 'react'; | ||
import { useSelector } from 'react-redux'; | ||
import { selectors } from '../../slice'; | ||
import { Card } from '@pipeline/components'; | ||
|
||
type Props = { | ||
id: string; | ||
}; | ||
|
||
const ConnectedCard: React.FC<Props> = ({ id }) => { | ||
const cardData = useSelector(selectors.getCardById(id))!; | ||
|
||
return <Card {...cardData} />; | ||
}; | ||
|
||
ConnectedCard.displayName = 'ConnectedCard'; | ||
|
||
export default ConnectedCard; |
3 changes: 3 additions & 0 deletions
3
packages/game-app/src/gameView/components/ConnectedCard/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import ConnectedCard from './ConnectedCard'; | ||
|
||
export default ConnectedCard; |
55 changes: 55 additions & 0 deletions
55
packages/game-app/src/gameView/components/DeckPanel/DeckPanel.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import React from 'react'; | ||
import DraggableCard from '../DraggableCard'; | ||
import styled from 'styled-components'; | ||
import { CardWrapper } from '../DraggableCard/DraggableCard'; | ||
|
||
function createStackedCss() { | ||
let cssString = ''; | ||
for (let i = 0; i < 100; i++) { | ||
cssString += ` | ||
${CardWrapper}:nth-child(${i + 1}){ | ||
position: absolute; | ||
top: ${110 * i}px; | ||
transition: transform .3s; | ||
} | ||
${CardWrapper}:hover{ | ||
transform: translate(0, -100px); | ||
} | ||
`; | ||
} | ||
return cssString; | ||
} | ||
|
||
const DeckPanelContent = styled.div` | ||
flex: 1 1 auto; | ||
overflow-y: scroll; | ||
position: relative; | ||
::-webkit-scrollbar { | ||
display: none; | ||
} | ||
${CardWrapper} + ${CardWrapper} { | ||
margin-top: 8px; | ||
} | ||
${createStackedCss()} | ||
`; | ||
|
||
type Props = { | ||
cardsIds: string[]; | ||
}; | ||
|
||
const DeckPanel: React.FC<Props> = ({ cardsIds }) => { | ||
return ( | ||
<DeckPanelContent> | ||
{cardsIds.map(id => ( | ||
<DraggableCard key={id} id={id} /> | ||
))} | ||
</DeckPanelContent> | ||
); | ||
}; | ||
|
||
DeckPanel.displayName = 'Panel'; | ||
|
||
export default DeckPanel; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import DeckPanel from './DeckPanel'; | ||
|
||
export default DeckPanel; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
packages/game-app/src/gameView/components/DroppablePanelArea/DroppablePanelArea.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import React, { useState } from 'react'; | ||
import { useDroppable } from '@dnd-kit/core'; | ||
import styled from 'styled-components'; | ||
import Box from '../../../_shared/components/Box'; | ||
|
||
type Props = {}; | ||
|
||
const FixedPanel = styled.div<{ closed: boolean }>` | ||
position: fixed; | ||
top: 0; | ||
right: 0; | ||
width: 360px; | ||
height: 100vh; | ||
border-radius: 40px 0px 0px 0px; | ||
opacity: 1; | ||
backdrop-filter: blur(30px); | ||
padding: 40px 40px 0 40px; | ||
box-sizing: border-box; | ||
background-color: rgb(170, 180, 175, 0.4); | ||
display: flex; | ||
flex-direction: column; | ||
transition: transform 0.5s; | ||
${props => props.closed && 'transform: translate(300px)'} | ||
`; | ||
|
||
const ToggleWrapper = styled.div` | ||
position: absolute; | ||
top: 0; | ||
bottom: 0; | ||
left: 0; | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
`; | ||
|
||
const ToggleButton = styled.button` | ||
min-width: 20px; | ||
height: 40px; | ||
padding: 0; | ||
margin: 0; | ||
background: transparent; | ||
border: none; | ||
border-radius: 9px; | ||
`; | ||
|
||
const ToggleIndicator = styled.div` | ||
width: 3px; | ||
height: 100%; | ||
padding: 0; | ||
margin: 0; | ||
background: #b4aea9; | ||
border: none; | ||
border-radius: 9px; | ||
position: relative; | ||
left: 8px; | ||
`; | ||
|
||
/** | ||
* The right game panel, where the deck is placed at the start of the game | ||
* and where you can find all cards that ar not placed into the board. | ||
* It is also a droppable are, where you can release cards moved out from the board | ||
*/ | ||
const DroppablePanelArea: React.FC<Props> = ({ children }) => { | ||
const { setNodeRef } = useDroppable({ | ||
id: 'panel', | ||
}); | ||
|
||
const [closed, setClosed] = useState(false); | ||
|
||
return ( | ||
<FixedPanel ref={setNodeRef} closed={closed}> | ||
<ToggleWrapper> | ||
<ToggleButton onClick={() => setClosed(state => !state)}> | ||
<ToggleIndicator /> | ||
</ToggleButton> | ||
</ToggleWrapper> | ||
{children} | ||
</FixedPanel> | ||
); | ||
}; | ||
|
||
DroppablePanelArea.displayName = 'DroppablePanelArea'; | ||
|
||
export default DroppablePanelArea; |
3 changes: 3 additions & 0 deletions
3
packages/game-app/src/gameView/components/DroppablePanelArea/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import DroppablePanelArea from './DroppablePanelArea'; | ||
|
||
export default DroppablePanelArea; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters