Skip to content

Commit 3c27cd2

Browse files
committed
Remove HourMark and MinuteMark components
1 parent fd22a41 commit 3c27cd2

File tree

7 files changed

+13
-90
lines changed

7 files changed

+13
-90
lines changed

packages/react-clock/src/Clock.spec.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ describe('Clock', () => {
9999
});
100100
});
101101

102-
it('passes formatHour to HourMark components', () => {
102+
it('uses formatHour properly if given', () => {
103103
const formatHour = () => 'H';
104104
const { container } = render(<Clock formatHour={formatHour} renderNumbers />);
105105

packages/react-clock/src/Clock.tsx

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@ import clsx from 'clsx';
22
import { getHours, getMilliseconds, getMinutes, getSeconds } from '@wojtekmaj/date-utils';
33

44
import Hand from './Hand.js';
5-
import MinuteMark from './MinuteMark.js';
6-
import HourMark from './HourMark.js';
5+
import Mark from './Mark.js';
76

8-
import type { formatHour as defaultFormatHour } from './shared/hourFormatter.js';
7+
import { formatHour as defaultFormatHour } from './shared/hourFormatter.js';
98

109
import type {
1110
ClassName,
@@ -192,7 +191,7 @@ export type ClockProps = {
192191
*/
193192
export default function Clock({
194193
className,
195-
formatHour,
194+
formatHour = defaultFormatHour,
196195
hourHandLength = 50,
197196
hourHandOppositeLength,
198197
hourHandWidth = 4,
@@ -227,7 +226,7 @@ export default function Clock({
227226

228227
if (!isHourMark) {
229228
minuteMarks.push(
230-
<MinuteMark
229+
<Mark
231230
key={`minute_${i}`}
232231
angle={i * 6}
233232
length={minuteMarksLength}
@@ -248,14 +247,12 @@ export default function Clock({
248247
const hourMarks = [];
249248
for (let i = 1; i <= 12; i += 1) {
250249
hourMarks.push(
251-
<HourMark
250+
<Mark
252251
key={`hour_${i}`}
253252
angle={i * 30}
254-
formatHour={formatHour}
255253
length={hourMarksLength}
256-
locale={locale}
257254
name="hour"
258-
number={renderNumbers ? i : undefined}
255+
number={renderNumbers ? formatHour(locale, i) : undefined}
259256
width={hourMarksWidth}
260257
/>,
261258
);

packages/react-clock/src/HourMark.spec.tsx

Lines changed: 0 additions & 31 deletions
This file was deleted.

packages/react-clock/src/HourMark.tsx

Lines changed: 0 additions & 22 deletions
This file was deleted.

packages/react-clock/src/Mark.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { memo } from 'react';
2+
13
import type { MarkLength, MarkWidth } from './shared/types.js';
24

35
type MarkProps = {
@@ -8,7 +10,7 @@ type MarkProps = {
810
width?: MarkWidth;
911
};
1012

11-
export default function Mark({
13+
const Mark: React.FC<MarkProps> = memo(function Mark({
1214
angle = 0,
1315
length = 10,
1416
name,
@@ -43,4 +45,6 @@ export default function Mark({
4345
) : null}
4446
</div>
4547
);
46-
}
48+
});
49+
50+
export default Mark;

packages/react-clock/src/MinuteMark.spec.tsx

Lines changed: 0 additions & 14 deletions
This file was deleted.

packages/react-clock/src/MinuteMark.tsx

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)