server-time-timer-yolabs-ui 1.0.17 → 1.0.19

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.
@@ -8,14 +8,38 @@ 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
10
  const useServerTimer_1 = require("../hooks/useServerTimer");
11
- const ServerTimerUI = ({ endTime, size = 'md', layout = 'horizontal', theme = 'light', customColors = {}, showUnits = { days: true, hours: true, minutes: true, seconds: true }, onEnd, className, }) => {
11
+ const ServerTimerUI = ({ endTime, size = 'md', layout = 'horizontal', theme = 'light', showLabels = true, innerShape = 'rectangle', equalUnitSize = true, customColors = {}, showUnits = { days: true, hours: true, minutes: true, seconds: true }, onEnd, className, }) => {
12
12
  const time = (0, useServerTimer_1.useServerTimer)(endTime, onEnd);
13
+ // SharePoint Fluent UI Color Palettes
13
14
  const themeColors = {
14
- light: { background: '#ffffff', text: '#323130', unitBackground: '#f3f2f1', progress: '#0078d4' },
15
- dark: { background: '#323130', text: '#ffffff', unitBackground: '#505050', progress: '#0078d4' },
16
- brand: { background: '#fef9f3', text: '#323130', unitBackground: '#fffbdd', progress: '#0078d4' },
15
+ light: {
16
+ background: '#ffffff',
17
+ text: '#323130',
18
+ unitBackground: '#f3f2f1', // NeutralLighter
19
+ },
20
+ dark: {
21
+ background: '#201f1e', // NeutralDark
22
+ text: '#ffffff',
23
+ unitBackground: '#323130', // NeutralPrimary
24
+ },
25
+ brand: {
26
+ background: '#fef9f3',
27
+ text: '#323130',
28
+ unitBackground: '#fffbdd', // Soft brand tint
29
+ },
17
30
  };
18
31
  const colors = Object.assign(Object.assign({}, themeColors[theme]), customColors);
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 })] }));
32
+ /**
33
+ * Automatically maps the container size to the number size
34
+ * to maintain SharePoint visual hierarchy.
35
+ */
36
+ const getNumberSize = () => {
37
+ if (size === 'sm')
38
+ return 'sm';
39
+ if (size === 'lg')
40
+ return 'lg';
41
+ return 'md';
42
+ };
43
+ 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, numberSize: getNumberSize(), background: colors.unitBackground, color: colors.text, showLabel: showLabels, shape: innerShape, equalSize: equalUnitSize })), showUnits.hours && ((0, jsx_runtime_1.jsx)(TimerUnit_1.default, { label: "Hours", value: time.hours, size: size, numberSize: getNumberSize(), background: colors.unitBackground, color: colors.text, showLabel: showLabels, shape: innerShape, equalSize: equalUnitSize })), showUnits.minutes && ((0, jsx_runtime_1.jsx)(TimerUnit_1.default, { label: "Minutes", value: time.minutes, size: size, numberSize: getNumberSize(), background: colors.unitBackground, color: colors.text, showLabel: showLabels, shape: innerShape, equalSize: equalUnitSize })), showUnits.seconds && ((0, jsx_runtime_1.jsx)(TimerUnit_1.default, { label: "Seconds", value: time.seconds, size: size, numberSize: getNumberSize(), background: colors.unitBackground, color: colors.text, showLabel: showLabels, shape: innerShape, equalSize: equalUnitSize }))] }));
20
44
  };
21
45
  exports.ServerTimerUI = ServerTimerUI;
@@ -7,6 +7,9 @@ interface TimerUnitProps {
7
7
  background?: string;
8
8
  color?: string;
9
9
  numberSize?: 'sm' | 'md' | 'lg';
10
+ showLabel?: boolean;
11
+ shape?: 'rectangle' | 'circle';
12
+ equalSize?: boolean;
10
13
  }
11
14
  declare const TimerUnit: React.FC<TimerUnitProps>;
12
15
  export default TimerUnit;
@@ -1,50 +1,36 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const jsx_runtime_1 = require("react/jsx-runtime");
4
- const TimerUnit = ({ label, value, size = 'md', background = '#f3f2f1', // SharePoint NeutralLighter
5
- color = '#323130', // SharePoint NeutralPrimary
6
- numberSize = 'md', }) => {
7
- /**
8
- * Label Typography - Based on your Engine Body Options
9
- * sm: 11px, md: 13px, lg: 15px
10
- */
4
+ const TimerUnit = ({ label, value, size = 'md', background = '#f3f2f1', color = '#323130', numberSize = 'md', showLabel = true, shape = 'rectangle', equalSize = true, }) => {
5
+ // 1. Typography from your Engine Settings
11
6
  const getLabelStyles = () => {
12
7
  if (size === 'sm')
13
8
  return { fontSize: '11px', lineHeight: 1.4, fontWeight: 400 };
14
9
  if (size === 'lg')
15
10
  return { fontSize: '15px', lineHeight: 1.5, fontWeight: 400 };
16
- return { fontSize: '13px', lineHeight: 1.5, fontWeight: 400 }; // Default md
11
+ return { fontSize: '13px', lineHeight: 1.5, fontWeight: 400 };
17
12
  };
18
- /**
19
- * Number Typography - Based on your Engine Title/Heading Options
20
- * sm (Heading): 18px, md (Title): 24px, lg (Hero): 32px
21
- */
22
13
  const getNumberStyles = () => {
23
14
  if (numberSize === 'sm')
24
- return { fontSize: '18px', fontWeight: 600, lineHeight: 1.4 };
15
+ return { fontSize: '18px', fontWeight: 600, lineHeight: 1 };
25
16
  if (numberSize === 'lg')
26
- return { fontSize: '32px', fontWeight: 700, lineHeight: 1.2 };
27
- return { fontSize: '24px', fontWeight: 600, lineHeight: 1.3 }; // Default md (Title)
17
+ return { fontSize: '32px', fontWeight: 700, lineHeight: 1 };
18
+ return { fontSize: '24px', fontWeight: 600, lineHeight: 1 };
28
19
  };
29
- const containerStyles = {
30
- display: 'flex',
31
- flexDirection: 'column',
32
- alignItems: 'center',
33
- justifyContent: 'center',
34
- backgroundColor: background,
35
- color: color,
36
- // SharePoint Style: Subtle rounding and very light border
37
- borderRadius: '2px',
38
- border: '1px solid #edebe9',
39
- // Spacing
40
- padding: size === 'sm' ? '4px 8px' : size === 'md' ? '8px 12px' : '12px 16px',
41
- minWidth: size === 'sm' ? '48px' : size === 'md' ? '64px' : '80px',
42
- // Visuals
43
- boxShadow: '0 1.6px 3.6px 0 rgba(0,0,0,0.132), 0 0.3px 0.9px 0 rgba(0,0,0,0.108)', // Fluent Depth
44
- transition: 'transform 0.1s ease, box-shadow 0.1s ease',
45
- boxSizing: 'border-box',
46
- fontFamily: '"Segoe UI", "Segoe UI Web (West European)", -apple-system, BlinkMacSystemFont, Roboto, sans-serif',
20
+ // 2. Square/Circle Dimension Logic
21
+ // Forces height to match width if equalSize or circle is requested
22
+ const getDimensions = () => {
23
+ const baseWidth = size === 'sm' ? '56px' : size === 'md' ? '72px' : '96px';
24
+ if (equalSize || shape === 'circle') {
25
+ return { width: baseWidth, height: baseWidth };
26
+ }
27
+ return { minWidth: baseWidth };
47
28
  };
48
- return ((0, jsx_runtime_1.jsxs)("div", { style: containerStyles, className: "timer-unit", children: [(0, jsx_runtime_1.jsx)("span", { style: Object.assign(Object.assign({}, getNumberStyles()), { display: 'block' }), children: value.toString().padStart(2, '0') }), (0, jsx_runtime_1.jsx)("span", { style: Object.assign(Object.assign({}, getLabelStyles()), { marginTop: '2px', textTransform: 'lowercase', opacity: 0.8, whiteSpace: 'nowrap' }), children: label })] }));
29
+ const containerStyles = Object.assign(Object.assign({ display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center', backgroundColor: background, color: color, boxSizing: 'border-box', fontFamily: '"Segoe UI", -apple-system, BlinkMacSystemFont, sans-serif', transition: 'all 0.2s ease-in-out', border: '1px solid #edebe9',
30
+ // Shape logic
31
+ borderRadius: shape === 'circle' ? '50%' : '2px' }, getDimensions()), {
32
+ // Visuals (Fluent Depth)
33
+ boxShadow: '0 1.6px 3.6px 0 rgba(0,0,0,0.1), 0 0.3px 0.9px 0 rgba(0,0,0,0.05)', padding: shape === 'circle' ? '0' : (size === 'sm' ? '4px' : '8px') });
34
+ return ((0, jsx_runtime_1.jsxs)("div", { style: containerStyles, className: `timer-unit timer-unit--${shape}`, children: [(0, jsx_runtime_1.jsx)("span", { style: getNumberStyles(), children: value.toString().padStart(2, '0') }), showLabel && ((0, jsx_runtime_1.jsx)("span", { style: Object.assign(Object.assign({}, getLabelStyles()), { marginTop: shape === 'circle' ? '2px' : '4px', textTransform: 'lowercase', opacity: 0.8, whiteSpace: 'nowrap' }), children: label }))] }));
49
35
  };
50
36
  exports.default = TimerUnit;
@@ -1,6 +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 type TimerInnerShape = 'rectangle' | 'circle';
4
5
  export interface TimerUnits {
5
6
  days?: boolean;
6
7
  hours?: boolean;
@@ -14,6 +15,11 @@ export interface ServerTimerUIProps {
14
15
  theme?: TimerTheme;
15
16
  showUnits?: TimerUnits;
16
17
  className?: string;
18
+ /** Show or hide labels */
19
+ showLabels?: boolean;
20
+ /** Inner background shape */
21
+ innerShape?: TimerInnerShape;
22
+ equalUnitSize?: boolean;
17
23
  customColors?: {
18
24
  background?: string;
19
25
  text?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "server-time-timer-yolabs-ui",
3
- "version": "1.0.17",
3
+ "version": "1.0.19",
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",