Skip to content

Commit

Permalink
feat(count-down): support simple mode
Browse files Browse the repository at this point in the history
  • Loading branch information
qianmoQ committed Dec 6, 2024
1 parent cc2157a commit da3e85f
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 4 deletions.
27 changes: 25 additions & 2 deletions docs/components/count-down.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,29 @@ This document is mainly used to describe some features and usage of the ShadcnCo
::: details Show code

```vue
<ShadcnCountDown :time="new Date(Date.now() + 2 * 24 * 60 * 60 * 1000)" />
<template>
<ShadcnCountDown :time="new Date(Date.now() + 2 * 24 * 60 * 60 * 1000)" />
</template>
```

:::

## Simple

::: raw

<CodeRunner title="Simple">
<ShadcnCountDown :time="new Date(Date.now() + 2 * 24 * 60 * 60 * 1000)" simple />
</CodeRunner>

:::

::: details Show code

```vue
<template>
<ShadcnCountDown :time="new Date(Date.now() + 2 * 24 * 60 * 60 * 1000)" simple />
</template>
```

:::
Expand All @@ -29,6 +51,7 @@ This document is mainly used to describe some features and usage of the ShadcnCo
<ApiTable title="Props"
:headers="['Attribute', 'Description', 'Type', 'Default Value']"
:columns="[
['time', 'The time of the count down', 'Date', ''],
['time', 'The time of the count down', 'date', ''],
['simple', 'Whether to display the simple version', 'boolean', 'false'],
]">
</ApiTable>
11 changes: 9 additions & 2 deletions src/ui/count-down/ShadcnCountDown.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
<template>
<ShadcnCard :border="false">
<div class="grid grid-cols-4 gap-4 text-center">
<div v-if="simple">
<div class="text-2xl font-bold">
{{ `${ timeLeft.days } : ${ timeLeft.hours } : ${ timeLeft.minutes } : ${ timeLeft.seconds }` }}
</div>
</div>
<div v-else class="grid grid-cols-4 gap-4 text-center">
<!-- Days -->
<div class="flex flex-col">
<div class="text-4xl font-bold bg-slate-100 rounded-lg p-4">
Expand Down Expand Up @@ -42,7 +47,9 @@ import { t } from '@/utils/locale'
import ShadcnCard from '@/ui/card'
import { CountDownProps } from '@/ui/count-down/types'
const props = withDefaults(defineProps<CountDownProps>(), {})
const props = withDefaults(defineProps<CountDownProps>(), {
simple: false
})
const timeLeft = ref({
days: 0,
Expand Down
1 change: 1 addition & 0 deletions src/ui/count-down/types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export interface CountDownProps {
time: Date
simple?: boolean
}

0 comments on commit da3e85f

Please sign in to comment.