Files
Ivan VasilovandTerry Sutton 5754c23abb feat: Move some components into ui-patterns (#20774)
* Change all imports in the ui package which import via the @ui shortcut.

* Add a new ui-patterns package. Add it to all apps.

* Migrate PrivacySettings from ui to ui-patterns.

* Migrate ConsentToast from ui to ui-patterns.

* Remove providers folder from ui package.

* Move GlassPanel.

* Migrate IconPanel.

* Migrate TweetCard.

* Migrate ThemeImage.

* Remove LWXCountdownBanner.

* Migrate CountdownWidget.

* Migrate SchemaTableNode.

* Migrate ExpandableVideo.

* Migrate ThemeToggle.

* Fix bunch of imports in the docs app.

* Revert some unnecessary changes.

* Expand the README.md.

* Fix the tailwind configs, they were using old folder structure.

* Fix leftover merge conflicts.

* Remove a deleted page in master.

---------

Co-authored-by: Terry Sutton <saltcod@gmail.com>
2024-02-12 12:44:00 +01:00

48 lines
1.2 KiB
TypeScript

import CountdownStep from './CountdownStep'
interface CountdownWidgetProps {
days?: string
hours?: string
minutes?: string
seconds?: string
showCard?: boolean
}
export function CountdownWidget({
days,
hours,
minutes,
seconds,
showCard = true,
}: CountdownWidgetProps) {
const Colon = () => <span className="text-xs mx-px text-foreground-lighter">:</span>
const showItem = (item: string | undefined) => item !== undefined && item !== '0'
return (
<div className="flex gap-1 items-center">
{days !== undefined && days !== '0' ? (
<>
<CountdownStep value={days} unit="d" showCard={showCard} />
<Colon />
</>
) : null}
{hours !== undefined ? (
<>
<CountdownStep value={hours} unit="h" showCard={showCard} />
<Colon />
</>
) : null}
{minutes !== undefined ? (
<>
<CountdownStep value={minutes} unit="m" showCard={showCard} />
{seconds !== undefined && <Colon />}
</>
) : null}
{seconds !== undefined ? (
<CountdownStep value={seconds} unit="s" showCard={showCard} />
) : null}
</div>
)
}