server-time-timer-yolabs-ui 1.0.11 → 1.0.12

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.
@@ -4,7 +4,6 @@ type TimeState = {
4
4
  hours: number;
5
5
  minutes: number;
6
6
  seconds: number;
7
- progress: number;
8
7
  };
9
8
  export declare const useServerTimer: (endTime: string, onEnd?: () => void) => TimeState;
10
9
  export {};
@@ -10,7 +10,6 @@ const useServerTimer = (endTime, onEnd) => {
10
10
  hours: 0,
11
11
  minutes: 0,
12
12
  seconds: 0,
13
- progress: 100,
14
13
  });
15
14
  (0, react_1.useEffect)(() => {
16
15
  const timer = (0, server_time_timer_yolabs_1.createServerTimer)({
@@ -7,9 +7,8 @@ exports.ServerTimerUI = void 0;
7
7
  const jsx_runtime_1 = require("react/jsx-runtime");
8
8
  const TimerContainer_1 = __importDefault(require("./components/TimerContainer"));
9
9
  const TimerUnit_1 = __importDefault(require("./components/TimerUnit"));
10
- const TimerProgress_1 = __importDefault(require("./components/TimerProgress"));
11
10
  const useServerTimer_1 = require("../hooks/useServerTimer");
12
- const ServerTimerUI = ({ endTime, size = 'md', layout = 'horizontal', theme = 'light', showProgress = true, customColors = {}, showUnits = { days: true, hours: true, minutes: true, seconds: true }, numberSize = 'md', onEnd, className, }) => {
11
+ const ServerTimerUI = ({ endTime, size = 'md', layout = 'horizontal', theme = 'light', customColors = {}, showUnits = { days: true, hours: true, minutes: true, seconds: true }, onEnd, className, }) => {
13
12
  const time = (0, useServerTimer_1.useServerTimer)(endTime, onEnd);
14
13
  const themeColors = {
15
14
  light: { background: '#ffffff', text: '#323130', unitBackground: '#f3f2f1', progress: '#0078d4' },
@@ -17,6 +16,6 @@ const ServerTimerUI = ({ endTime, size = 'md', layout = 'horizontal', theme = 'l
17
16
  brand: { background: '#fef9f3', text: '#323130', unitBackground: '#fffbdd', progress: '#0078d4' },
18
17
  };
19
18
  const colors = Object.assign(Object.assign({}, themeColors[theme]), customColors);
20
- return ((0, jsx_runtime_1.jsxs)(TimerContainer_1.default, { size: size, layout: layout, background: colors.background, color: colors.text, className: className, children: [showUnits.days && (0, jsx_runtime_1.jsx)(TimerUnit_1.default, { label: "Days", value: time.days, size: size, background: colors.unitBackground, color: colors.text, numberSize: numberSize }), showUnits.hours && (0, jsx_runtime_1.jsx)(TimerUnit_1.default, { label: "Hours", value: time.hours, size: size, background: colors.unitBackground, color: colors.text, numberSize: numberSize }), showUnits.minutes && (0, jsx_runtime_1.jsx)(TimerUnit_1.default, { label: "Minutes", value: time.minutes, size: size, background: colors.unitBackground, color: colors.text, numberSize: numberSize }), showUnits.seconds && (0, jsx_runtime_1.jsx)(TimerUnit_1.default, { label: "Seconds", value: time.seconds, size: size, background: colors.unitBackground, color: colors.text, numberSize: numberSize }), showProgress && (0, jsx_runtime_1.jsx)(TimerProgress_1.default, { value: time.progress, color: colors.progress })] }));
19
+ return ((0, jsx_runtime_1.jsxs)(TimerContainer_1.default, { size: size, layout: layout, background: colors.background, color: colors.text, className: className, children: [showUnits.days && (0, jsx_runtime_1.jsx)(TimerUnit_1.default, { label: "Days", value: time.days, size: size, background: colors.unitBackground, color: colors.text }), showUnits.hours && (0, jsx_runtime_1.jsx)(TimerUnit_1.default, { label: "Hours", value: time.hours, size: size, background: colors.unitBackground, color: colors.text }), showUnits.minutes && (0, jsx_runtime_1.jsx)(TimerUnit_1.default, { label: "Minutes", value: time.minutes, size: size, background: colors.unitBackground, color: colors.text }), showUnits.seconds && (0, jsx_runtime_1.jsx)(TimerUnit_1.default, { label: "Seconds", value: time.seconds, size: size, background: colors.unitBackground, color: colors.text })] }));
21
20
  };
22
21
  exports.ServerTimerUI = ServerTimerUI;
@@ -6,7 +6,8 @@ interface TimerUnitProps {
6
6
  size?: TimerSize;
7
7
  background?: string;
8
8
  color?: string;
9
- numberSize?: 'sm' | 'md' | 'lg';
9
+ leadingZero?: boolean;
10
+ monospace?: boolean;
10
11
  }
11
12
  declare const TimerUnit: React.FC<TimerUnitProps>;
12
13
  export default TimerUnit;
@@ -1,13 +1,56 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const jsx_runtime_1 = require("react/jsx-runtime");
4
- const fontSizeMap = { sm: '0.9rem', md: '1.2rem', lg: '1.5rem' };
5
- const TimerUnit = ({ label, value, size = 'md', background = '#f3f2f1', color = '#323130', numberSize = 'md', }) => ((0, jsx_runtime_1.jsxs)("div", { style: {
6
- backgroundColor: background,
7
- color,
8
- padding: '0.5rem',
9
- borderRadius: '4px',
10
- textAlign: 'center',
11
- minWidth: '50px',
12
- }, children: [(0, jsx_runtime_1.jsx)("div", { style: { fontSize: fontSizeMap[numberSize], fontWeight: 'bold' }, children: value.toString().padStart(2, '0') }), (0, jsx_runtime_1.jsx)("div", { style: { fontSize: '0.8rem' }, children: label })] }));
4
+ const TimerUnit = ({ label, value, size = 'md', background = '#ffffff', color = '#333333', leadingZero = true, monospace = true, }) => {
5
+ const sizeStyles = {
6
+ sm: {
7
+ container: 'p-2 min-w-12',
8
+ value: 'text-lg font-semibold',
9
+ label: 'text-xs'
10
+ },
11
+ md: {
12
+ container: 'p-3 min-w-16',
13
+ value: 'text-2xl font-bold',
14
+ label: 'text-sm'
15
+ },
16
+ lg: {
17
+ container: 'p-4 min-w-20',
18
+ value: 'text-3xl font-extrabold',
19
+ label: 'text-base'
20
+ }
21
+ };
22
+ const formattedValue = leadingZero ?
23
+ value.toString().padStart(2, '0') :
24
+ value.toString();
25
+ const fontFamily = monospace ?
26
+ 'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace' :
27
+ 'inherit';
28
+ return ((0, jsx_runtime_1.jsxs)("div", { style: {
29
+ backgroundColor: background,
30
+ color: color,
31
+ padding: size === 'sm' ? '0.5rem' : size === 'lg' ? '1rem' : '0.75rem',
32
+ borderRadius: '0.5rem',
33
+ textAlign: 'center',
34
+ minWidth: size === 'sm' ? '3rem' : size === 'lg' ? '5rem' : '4rem',
35
+ display: 'flex',
36
+ flexDirection: 'column',
37
+ alignItems: 'center',
38
+ justifyContent: 'center',
39
+ border: '1px solid #e5e5e5',
40
+ boxShadow: '0 1px 3px rgba(0,0,0,0.04)',
41
+ }, "aria-label": `${formattedValue} ${label}`, children: [(0, jsx_runtime_1.jsx)("div", { style: {
42
+ fontSize: size === 'sm' ? '1.125rem' : size === 'lg' ? '1.875rem' : '1.5rem',
43
+ fontWeight: size === 'sm' ? 600 : size === 'lg' ? 800 : 700,
44
+ lineHeight: 1.1,
45
+ fontFamily: fontFamily,
46
+ fontVariantNumeric: 'tabular-nums',
47
+ marginBottom: '0.25rem',
48
+ }, children: formattedValue }), (0, jsx_runtime_1.jsx)("div", { style: {
49
+ fontSize: size === 'sm' ? '0.75rem' : size === 'lg' ? '1rem' : '0.875rem',
50
+ fontWeight: 500,
51
+ textTransform: 'uppercase',
52
+ letterSpacing: '0.05em',
53
+ opacity: 0.7,
54
+ }, children: label })] }));
55
+ };
13
56
  exports.default = TimerUnit;
@@ -1,13 +1,7 @@
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 CustomColors {
5
- background?: string;
6
- text?: string;
7
- unitBackground?: string;
8
- progress?: string;
9
- }
10
- export interface ShowUnits {
4
+ export interface TimerUnits {
11
5
  days?: boolean;
12
6
  hours?: boolean;
13
7
  minutes?: boolean;
@@ -18,10 +12,12 @@ export interface ServerTimerUIProps {
18
12
  size?: TimerSize;
19
13
  layout?: TimerLayout;
20
14
  theme?: TimerTheme;
21
- showProgress?: boolean;
22
- customColors?: CustomColors;
23
- showUnits?: ShowUnits;
24
- onEnd?: () => void;
15
+ showUnits?: TimerUnits;
25
16
  className?: string;
26
- numberSize?: 'sm' | 'md' | 'lg';
17
+ customColors?: {
18
+ background?: string;
19
+ text?: string;
20
+ unitBackground?: string;
21
+ };
22
+ onEnd?: () => void;
27
23
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "server-time-timer-yolabs-ui",
3
- "version": "1.0.11",
3
+ "version": "1.0.12",
4
4
  "description": "FluentUI/SharePoint styled React countdown timer UI for server-time-timer-yoLabs",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",