@1001-digital/layers.base 0.0.2 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -23,6 +23,7 @@ const props = withDefaults(defineProps<{
|
|
|
23
23
|
xClose?: boolean
|
|
24
24
|
clickOutside?: boolean
|
|
25
25
|
compat?: boolean
|
|
26
|
+
large?: boolean
|
|
26
27
|
}>(), {
|
|
27
28
|
xClose: true,
|
|
28
29
|
clickOutside: true,
|
|
@@ -37,6 +38,7 @@ const classes = computed(() => {
|
|
|
37
38
|
let obj: Record<string, boolean> = {
|
|
38
39
|
dialog: true,
|
|
39
40
|
compat: !!props.compat,
|
|
41
|
+
large: !!props.large,
|
|
40
42
|
}
|
|
41
43
|
|
|
42
44
|
// Apply passed classes
|
|
@@ -214,6 +216,10 @@ watchEffect(() => (open.value ? show() : hide()))
|
|
|
214
216
|
gap: var(--spacer);
|
|
215
217
|
justify-content: flex-end;
|
|
216
218
|
}
|
|
219
|
+
|
|
220
|
+
&.large {
|
|
221
|
+
--dialog-width: min(90vw, 64rem);
|
|
222
|
+
}
|
|
217
223
|
}
|
|
218
224
|
|
|
219
225
|
html:has(dialog[open]),
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { DateTime } from 'luxon'
|
|
2
|
+
import type { Ref } from 'vue'
|
|
3
|
+
|
|
4
|
+
let nowInterval: NodeJS.Timeout | undefined
|
|
5
|
+
|
|
6
|
+
export const useSeconds = () => {
|
|
7
|
+
const now = useState<number>('now', () => nowInSeconds())
|
|
8
|
+
|
|
9
|
+
if (import.meta.client && !nowInterval) {
|
|
10
|
+
nowInterval = setInterval(() => {
|
|
11
|
+
now.value = nowInSeconds()
|
|
12
|
+
}, 1000)
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return now
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const useCountDown = (s: Ref<number | bigint>, showSecondsWithin: number = 60) => {
|
|
19
|
+
const duration = computed(() => Math.abs(Number(s.value)))
|
|
20
|
+
|
|
21
|
+
const seconds = computed(() => duration.value % 60)
|
|
22
|
+
const minutes = computed(() => Math.floor(duration.value / 60) % 60)
|
|
23
|
+
const hours = computed(() => Math.floor(duration.value / 60 / 60) % 24)
|
|
24
|
+
const days = computed(() => Math.floor(duration.value / 60 / 60 / 24))
|
|
25
|
+
|
|
26
|
+
const str = computed(() =>
|
|
27
|
+
[
|
|
28
|
+
days.value ? `${days.value}d` : null,
|
|
29
|
+
hours.value ? `${hours.value}h` : null,
|
|
30
|
+
minutes.value ? `${minutes.value}m` : null,
|
|
31
|
+
duration.value < showSecondsWithin && seconds.value ? `${seconds.value}s` : null,
|
|
32
|
+
]
|
|
33
|
+
.filter((s) => !!s)
|
|
34
|
+
.join(' '),
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
return {
|
|
38
|
+
seconds,
|
|
39
|
+
minutes,
|
|
40
|
+
hours,
|
|
41
|
+
days,
|
|
42
|
+
str,
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export const useSecondsAgo = (time: Ref<string | undefined>) => {
|
|
47
|
+
const ago = ref<string>()
|
|
48
|
+
const now = useSeconds()
|
|
49
|
+
|
|
50
|
+
watch(
|
|
51
|
+
now,
|
|
52
|
+
() => {
|
|
53
|
+
if (time.value) {
|
|
54
|
+
ago.value = DateTime.fromISO(time.value).toRelative({ style: 'short', locale: 'en' }) ?? undefined
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
immediate: true,
|
|
59
|
+
},
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
return ago
|
|
63
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { DateTime } from 'luxon'
|
|
2
|
+
|
|
3
|
+
export const delay = (ms: number): Promise<void> =>
|
|
4
|
+
new Promise((resolve) => setTimeout(resolve, ms))
|
|
5
|
+
|
|
6
|
+
export const daysInSeconds = (days: number): number => days * 60 * 60 * 24
|
|
7
|
+
|
|
8
|
+
export const nowInSeconds = (): number => Math.floor(Date.now() / 1000)
|
|
9
|
+
|
|
10
|
+
export const asUTCDate = (date: Date | null) =>
|
|
11
|
+
date
|
|
12
|
+
? DateTime.utc(
|
|
13
|
+
date.getFullYear(),
|
|
14
|
+
date.getMonth() + 1,
|
|
15
|
+
date.getDate(),
|
|
16
|
+
date.getHours(),
|
|
17
|
+
date.getMinutes(),
|
|
18
|
+
date.getSeconds(),
|
|
19
|
+
)
|
|
20
|
+
: null
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@1001-digital/layers.base",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.4",
|
|
5
5
|
"main": "./nuxt.config.ts",
|
|
6
6
|
"devDependencies": {
|
|
7
7
|
"@iconify-json/lucide": "^1.2.81",
|
|
8
8
|
"@iconify-json/simple-icons": "^1.2.63",
|
|
9
9
|
"@nuxt/eslint": "latest",
|
|
10
|
+
"@types/luxon": "^3.6.2",
|
|
10
11
|
"@types/node": "^24.10.1",
|
|
11
12
|
"eslint": "^9.39.1",
|
|
12
13
|
"nuxt": "^4.2.2",
|
|
@@ -15,6 +16,7 @@
|
|
|
15
16
|
},
|
|
16
17
|
"dependencies": {
|
|
17
18
|
"@nuxt/icon": "^1.10.3",
|
|
19
|
+
"luxon": "^3.6.1",
|
|
18
20
|
"modern-normalize": "^3.0.1",
|
|
19
21
|
"reka-ui": "^2.6.1"
|
|
20
22
|
},
|
|
@@ -24,6 +26,7 @@
|
|
|
24
26
|
"build": "nuxt build .playground",
|
|
25
27
|
"generate": "nuxt generate .playground",
|
|
26
28
|
"preview": "nuxt preview .playground",
|
|
27
|
-
"lint": "eslint ."
|
|
29
|
+
"lint": "eslint .",
|
|
30
|
+
"typecheck": "nuxi typecheck .playground"
|
|
28
31
|
}
|
|
29
32
|
}
|