Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(web): timeline with padding #853

Merged
merged 21 commits into from
Dec 22, 2023
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
2ea6c2f
change input orders
mkumbobeaty Nov 20, 2023
ae6447a
chore(web): fix WAS gap
KaWaite Nov 20, 2023
5ef59b4
chore(web): fix camera behavior in interaction mode (#824)
keiya01 Nov 20, 2023
0271762
chore(server): modify zoom level in manifest (#807)
nina992 Nov 21, 2023
af67c1d
Revert "chore(web): fix camera behavior in interaction mode (#824)"
mkumbobeaty Nov 22, 2023
c58f7db
Merge branch 'main' of github.com:reearth/reearth
mkumbobeaty Nov 22, 2023
14ab2e5
revert unsposed changes
mkumbobeaty Nov 22, 2023
3cd43c3
Merge branch 'main' of github.com:reearth/reearth
mkumbobeaty Nov 27, 2023
a2fd84e
Merge branch 'main' of github.com:reearth/reearth
mkumbobeaty Nov 28, 2023
88792a7
Merge branch 'main' of github.com:reearth/reearth
mkumbobeaty Nov 30, 2023
4477d3f
Merge branch 'main' of github.com:reearth/reearth
mkumbobeaty Dec 4, 2023
574e5a5
improve click when padding is introduced
mkumbobeaty Dec 5, 2023
6969fbb
imptove timeline UI
mkumbobeaty Dec 5, 2023
cf520cc
Merge branch 'main' of github.com:reearth/reearth into chore/timeline-ux
mkumbobeaty Dec 6, 2023
de4e072
fix UI issue
mkumbobeaty Dec 8, 2023
3106ec8
remove console
mkumbobeaty Dec 8, 2023
220a258
Merge branch 'main' of github.com:reearth/reearth into chore/timeline-ux
mkumbobeaty Dec 8, 2023
a097ecc
Merge branch 'main' of github.com:reearth/reearth into chore/timeline-ux
mkumbobeaty Dec 14, 2023
f4c46b1
define default padding in one file
mkumbobeaty Dec 14, 2023
abdd4ca
refactor padding to use resize
mkumbobeaty Dec 14, 2023
8820171
Merge branch 'main' of github.com:reearth/reearth into chore/timeline-ux
mkumbobeaty Dec 22, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
187 changes: 112 additions & 75 deletions web/src/beta/lib/core/StoryPanel/Block/builtin/Timeline/Editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,22 @@ import { styled } from "@reearth/services/theme";

import { TimelineValues } from ".";

const DEFAULT_PADDING = 40;
export type PaddingProp = {
bottom: number;
top: number;
left?: number;
right?: number;
};

type TimelineProps = {
blockId?: string;
isSelected?: boolean;
timelineValues?: TimelineValues;
inEditor?: boolean;
playMode?: string;
padding?: PaddingProp;
property?: any;
};

const TimelineEditor = ({
Expand All @@ -21,9 +31,10 @@ const TimelineEditor = ({
timelineValues,
inEditor,
playMode,
padding,
property,
}: TimelineProps) => {
const t = useT();

const {
currentTime,
range,
Expand All @@ -50,6 +61,7 @@ const TimelineEditor = ({
selected,
sliderPosition,
isActive,
paddingCheck,
handleOnSelect,
handlePopOver,
toggleIsPlaying,
Expand All @@ -67,6 +79,8 @@ const TimelineEditor = ({
inEditor,
speed,
playMode,
padding,
property,
onPlay,
onSpeedChange,
onPause,
Expand All @@ -81,53 +95,57 @@ const TimelineEditor = ({

return (
<Wrapper>
<TimelineControl>
<StyledIcon activeBlock={isActive}>
<Icon icon="timelineStoryBlockSolid" size={16} />
</StyledIcon>
<PlayControl>
<PlayButton
isClicked={true}
isPlaying={isPlayingReversed}
onClick={toggleIsPlayingReversed}>
<Icon icon="timelinePlayLeft" />
</PlayButton>
<PlayButton
isPlaying={isPause}
isClicked={isPlaying || isPlayingReversed || isPause}
onClick={() => {
if (isPlaying || isPlayingReversed || isPause) {
toggleIsPause();
}
}}>
<Icon icon="pause" />
</PlayButton>
<PlayButton isClicked={true} isPlaying={isPlaying} onClick={toggleIsPlaying}>
<Icon icon="timelinePlayRight" />
</PlayButton>
</PlayControl>
<Popover.Provider open={isOpen} placement="bottom-start" onOpenChange={handlePopOver}>
<Popover.Trigger asChild>
<InputWrapper onClick={handlePopOver}>
<Select>{selected && t(`${selected}`)}</Select>
<ArrowIcon icon="arrowDown" open={isOpen} size={16} />
</InputWrapper>
</Popover.Trigger>
<PickerWrapper attachToRoot>
{playSpeedOptions?.map((playSpeed, key) => (
<InputOptions
key={key}
value={playSpeed.seconds}
onClick={() => {
handleOnSelect(playSpeed.timeString, playSpeed.seconds);
}}>
{playSpeed.timeString}
</InputOptions>
))}
</PickerWrapper>
</Popover.Provider>
<CurrentTime>{currentTime && formattedCurrentTime}</CurrentTime>
</TimelineControl>
<TimelineWrapper padding={paddingCheck}>
<TimelineControl padding={paddingCheck}>
<StyledIcon activeBlock={isActive}>
<Icon icon="timelineStoryBlockSolid" size={16} />
</StyledIcon>
<PlayControl padding={paddingCheck}>
<PlayButton
isClicked={true}
isPlaying={isPlayingReversed}
onClick={toggleIsPlayingReversed}>
<Icon icon="timelinePlayLeft" size={14} />
</PlayButton>
<PlayButton
isPlaying={isPause}
isClicked={isPlaying || isPlayingReversed || isPause}
onClick={() => {
if (isPlaying || isPlayingReversed || isPause) {
toggleIsPause();
}
}}>
<Icon icon="pause" size={14} />
</PlayButton>
<PlayButton isClicked={true} isPlaying={isPlaying} onClick={toggleIsPlaying}>
<Icon icon="timelinePlayRight" size={14} />
</PlayButton>
</PlayControl>
<PopoverWrapper padding={paddingCheck}>
<Popover.Provider open={isOpen} placement="bottom-start" onOpenChange={handlePopOver}>
<Popover.Trigger asChild>
<InputWrapper onClick={handlePopOver}>
<Select>{selected && t(`${selected}`)}</Select>
<ArrowIcon icon="arrowDown" open={isOpen} size={16} />
</InputWrapper>
</Popover.Trigger>
<PickerWrapper attachToRoot>
{playSpeedOptions?.map((playSpeed, key) => (
<InputOptions
key={key}
value={playSpeed.seconds}
onClick={() => {
handleOnSelect(playSpeed.timeString, playSpeed.seconds);
}}>
{playSpeed.timeString}
</InputOptions>
))}
</PickerWrapper>
</Popover.Provider>
</PopoverWrapper>
</TimelineControl>
<CurrentTime padding={paddingCheck}>{currentTime && formattedCurrentTime}</CurrentTime>
</TimelineWrapper>
<TimelineSlider>
<ScaleList
onClick={handleOnClick}
Expand All @@ -136,20 +154,23 @@ const TimelineEditor = ({
{[...Array(11)].map((_, idx) => (
<Scale key={idx}>
{idx === 0 ? (
<>
<ScaleLabel>{timeRange?.startTime?.date}</ScaleLabel>
<ScaleLabel>{timeRange?.startTime?.time}</ScaleLabel>
</>
<ScaleLabel padding={paddingCheck}>
{timeRange?.startTime?.date}
<br />
{timeRange?.startTime?.time}
</ScaleLabel>
) : idx === 5 ? (
<>
<ScaleLabel>{timeRange?.midTime?.date}</ScaleLabel>
<ScaleLabel>{timeRange?.midTime?.time}</ScaleLabel>
</>
<ScaleLabel padding={paddingCheck}>
{timeRange?.midTime?.date}
<br />
{timeRange?.midTime?.time}
</ScaleLabel>
) : idx === 10 ? (
<>
<ScaleLabel>{timeRange?.endTime?.date}</ScaleLabel>
<ScaleLabel>{timeRange?.endTime?.time}</ScaleLabel>
</>
<ScaleLabel padding={paddingCheck}>
{timeRange?.endTime?.date}
<br />
{timeRange?.endTime?.time}
</ScaleLabel>
) : null}
</Scale>
))}
Expand All @@ -158,7 +179,7 @@ const TimelineEditor = ({
onMouseDown={handleOnStartMove}
isPlaying={isPlaying || isPlayingReversed || isPause}
style={{
left: `${sliderPosition}px`,
left: `${sliderPosition}%`,
}}>
<Icon icon="slider" />
</IconWrapper>
Expand All @@ -178,11 +199,20 @@ const Wrapper = styled.div`
user-select: none;
`;

const TimelineControl = styled.div`
const TimelineWrapper = styled.div<{ padding: number }>`
display: flex;
align-items: center;
padding-bottom: 6px;
gap: 16px;
gap: ${({ padding }) => (padding > DEFAULT_PADDING ? "" : "25px")};
flex-direction: ${({ padding }) => (padding > DEFAULT_PADDING ? "column" : "row")};
`;

const TimelineControl = styled.div<{ padding: number }>`
display: flex;
align-items: center;
justify-content: space-between;
gap: ${({ padding }) => (padding > DEFAULT_PADDING ? "0" : "18px")};
width: ${({ padding }) => (padding > DEFAULT_PADDING ? "100%" : "auto")};
`;

const StyledIcon = styled.div<{ activeBlock: boolean }>`
Expand All @@ -191,10 +221,20 @@ const StyledIcon = styled.div<{ activeBlock: boolean }>`
background: ${({ activeBlock, theme }) => (activeBlock ? theme.select.main : theme.bg[4])};
padding: 4px 6px 2px;
border-radius: 6px 0 8px 0;
margin-bottom: 6px;
`;
const PlayControl = styled.div`

const PlayControl = styled.div<{ padding: number }>`
display: flex;
gap: 10px;
margin-left: ${({ padding }) => (padding > DEFAULT_PADDING ? "auto" : "0")};
`;

const CurrentTime = styled.div<{ padding: number }>`
color: ${({ theme }) => theme.content.weaker};
padding-right: ${({ padding }) => (padding > DEFAULT_PADDING ? "8px" : "0")};
font-size: 12px;
margin-left: ${({ padding }) => (padding > DEFAULT_PADDING ? "auto" : "0")};
`;

const PlayButton = styled.div<{ isPlaying?: boolean; isClicked?: boolean }>`
Expand All @@ -206,12 +246,11 @@ const PlayButton = styled.div<{ isPlaying?: boolean; isClicked?: boolean }>`
const InputWrapper = styled.div`
position: relative;
cursor: pointer;
width: 90px;
`;

const ArrowIcon = styled(Icon)<{ open: boolean }>`
position: absolute;
right: 10px;
right: -6px;
top: 60%;
transform: ${({ open }) => (open ? "translateY(-50%) scaleY(-1)" : "translateY(-50%)")};
color: ${({ theme }) => theme.content.weaker};
Expand All @@ -223,6 +262,9 @@ const Select = styled.div`
padding-right: 12px;
color: ${({ theme }) => theme.content.weaker};
`;
const PopoverWrapper = styled.div<{ padding: number }>`
padding: ${({ padding }) => (padding > DEFAULT_PADDING ? "0 10px" : "0")};
`;

const PickerWrapper = styled(Popover.Content)`
min-width: 100px;
Expand All @@ -249,12 +291,6 @@ const InputOptions = styled.option`
color: ${({ theme }) => theme.content.main};
`;

const CurrentTime = styled.div`
color: ${({ theme }) => theme.content.weaker};
position: relative;
font-size: 13px;
`;

const TimelineSlider = styled.div`
background: #e0e0e0;
height: 38px;
Expand Down Expand Up @@ -290,9 +326,10 @@ const Scale = styled.div`
width: calc(100% / 11);
`;

const ScaleLabel = styled.div`
font-size: 10px;
const ScaleLabel = styled.div<{ padding: number }>`
font-size: ${({ padding }) => (padding > 60 ? "8px" : "10px")};
position: relative;
bottom: 28px;
right: 15px;
right: 16px;
width: 34px;
`;
Loading
Loading