Skip to content

Commit bb16638

Browse files
committed
chore(lib): renamed Date to Calendar
1 parent e7fa673 commit bb16638

File tree

10 files changed

+76
-76
lines changed

10 files changed

+76
-76
lines changed

biome.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
},
88
"files": {
99
"ignoreUnknown": false,
10-
"ignore": ["**/*.res.js"]
10+
"ignore": ["**/*.js", "**/*.d.ts"]
1111
},
1212
"formatter": {
1313
"enabled": true,

docs/3-api-reference.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ const MyStatusLeft = () => <Box>
189189
| -------------- | ------- |
190190
| `icon` | string |
191191

192-
### `<Date />`
192+
### `<Calendar />`
193193
| Prop | Type |
194194
| -------------- | ------- |
195195
| `icon` | string |

examples/index.tsx

+29-18
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,56 @@
1-
import { Box, BetterTmuxConfig, WindowConfig, useTheme, tmux } from 'better-tmux'
2-
import { Date, SessionName } from 'better-tmux/widgets'
1+
import {
2+
Box,
3+
type BetterTmuxConfig,
4+
type WindowConfig,
5+
useTheme,
6+
tmux,
7+
} from "better-tmux";
8+
import { Calendar, SessionName } from "better-tmux/widgets";
39

410
const Window = ({ type, number, name }: WindowConfig) => {
5-
let theme = useTheme()
6-
let styles = type === "active" ? { bg: theme.primary, fg: theme.background, bold: true } : {}
11+
const theme = useTheme();
12+
const styles =
13+
type === "active"
14+
? { bg: theme.primary, fg: theme.background, bold: true }
15+
: {};
716

817
return (
918
<Box padding={1} {...styles}>
1019
{number}: {name}
1120
</Box>
12-
)
13-
}
21+
);
22+
};
1423

1524
const StatusLeft = () => (
1625
<Box>
1726
<SessionName />
1827
</Box>
19-
)
28+
);
2029

2130
const StatusRight = () => (
2231
<Box>
23-
<Date format={`${tmux.globals.abbreviated_month} ${tmux.globals.day}`} />
32+
<Calendar
33+
format={`${tmux.globals.abbreviated_month} ${tmux.globals.day}`}
34+
/>
2435
</Box>
25-
)
36+
);
2637

2738
export default {
28-
theme: 'ayu-light',
39+
theme: "ayu-light",
2940
bindings: [
3041
{
31-
key: 'x',
32-
command: 'kill-window'
33-
}
42+
key: "x",
43+
command: "kill-window",
44+
},
3445
],
35-
options:{
46+
options: {
3647
setTitlesString: " ",
37-
prefix: 'C-a'
48+
prefix: "C-a",
3849
},
3950
status: {
4051
left: <StatusLeft />,
4152
right: <StatusRight />,
42-
position: 'top'
53+
position: "top",
4354
},
44-
window: (props) => <Window {...props} />
45-
} satisfies BetterTmuxConfig
55+
window: (props) => <Window {...props} />,
56+
} satisfies BetterTmuxConfig;

packages/lib/CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [Unreleased]
9+
10+
### Breaking change 💥
11+
12+
- Renamed widget `Date` to `Calendar` to avoid conflicts with the native `Date` constructor
13+
814
## [0.0.15] - 2024-10-20
915

1016
### Fixes 🐛

packages/lib/src/components.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ReactNode } from "react"
1+
import type { ReactNode } from "react"
22

33
export type ElementProps = {
44
padding?: number,

packages/lib/src/global.d.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { Theme } from './types.ts'
2-
import { ElementProps } from "./components.tsx"
1+
import type { Theme } from './types.ts'
2+
import type { ElementProps } from "./components.tsx"
33

44
declare global {
55
namespace JSX {
@@ -16,5 +16,3 @@ declare global {
1616
}
1717
}
1818
}
19-
20-
export { }

packages/lib/src/hooks/use-theme.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Theme } from "../types.js"
1+
import type { Theme } from "../types.js"
22

33
type ThemePalette = {
44
background: string,

packages/lib/src/presets/index.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { useTheme } from '../hooks/use-theme.js'
2-
import { BetterTmuxConfig, WindowConfig } from '../types.js'
2+
import type { BetterTmuxConfig, WindowConfig } from '../types.js'
33

44
const Window = ({ type, number, name }: WindowConfig) => {
55
const theme = useTheme()
6-
let style = type === "active" ? { bg: theme.primary, fg: theme.foreground } : {}
6+
const style = type === "active" ? { bg: theme.primary, fg: theme.foreground } : {}
77

88
return (
99
<box padding={1} {...style}>

packages/lib/src/widgets/index.tsx

+32-47
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,60 @@
1-
import { tmux } from "../tmux.js"
2-
import { Widget, WidgetIcon, WidgetLabel } from "./widget.js"
3-
export * from './widget.js'
1+
import { tmux } from "../tmux.js";
2+
import { Widget, WidgetIcon, WidgetLabel } from "./widget.js";
3+
export * from "./widget.js";
44

55
type CommonModuleProps = {
6-
icon?: string,
7-
}
6+
icon?: string;
7+
};
88

9-
type HostnameProps = CommonModuleProps
9+
type HostnameProps = CommonModuleProps;
1010

1111
export const Hostname = ({ icon }: HostnameProps) => {
1212
return (
1313
<Widget>
14-
<WidgetIcon>
15-
{icon ?? ""}
16-
</WidgetIcon>
17-
<WidgetLabel>
18-
{tmux.globals.hostname}
19-
</WidgetLabel>
14+
<WidgetIcon>{icon ?? ""}</WidgetIcon>
15+
<WidgetLabel>{tmux.globals.hostname}</WidgetLabel>
2016
</Widget>
21-
)
22-
}
17+
);
18+
};
2319

24-
type SessionNameProps = CommonModuleProps
20+
type SessionNameProps = CommonModuleProps;
2521

2622
export const SessionName = ({ icon }: SessionNameProps) => {
2723
return (
2824
<Widget>
29-
<WidgetIcon>
30-
{icon ?? ""}
31-
</WidgetIcon>
32-
<WidgetLabel>
33-
{tmux.globals.sessionName}
34-
</WidgetLabel>
25+
<WidgetIcon>{icon ?? ""}</WidgetIcon>
26+
<WidgetLabel>{tmux.globals.sessionName}</WidgetLabel>
3527
</Widget>
36-
)
37-
}
28+
);
29+
};
3830

3931
type ClockProps = CommonModuleProps & {
40-
format?: string
41-
}
32+
format?: string;
33+
};
4234

4335
export const Clock = ({ format, icon }: ClockProps) => {
44-
const value = format ?? `${tmux.globals.hour_24}:${tmux.globals.minute}`
36+
const value = format ?? `${tmux.globals.hour_24}:${tmux.globals.minute}`;
4537

4638
return (
4739
<Widget>
48-
<WidgetIcon>
49-
{icon ?? ""}
50-
</WidgetIcon>
51-
<WidgetLabel>
52-
{value}
53-
</WidgetLabel>
40+
<WidgetIcon>{icon ?? ""}</WidgetIcon>
41+
<WidgetLabel>{value}</WidgetLabel>
5442
</Widget>
55-
)
56-
}
43+
);
44+
};
5745

58-
type DateProps = CommonModuleProps & {
59-
format?: string
60-
}
46+
type CalendarProps = CommonModuleProps & {
47+
format?: string;
48+
};
6149

62-
export const Date = ({ format, icon }: DateProps) => {
63-
const value = format ?? `${tmux.globals.month}-${tmux.globals.day}-${tmux.globals.year}`
50+
export const Calendar = ({ format, icon }: CalendarProps) => {
51+
const value =
52+
format ?? `${tmux.globals.month}-${tmux.globals.day}-${tmux.globals.year}`;
6453

6554
return (
6655
<Widget>
67-
<WidgetIcon>
68-
{icon ?? ""}
69-
</WidgetIcon>
70-
<WidgetLabel>
71-
{value}
72-
</WidgetLabel>
56+
<WidgetIcon>{icon ?? ""}</WidgetIcon>
57+
<WidgetLabel>{value}</WidgetLabel>
7358
</Widget>
74-
)
75-
}
59+
);
60+
};

packages/lib/src/widgets/widget.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { PropsWithChildren } from "react"
1+
import type { PropsWithChildren } from "react"
22
import { useTheme } from "../hooks/use-theme.js"
33

44
export const Widget = ({ children }: PropsWithChildren) => {

0 commit comments

Comments
 (0)