-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
431 additions
and
242 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
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
69 changes: 31 additions & 38 deletions
69
src/components/mindset/components/PlayerContols/ProgressBar/index.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 |
---|---|---|
@@ -1,64 +1,57 @@ | ||
import { LinearProgress } from '@mui/material' | ||
import { Slider } from '@mui/material' | ||
import styled from 'styled-components' | ||
import { Flex } from '~/components/common/Flex' | ||
import { Tooltip } from '~/components/common/ToolTip' | ||
import { NodeExtended } from '~/types' | ||
import { colors } from '~/utils' | ||
import { Marker } from '../../Marker' | ||
|
||
type Props = { | ||
duration: number | ||
progress: number | ||
markers: NodeExtended[] | ||
playingTIme: number | ||
handleProgressChange: (_: Event, value: number | number[]) => void | ||
} | ||
|
||
export const ProgressBar = ({ duration, progress, markers }: Props) => ( | ||
export const ProgressBar = ({ duration, markers, handleProgressChange, playingTIme }: Props) => ( | ||
<ProgressWrapper> | ||
<Progress value={progress} variant="determinate" /> | ||
<ProgressSlider max={duration} onChange={handleProgressChange} value={playingTIme} /> | ||
{markers.map((node) => { | ||
const position = ((node?.start || 0) / duration) * 100 | ||
const type = node?.node_type || '' | ||
const name = node?.properties?.name || '' | ||
|
||
return ( | ||
<MarkerWrapper key={node?.ref_id} style={{ left: `${position}%` }}> | ||
<Tooltip content={`${node?.properties?.name || type}`}> | ||
<Marker type={type} /> | ||
</Tooltip> | ||
</MarkerWrapper> | ||
) | ||
return <Marker key={node.ref_id} left={position} name={name} type={type} /> | ||
})} | ||
</ProgressWrapper> | ||
) | ||
|
||
const Progress = styled(LinearProgress)` | ||
&& { | ||
height: 2px; | ||
background-color: ${colors.white}; | ||
color: blue; | ||
flex-grow: 1; | ||
.MuiLinearProgress-bar { | ||
background: ${colors.GRAY6}; | ||
} | ||
} | ||
` | ||
|
||
const ProgressWrapper = styled(Flex)` | ||
position: relative; | ||
flex: 1 1 100%; | ||
` | ||
|
||
const MarkerWrapper = styled.div` | ||
position: absolute; | ||
top: -4px; /* Adjust as needed to center above the progress bar */ | ||
width: 8px; | ||
height: 8px; | ||
background-color: ${colors.white}; | ||
border-radius: 50%; | ||
transform: translateX(-50%); /* Center the marker horizontally */ | ||
transform: translateX(-50%) translateY(-50%); | ||
top: 50%; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
const ProgressSlider = styled(Slider)` | ||
&& { | ||
z-index: 20; | ||
color: ${colors.white}; | ||
height: 3px; | ||
width: calc(100% - 12px); | ||
box-sizing: border-box; | ||
.MuiSlider-track { | ||
border: none; | ||
} | ||
.MuiSlider-thumb { | ||
width: 10px; | ||
height: 10px; | ||
background-color: ${colors.white}; | ||
&:before { | ||
box-shadow: '0 4px 8px rgba(0,0,0,0.4)'; | ||
} | ||
&:hover, | ||
&.Mui-focusVisible, | ||
&.Mui-active { | ||
box-shadow: none; | ||
} | ||
} | ||
} | ||
` |
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
45 changes: 45 additions & 0 deletions
45
src/components/mindset/components/Scene/Board/Edges/index.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,45 @@ | ||
import { useMemo } from 'react' | ||
import { Vector3 } from 'three' | ||
|
||
type Props = { | ||
sourcePosition: { x: number; y: number; z: number } | ||
targetPosition: { x: number; y: number; z: number } | ||
color?: string | ||
arrowSize?: number | ||
} | ||
|
||
export const Edge = ({ sourcePosition, targetPosition, color = 'white', arrowSize = 1 }: Props) => { | ||
const points = useMemo(() => { | ||
const start = new Vector3(sourcePosition.x, sourcePosition.y, sourcePosition.z) | ||
const end = new Vector3(targetPosition.x, targetPosition.y, targetPosition.z) | ||
const direction = new Vector3().subVectors(end, start).normalize() | ||
|
||
// Calculate arrowhead points | ||
const arrowLeft = new Vector3() | ||
.copy(direction) | ||
.multiplyScalar(-arrowSize) | ||
.applyAxisAngle(new Vector3(0, 0, 1), Math.PI / 6) | ||
|
||
const arrowRight = new Vector3() | ||
.copy(direction) | ||
.multiplyScalar(-arrowSize) | ||
.applyAxisAngle(new Vector3(0, 0, 1), -Math.PI / 6) | ||
|
||
// Return line points + arrowhead points | ||
return [start, end, end.clone(), end.clone().add(arrowLeft), end.clone(), end.clone().add(arrowRight)] | ||
}, [sourcePosition, targetPosition, arrowSize]) | ||
|
||
return ( | ||
<line> | ||
<bufferGeometry> | ||
<bufferAttribute | ||
array={new Float32Array(points.flatMap((p) => [p.x, p.y, p.z]))} | ||
attach="attributes-position" | ||
count={points.length} | ||
itemSize={3} | ||
/> | ||
</bufferGeometry> | ||
<lineBasicMaterial color={color} /> | ||
</line> | ||
) | ||
} |
Oops, something went wrong.