Skip to content

Commit

Permalink
Add background to message
Browse files Browse the repository at this point in the history
  • Loading branch information
FilipChalupa committed Nov 17, 2023
1 parent 9096359 commit 959e795
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
12 changes: 8 additions & 4 deletions components/Countdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const Countdown: React.FunctionComponent<CountdownProps> = ({
useLocalTime = false,
flashOnZero = false,
forceFlash = false,
message = '',
message,
}) => {
const [remainingSeconds, setRemainingSeconds] = React.useState(0)

Expand Down Expand Up @@ -90,9 +90,13 @@ export const Countdown: React.FunctionComponent<CountdownProps> = ({
remainingSeconds === 0 && flashOnZero && <div className="flash" />
)}
{formattedTime}
<div className={clsx('message', isMessageVisible && 'is-visible')}>
{lastMessage.current}
</div>
{message !== undefined && (
<>
<div className={clsx('message', isMessageVisible && 'is-visible')}>
{lastMessage.current}
</div>
</>
)}
</div>
)
}
14 changes: 13 additions & 1 deletion styles/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -110,16 +110,28 @@ body:has(.fullScreenCountdown.is-iframe) {

.message {
position: absolute;
isolation: isolate;
inset: auto 0 0;
text-align: center;
font-size: 0.3em;
padding: 0.3em;
padding: 0 0.3em 0.3em;
line-height: 1.2;
transition-property: translate;
translate: 0 100%;
transition-timing-function: ease-in-out;
}

.message::before {
content: '';
position: absolute;
inset: 0;
z-index: -1;
background-color: currentColor;
opacity: 0.9;
box-shadow: 0 0 10px 10px currentColor;
filter: invert(100%);
}

.message.is-visible {
translate: 0 0;
}
Expand Down

0 comments on commit 959e795

Please sign in to comment.