server-time-timer-yolabs-ui 1.0.6 → 1.0.7
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.
- package/dist/ui/ServerTimerUI.d.ts +0 -1
- package/dist/ui/ServerTimerUI.js +16 -2
- package/dist/ui/components/TimerContainer.d.ts +8 -9
- package/dist/ui/components/TimerContainer.js +18 -30
- package/dist/ui/components/TimerProgress.d.ts +3 -6
- package/dist/ui/components/TimerProgress.js +9 -8
- package/dist/ui/components/TimerUnit.d.ts +8 -10
- package/dist/ui/components/TimerUnit.js +33 -17
- package/dist/ui/themes/brand.d.ts +3 -1
- package/dist/ui/themes/brand.js +6 -1
- package/dist/ui/themes/dark.d.ts +3 -1
- package/dist/ui/themes/dark.js +6 -1
- package/dist/ui/themes/light.d.ts +3 -1
- package/dist/ui/themes/light.js +6 -1
- package/dist/ui/types/index.d.ts +6 -7
- package/package.json +1 -1
package/dist/ui/ServerTimerUI.js
CHANGED
|
@@ -9,9 +9,23 @@ const TimerContainer_1 = __importDefault(require("./components/TimerContainer"))
|
|
|
9
9
|
const TimerUnit_1 = __importDefault(require("./components/TimerUnit"));
|
|
10
10
|
const TimerProgress_1 = __importDefault(require("./components/TimerProgress"));
|
|
11
11
|
const useServerTimer_1 = require("../hooks/useServerTimer");
|
|
12
|
+
const light_1 = require("./themes/light");
|
|
13
|
+
const dark_1 = require("./themes/dark");
|
|
14
|
+
const brand_1 = require("./themes/brand");
|
|
12
15
|
const ServerTimerUI = ({ serverNow, endTime, size = 'md', layout = 'horizontal', theme = 'light', showProgress = true, customColors, showUnits = { days: true, hours: true, minutes: true, seconds: true }, onEnd }) => {
|
|
16
|
+
var _a, _b, _c, _d;
|
|
13
17
|
const time = (0, useServerTimer_1.useServerTimer)({ serverNow, endTime, onEnd });
|
|
14
|
-
|
|
18
|
+
// 1️⃣ Base theme (ALWAYS defined)
|
|
19
|
+
const baseTheme = theme === 'dark' ? dark_1.dark :
|
|
20
|
+
theme === 'brand' ? brand_1.brand :
|
|
21
|
+
light_1.light;
|
|
22
|
+
// 2️⃣ Final resolved colors (NO undefined)
|
|
23
|
+
const colors = {
|
|
24
|
+
background: (_a = customColors === null || customColors === void 0 ? void 0 : customColors.background) !== null && _a !== void 0 ? _a : baseTheme.background,
|
|
25
|
+
text: (_b = customColors === null || customColors === void 0 ? void 0 : customColors.text) !== null && _b !== void 0 ? _b : baseTheme.text,
|
|
26
|
+
unitBackground: (_c = customColors === null || customColors === void 0 ? void 0 : customColors.unitBackground) !== null && _c !== void 0 ? _c : baseTheme.unitBackground,
|
|
27
|
+
progress: (_d = customColors === null || customColors === void 0 ? void 0 : customColors.progress) !== null && _d !== void 0 ? _d : baseTheme.progress
|
|
28
|
+
};
|
|
29
|
+
return ((0, jsx_runtime_1.jsxs)(TimerContainer_1.default, { size: size, layout: layout, background: colors.background, color: colors.text, children: [showUnits.days && ((0, jsx_runtime_1.jsx)(TimerUnit_1.default, { label: "Days", value: time.days, size: size, layout: layout, background: colors.unitBackground, color: colors.text })), showUnits.hours && ((0, jsx_runtime_1.jsx)(TimerUnit_1.default, { label: "Hours", value: time.hours, size: size, layout: layout, background: colors.unitBackground, color: colors.text })), showUnits.minutes && ((0, jsx_runtime_1.jsx)(TimerUnit_1.default, { label: "Minutes", value: time.minutes, size: size, layout: layout, background: colors.unitBackground, color: colors.text })), showUnits.seconds && ((0, jsx_runtime_1.jsx)(TimerUnit_1.default, { label: "Seconds", value: time.seconds, size: size, layout: layout, background: colors.unitBackground, color: colors.text })), showProgress && ((0, jsx_runtime_1.jsx)(TimerProgress_1.default, { value: time.progress, color: colors.progress }))] }));
|
|
15
30
|
};
|
|
16
31
|
exports.ServerTimerUI = ServerTimerUI;
|
|
17
|
-
exports.default = exports.ServerTimerUI;
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
interface
|
|
2
|
+
import { TimerLayout, TimerSize } from '../types';
|
|
3
|
+
interface Props {
|
|
4
4
|
children: React.ReactNode;
|
|
5
|
-
size
|
|
6
|
-
layout
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
color?: string;
|
|
5
|
+
size: TimerSize;
|
|
6
|
+
layout: TimerLayout;
|
|
7
|
+
background: string;
|
|
8
|
+
color: string;
|
|
10
9
|
}
|
|
11
|
-
|
|
12
|
-
export
|
|
10
|
+
export default function TimerContainer({ children, size, layout, background, color }: Props): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export {};
|
|
@@ -1,37 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = TimerContainer;
|
|
3
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
|
-
const paddingMap = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
if (layout === 'vertical')
|
|
12
|
-
flexDirection = 'column';
|
|
13
|
-
if (layout === 'compact') {
|
|
14
|
-
flexDirection = 'row';
|
|
15
|
-
padding = '0.25rem 0.5rem';
|
|
16
|
-
gap = '0.25rem';
|
|
17
|
-
fontSize = '0.75rem';
|
|
18
|
-
}
|
|
19
|
-
return ((0, jsx_runtime_1.jsx)("div", { className: className, style: {
|
|
20
|
-
backgroundColor: background,
|
|
21
|
-
color,
|
|
22
|
-
border: '1px solid #e1e1e1',
|
|
23
|
-
borderRadius: '4px',
|
|
24
|
-
boxShadow: '0 1px 3px rgba(0,0,0,0.1)',
|
|
25
|
-
padding,
|
|
5
|
+
const paddingMap = {
|
|
6
|
+
sm: '6px 10px',
|
|
7
|
+
md: '10px 16px',
|
|
8
|
+
lg: '16px 22px'
|
|
9
|
+
};
|
|
10
|
+
function TimerContainer({ children, size, layout, background, color }) {
|
|
11
|
+
return ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
26
12
|
display: 'flex',
|
|
27
|
-
flexDirection,
|
|
13
|
+
flexDirection: layout === 'vertical' ? 'column' : 'row',
|
|
28
14
|
alignItems: 'center',
|
|
29
|
-
gap,
|
|
30
|
-
|
|
31
|
-
|
|
15
|
+
gap: layout === 'compact' ? '4px' : '10px',
|
|
16
|
+
padding: paddingMap[size],
|
|
17
|
+
background,
|
|
18
|
+
color,
|
|
19
|
+
border: '1px solid #e1e1e1',
|
|
20
|
+
borderRadius: 4,
|
|
21
|
+
fontFamily: `'Segoe UI', system-ui`,
|
|
32
22
|
flexWrap: 'wrap',
|
|
33
|
-
maxWidth: '100%'
|
|
34
|
-
overflow: 'hidden',
|
|
23
|
+
maxWidth: '100%'
|
|
35
24
|
}, children: children }));
|
|
36
|
-
}
|
|
37
|
-
exports.default = TimerContainer;
|
|
25
|
+
}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
interface TimerProgressProps {
|
|
1
|
+
export default function TimerProgress({ value, color }: {
|
|
3
2
|
value: number;
|
|
4
|
-
color
|
|
5
|
-
}
|
|
6
|
-
declare const TimerProgress: React.FC<TimerProgressProps>;
|
|
7
|
-
export default TimerProgress;
|
|
3
|
+
color: string;
|
|
4
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
|
-
const TimerProgress = ({ value, color = '#0078d4' }) => ((0, jsx_runtime_1.jsx)("div", { style: { flex: 1, height: '6px', backgroundColor: '#e1e1e1', borderRadius: '3px', margin: '0 0.5rem', minWidth: '50px' }, children: (0, jsx_runtime_1.jsx)("div", { style: {
|
|
5
|
-
width: `${value}%`,
|
|
6
|
-
height: '100%',
|
|
7
|
-
backgroundColor: color,
|
|
8
|
-
borderRadius: '3px',
|
|
9
|
-
transition: 'width 0.2s ease'
|
|
10
|
-
} }) }));
|
|
11
3
|
exports.default = TimerProgress;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
function TimerProgress({ value, color }) {
|
|
6
|
+
return ((0, jsx_runtime_1.jsx)("div", { style: { width: '100%', height: 4, background: '#e1e1e1', borderRadius: 2 }, children: (0, jsx_runtime_1.jsx)("div", { style: {
|
|
7
|
+
width: `${value}%`,
|
|
8
|
+
height: '100%',
|
|
9
|
+
background: color,
|
|
10
|
+
transition: 'width 0.3s linear'
|
|
11
|
+
} }) }));
|
|
12
|
+
}
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
export interface TimerUnitProps {
|
|
1
|
+
import { TimerLayout, TimerSize } from '../types';
|
|
2
|
+
interface Props {
|
|
4
3
|
label: string;
|
|
5
4
|
value: number;
|
|
6
|
-
size
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
color?: string;
|
|
5
|
+
size: TimerSize;
|
|
6
|
+
layout: TimerLayout;
|
|
7
|
+
background: string;
|
|
8
|
+
color: string;
|
|
11
9
|
}
|
|
12
|
-
|
|
13
|
-
export
|
|
10
|
+
export default function TimerUnit({ label, value, size, layout, background, color }: Props): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export {};
|
|
@@ -1,20 +1,36 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
|
-
const fontMap = { sm: '0.75rem', md: '1rem', lg: '1.5rem' };
|
|
5
|
-
const paddingMap = { sm: '0.25rem 0.5rem', md: '0.5rem 1rem', lg: '1rem 1.5rem' };
|
|
6
|
-
const TimerUnit = ({ label, value, size = 'md', numberSize = 'md', layout = 'horizontal', background = '#f3f2f1', color = '#323130' }) => ((0, jsx_runtime_1.jsxs)("div", { style: {
|
|
7
|
-
backgroundColor: background,
|
|
8
|
-
color,
|
|
9
|
-
padding: paddingMap[size],
|
|
10
|
-
borderRadius: '4px',
|
|
11
|
-
textAlign: 'center',
|
|
12
|
-
minWidth: layout === 'compact' ? '2rem' : '3rem',
|
|
13
|
-
flex: layout === 'horizontal' ? '1 1 auto' : undefined,
|
|
14
|
-
display: 'flex',
|
|
15
|
-
flexDirection: 'column',
|
|
16
|
-
alignItems: 'center',
|
|
17
|
-
marginBottom: layout === 'vertical' ? '0.25rem' : undefined,
|
|
18
|
-
overflow: 'hidden'
|
|
19
|
-
}, children: [(0, jsx_runtime_1.jsx)("div", { style: { fontSize: fontMap[numberSize], fontWeight: 600, whiteSpace: 'nowrap' }, children: value.toString().padStart(2, '0') }), (0, jsx_runtime_1.jsx)("div", { style: { fontSize: '0.75rem', whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis' }, children: label })] }));
|
|
20
3
|
exports.default = TimerUnit;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const numberSizeMap = {
|
|
6
|
+
sm: '0.9rem',
|
|
7
|
+
md: '1.2rem',
|
|
8
|
+
lg: '1.6rem'
|
|
9
|
+
};
|
|
10
|
+
const minWidthMap = {
|
|
11
|
+
sm: '2ch',
|
|
12
|
+
md: '2.5ch',
|
|
13
|
+
lg: '3ch'
|
|
14
|
+
};
|
|
15
|
+
function TimerUnit({ label, value, size, layout, background, color }) {
|
|
16
|
+
return ((0, jsx_runtime_1.jsxs)("div", { role: "group", "aria-label": label, style: {
|
|
17
|
+
display: 'flex',
|
|
18
|
+
flexDirection: layout === 'compact' ? 'row' : 'column',
|
|
19
|
+
alignItems: 'center',
|
|
20
|
+
padding: '6px 8px',
|
|
21
|
+
background,
|
|
22
|
+
borderRadius: 4,
|
|
23
|
+
minWidth: layout === 'compact' ? 'auto' : '64px'
|
|
24
|
+
}, children: [(0, jsx_runtime_1.jsx)("span", { "aria-live": "polite", "aria-atomic": "true", style: {
|
|
25
|
+
fontSize: numberSizeMap[size],
|
|
26
|
+
fontWeight: 600,
|
|
27
|
+
fontFamily: `'Segoe UI Mono', Consolas, monospace`,
|
|
28
|
+
minWidth: minWidthMap[size],
|
|
29
|
+
textAlign: 'center',
|
|
30
|
+
transition: 'transform 0.15s ease, opacity 0.15s ease'
|
|
31
|
+
}, children: value.toString().padStart(2, '0') }), layout !== 'compact' && ((0, jsx_runtime_1.jsx)("span", { style: {
|
|
32
|
+
fontSize: '0.7rem',
|
|
33
|
+
opacity: 0.75,
|
|
34
|
+
marginTop: 2
|
|
35
|
+
}, children: label }))] }));
|
|
36
|
+
}
|
package/dist/ui/themes/brand.js
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.brand = void 0;
|
|
4
|
-
exports.brand = {
|
|
4
|
+
exports.brand = {
|
|
5
|
+
background: '#f5f9ff',
|
|
6
|
+
text: '#003a8f',
|
|
7
|
+
unitBackground: '#e6f0ff',
|
|
8
|
+
progress: '#005fb8'
|
|
9
|
+
};
|
package/dist/ui/themes/dark.d.ts
CHANGED
package/dist/ui/themes/dark.js
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.dark = void 0;
|
|
4
|
-
exports.dark = {
|
|
4
|
+
exports.dark = {
|
|
5
|
+
background: '#1f1f1f',
|
|
6
|
+
text: '#ffffff',
|
|
7
|
+
unitBackground: '#2d2d2d',
|
|
8
|
+
progress: '#2899f5'
|
|
9
|
+
};
|
package/dist/ui/themes/light.js
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.light = void 0;
|
|
4
|
-
exports.light = {
|
|
4
|
+
exports.light = {
|
|
5
|
+
background: '#ffffff',
|
|
6
|
+
text: '#323130',
|
|
7
|
+
unitBackground: '#f3f2f1',
|
|
8
|
+
progress: '#0078d4',
|
|
9
|
+
};
|
package/dist/ui/types/index.d.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
export type TimerSize = 'sm' | 'md' | 'lg';
|
|
2
2
|
export type TimerLayout = 'horizontal' | 'vertical' | 'compact';
|
|
3
3
|
export type TimerTheme = 'light' | 'dark' | 'brand';
|
|
4
|
-
export interface ShowUnits {
|
|
5
|
-
days?: boolean;
|
|
6
|
-
hours?: boolean;
|
|
7
|
-
minutes?: boolean;
|
|
8
|
-
seconds?: boolean;
|
|
9
|
-
}
|
|
10
4
|
export interface CustomColors {
|
|
11
5
|
background?: string;
|
|
12
6
|
text?: string;
|
|
13
7
|
unitBackground?: string;
|
|
14
8
|
progress?: string;
|
|
15
9
|
}
|
|
10
|
+
export interface ShowUnits {
|
|
11
|
+
days?: boolean;
|
|
12
|
+
hours?: boolean;
|
|
13
|
+
minutes?: boolean;
|
|
14
|
+
seconds?: boolean;
|
|
15
|
+
}
|
|
16
16
|
export interface ServerTimerUIProps {
|
|
17
17
|
serverNow: string;
|
|
18
18
|
endTime: string;
|
|
@@ -23,5 +23,4 @@ export interface ServerTimerUIProps {
|
|
|
23
23
|
customColors?: CustomColors;
|
|
24
24
|
showUnits?: ShowUnits;
|
|
25
25
|
onEnd?: () => void;
|
|
26
|
-
className?: string;
|
|
27
26
|
}
|
package/package.json
CHANGED