Skip to content

Commit 3e6edc6

Browse files
committed
Add JSDoc documentation
1 parent ef5ecb3 commit 3e6edc6

File tree

1 file changed

+147
-0
lines changed

1 file changed

+147
-0
lines changed

packages/react-clock/src/Clock.tsx

+147
Original file line numberDiff line numberDiff line change
@@ -27,32 +27,179 @@ import type {
2727
} from './shared/types.js';
2828

2929
export type ClockProps = {
30+
/**
31+
* Class name(s) that will be added along with `"react-clock"` to the main react-clock `<time>` element.
32+
*
33+
* @example 'class1 class2'
34+
* @example ['class1', 'class2 class3']
35+
*/
3036
className?: ClassName;
37+
/**
38+
* Function called to override default formatting of hour marks. Can be used to use your own formatting function.
39+
*
40+
* @example (locale, hour) => formatHour(hour, 'HH')
41+
*/
3142
formatHour?: typeof defaultFormatHour;
43+
/**
44+
* Hour hand length, in %.
45+
*
46+
* @default 50
47+
* @example 80
48+
*/
3249
hourHandLength?: HandLength;
50+
/**
51+
* The length of the part of an hour hand on the opposite side the hand is pointing to, in %.
52+
*
53+
* @default 10
54+
* @example 20
55+
*/
3356
hourHandOppositeLength?: OppositeHandLength;
57+
/**
58+
* Hour hand width, in pixels.
59+
*
60+
* @default 4
61+
* @example 3
62+
*/
3463
hourHandWidth?: HandWidth;
64+
/**
65+
* Hour marks length, in %.
66+
*
67+
* @default 10
68+
* @example 8
69+
*/
3570
hourMarksLength?: MarkLength;
71+
/**
72+
* Hour marks width, in pixels.
73+
*
74+
* @default 3
75+
* @example 2
76+
*/
3677
hourMarksWidth?: MarkWidth;
78+
/**
79+
* Locale that should be used by the clock. Can be any [IETF language tag](https://en.wikipedia.org/wiki/IETF_language_tag).
80+
*
81+
* **Note**: When using SSR, setting this prop may help resolving hydration errors caused by locale mismatch between server and client.
82+
*
83+
* @example 'hu-HU'
84+
*/
3785
locale?: string;
86+
/**
87+
* Minute hand length, in %.
88+
*
89+
* @default 70
90+
* @example 80
91+
*/
3892
minuteHandLength?: HandLength;
93+
/**
94+
* The length of the part of a minute hand on the opposite side the hand is pointing to, in %.
95+
*
96+
* @default 10
97+
* @example 20
98+
*/
3999
minuteHandOppositeLength?: OppositeHandLength;
100+
/**
101+
* Minute hand width, in pixels.
102+
*
103+
* @default 2
104+
* @example 3
105+
*/
40106
minuteHandWidth?: HandWidth;
107+
/**
108+
* Minute marks length, in %.
109+
*
110+
* @default 6
111+
* @example 8
112+
*/
41113
minuteMarksLength?: MarkLength;
114+
/**
115+
* Minute marks width, in pixels.
116+
*
117+
* @default 1
118+
* @example 2
119+
*/
42120
minuteMarksWidth?: MarkWidth;
121+
/**
122+
* Whether hour marks shall be rendered.
123+
*
124+
* @default true
125+
* @example false
126+
*/
43127
renderHourMarks?: boolean;
128+
/**
129+
* Whether minute hand shall be rendered.
130+
*
131+
* @default true
132+
* @example false
133+
*/
44134
renderMinuteHand?: boolean;
135+
/**
136+
* Whether minute marks shall be rendered.
137+
*
138+
* @default true
139+
* @example false
140+
*/
45141
renderMinuteMarks?: boolean;
142+
/**
143+
* Whether numbers shall be rendered.
144+
*
145+
* @default true
146+
* @example false
147+
*/
46148
renderNumbers?: boolean;
149+
/**
150+
* Whether second hand shall be rendered.
151+
*
152+
* @default true
153+
* @example false
154+
*/
47155
renderSecondHand?: boolean;
156+
/**
157+
* Second hand length, in %.
158+
*
159+
* @default 90
160+
* @example 80
161+
*/
48162
secondHandLength?: HandLength;
163+
/**
164+
* The length of the part of a second hand on the opposite side the hand is pointing to, in %.
165+
*
166+
* @default 10
167+
* @example 20
168+
*/
49169
secondHandOppositeLength?: OppositeHandLength;
170+
/**
171+
* Second hand width, in pixels.
172+
*
173+
* @default 1
174+
* @example 2
175+
*/
50176
secondHandWidth?: HandWidth;
177+
/**
178+
* Clock size, in pixels (e.g. `200`) or as string (e.g. `"50vw"`).
179+
*
180+
* @default 150
181+
* @example 260
182+
* @example '50vw'
183+
*/
51184
size?: React.CSSProperties['width'];
185+
/**
186+
* Whether to use millisecond precision.
187+
*
188+
* @default false
189+
* @example true
190+
*/
52191
useMillisecondPrecision?: boolean;
192+
/**
193+
* Clock value. Must be provided.
194+
*
195+
* @example new Date()
196+
*/
53197
value?: string | Date | null;
54198
};
55199

200+
/**
201+
* Displays a complete clock.
202+
*/
56203
const Clock: React.FC<ClockProps> = function Clock({
57204
className,
58205
formatHour,

0 commit comments

Comments
 (0)