Skip to content

Commit 0809f6f

Browse files
feat(calendar-web): create Button and CustomToolbar components
1 parent 20e3fac commit 0809f6f

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import classNames from "classnames";
2+
import { createElement, ReactElement, PropsWithChildren } from "react";
3+
4+
type ButtonProps = PropsWithChildren & { isActive?: boolean; onClick?: () => void };
5+
6+
export function Button({ children, isActive = false, onClick }: ButtonProps): ReactElement {
7+
return (
8+
<button className={classNames("btn", "btn-default", { active: isActive })} onClick={onClick}>
9+
{children}
10+
</button>
11+
);
12+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { createElement, ReactElement } from "react";
2+
import { Navigate, ToolbarProps } from "react-big-calendar";
3+
import { Button } from "./Button";
4+
import "react-big-calendar/lib/css/react-big-calendar.css";
5+
6+
export function CustomToolbar({ label, localizer, onNavigate, onView, view, views }: ToolbarProps): ReactElement {
7+
return (
8+
<div className="calendar-toolbar">
9+
<div className="align-left btn-group">
10+
<Button onClick={() => onNavigate(Navigate.PREVIOUS)}>
11+
<span className="glyphicon glyphicon-backward" />
12+
</Button>
13+
<Button onClick={() => onNavigate(Navigate.TODAY)}>{localizer.messages.today}</Button>
14+
<Button onClick={() => onNavigate(Navigate.NEXT)}>
15+
<span className="glyphicon glyphicon-forward" />
16+
</Button>
17+
</div>
18+
19+
<div className="align-center btn-group">
20+
<span className="calendar-label">{label}</span>
21+
</div>
22+
23+
<div className="align-right btn-group">
24+
{Array.isArray(views) &&
25+
views.map(name => {
26+
return (
27+
<Button key={name} onClick={() => onView(name)} isActive={view === name}>
28+
{localizer.messages[name]}
29+
</Button>
30+
);
31+
})}
32+
</div>
33+
</div>
34+
);
35+
}

0 commit comments

Comments
 (0)