Skip to content

Commit

Permalink
fix: styling issues with compact mode + fullscreen
Browse files Browse the repository at this point in the history
  • Loading branch information
roldanjr authored and sekwah41 committed Dec 20, 2022
1 parent 50b68c0 commit 3cb1725
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 22 deletions.
1 change: 1 addition & 0 deletions app/renderer/.env
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
SKIP_PREFLIGHT_CHECK=true
BROWSER=none
CI=true
19 changes: 15 additions & 4 deletions app/renderer/src/routes/Timer/Control/CompactModeButton.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
import { SVG } from "components";
import { CounterContext } from "contexts";
import { useRippleEffect } from "hooks";
import React, { useCallback, useRef } from "react";
import { StyledMainButton } from "styles";
import { useSelector } from "react-redux";
import { AppStateTypes, SettingTypes } from "store";
import { StyledCompactButton } from "styles";

type Props = { flipped?: boolean } & React.HTMLProps<HTMLButtonElement>;

const CompactModeButton: React.FC<Props> = ({ onClick, flipped }) => {
const { compactMode }: SettingTypes = useSelector(
(state: AppStateTypes) => state.settings
);

const buttonRef = useRef<HTMLButtonElement>(null);

const buttonClickAction = useRippleEffect();
Expand All @@ -17,16 +24,20 @@ const CompactModeButton: React.FC<Props> = ({ onClick, flipped }) => {
onClick(e);
}
}),
[buttonClickAction, onClick],
[buttonClickAction, onClick]
);

return (
<StyledMainButton ref={buttonRef} onClick={onClickAction}>
<StyledCompactButton
ref={buttonRef}
onClick={onClickAction}
compact={compactMode}
>
<SVG
name="expand"
style={flipped ? { transform: "rotate(180deg)" } : {}}
/>
</StyledMainButton>
</StyledCompactButton>
);
};

Expand Down
4 changes: 2 additions & 2 deletions app/renderer/src/routes/Timer/Control/Control.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const Control: React.FC<Props> = ({ resetTimerAction }) => {
}));

const settings: SettingTypes = useSelector(
(state: AppStateTypes) => state.settings,
(state: AppStateTypes) => state.settings
);

const dispatch = useDispatch();
Expand Down Expand Up @@ -154,7 +154,7 @@ const Control: React.FC<Props> = ({ resetTimerAction }) => {
onClick={onResetSessionCallback}
/>
<StyledControlSpacer className="test" />
<StyledControlMain>
<StyledControlMain compact={settings.compactMode}>
<ResetButton className="compact" onClick={onResetCallback} />
<PlayButton
compact
Expand Down
41 changes: 32 additions & 9 deletions app/renderer/src/routes/Timer/Counter/Counter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,47 @@ import CounterType from "./CounterType";

const Counter: React.FC = () => {
const settings: SettingTypes = useSelector(
(state: AppStateTypes) => state.settings,
(state: AppStateTypes) => state.settings
);

const { count, duration, timerType, shouldFullscreen } =
useContext(CounterContext);
const { count, duration, timerType, shouldFullscreen } = useContext(
CounterContext
);

const dashOffset = (duration - count) * (674 / duration);

const { minutes, seconds } = useTime(count);

if (settings.compactMode) {
return (
<StyledCounterContainer className="compact" fullscreen={shouldFullscreen}>
<CounterTimer
compact
timerType={timerType}
minutes={minutes}
seconds={seconds}
/>
{shouldFullscreen ? (
<>
<StyledCounterProgress
offset={dashOffset}
type={timerType}
animate={settings.enableProgressAnimation ? "true" : "false"}
/>
<StyledCounterWrapper>
<CounterType timerType={timerType} />
<CounterTimer
compact
fullscreen={shouldFullscreen}
timerType={timerType}
minutes={minutes}
seconds={seconds}
/>
<CounterLabel timerType={timerType} />
</StyledCounterWrapper>
</>
) : (
<CounterTimer
compact
timerType={timerType}
minutes={minutes}
seconds={seconds}
/>
)}
</StyledCounterContainer>
);
}
Expand Down
8 changes: 7 additions & 1 deletion app/renderer/src/routes/Timer/Counter/CounterTimer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,22 @@ type Props = {
minutes: string;
seconds: string;
compact?: boolean;
fullscreen?: boolean;
};

const CounterTimer: React.FC<Props> = ({
timerType,
minutes,
seconds,
compact,
fullscreen,
}) => {
return (
<StyledCounterTimer className={compact ? "compact" : ""} type={timerType}>
<StyledCounterTimer
type={timerType}
className={compact ? "compact" : ""}
fullscreen={fullscreen}
>
<span>{minutes}</span>
<span>:</span>
<span>{seconds}</span>
Expand Down
12 changes: 9 additions & 3 deletions app/renderer/src/styles/routes/timer/control.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ const ControlButton = css`
}
&.compact {
min-width: 2rem;
min-height: 2rem;
min-width: 1.6rem;
min-height: 1.6rem;
}
`;

Expand Down Expand Up @@ -131,12 +131,13 @@ export const StyledSessions = styled.p`
}
`;

export const StyledControlMain = styled.div`
export const StyledControlMain = styled.div<{ compact?: boolean }>`
display: grid;
align-items: center;
align-content: center;
grid-auto-flow: column;
column-gap: 1rem;
margin-right: ${(p) => (p.compact ? 0 : "-1rem")};
`;

export const StyledResetButton = styled.button`
Expand All @@ -147,6 +148,11 @@ export const StyledMainButton = styled.button`
${ControlButton};
`;

export const StyledCompactButton = styled.button<{ compact?: boolean }>`
${ControlButton}
padding-right: ${(p) => (p.compact ? "1.6rem" : 0)};
`;

export const StyledSkipButton = styled.button`
${ControlButton};
Expand Down
6 changes: 3 additions & 3 deletions app/renderer/src/styles/routes/timer/counter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export const StyledCounterContainer = styled.div<CounterContainerProps>`
display: flex;
flex: 0;
&::before {
display: none;
display: ${(p) => (p.fullscreen ? "auto" : "none")} ;
}
}
`;
Expand All @@ -105,7 +105,7 @@ export const StyledCounterType = styled.div`
padding-bottom: 0.8rem;
`;

type TimerProps = { type?: string };
type TimerProps = { type?: string } & CounterContainerProps;

export const StyledCounterTimer = styled.h3<TimerProps>`
font-size: 4rem;
Expand All @@ -131,7 +131,7 @@ export const StyledCounterTimer = styled.h3<TimerProps>`
}
&.compact {
font-size: 2.5rem;
font-size: ${(p) => (p.fullscreen ? "4rem" : "2.5rem")};
width: unset;
display: flex;
gap: 0.25rem;
Expand Down

0 comments on commit 3cb1725

Please sign in to comment.