Skip to content

Commit 6e1e46e

Browse files
feat(date-time-picker-web): enhance DateTimePicker preview and container layout
1 parent 3656c64 commit 6e1e46e

File tree

3 files changed

+48
-14
lines changed

3 files changed

+48
-14
lines changed
Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,44 @@
11
import { ReactElement } from "react";
22
import { DateTimePickerPreviewProps } from "../typings/DateTimePickerProps";
3-
import { DatePicker } from "./components/DatePicker";
43
import "./ui/DateTimePicker.scss";
54

65
export function preview(props: DateTimePickerPreviewProps): ReactElement {
7-
console.info("Rendering DateTimePicker preview with props:", props);
8-
return <DatePicker label={props.label} />;
6+
const label = props.showLabel ? props.label : null;
7+
const portalId = `datepicker_` + Math.random();
8+
9+
return (
10+
<div className="widget-datetimepicker">
11+
{label ? (
12+
<div className="widget-datetimepicker-label-wrapper">
13+
<div id={portalId} />
14+
15+
<label className="widget-datetimepicker-label" id="datepicker-label">
16+
{label}
17+
</label>
18+
</div>
19+
) : (
20+
<span className="sr-only" id="datepicker-label">
21+
Date picker
22+
</span>
23+
)}
24+
25+
<div className="widget-datetimepicker-wrapper">
26+
<div className="react-datepicker-wrapper">
27+
<div className="react-datepicker__input-container">
28+
<input
29+
className="widget-datetimepicker-input react-datepicker-ignore-onclickoutside"
30+
placeholder={props.placeholder ?? ""}
31+
readOnly
32+
type="text"
33+
value={props.dateAttribute ? `[${props.dateAttribute}]` : "[Date time picker]"}
34+
/>
35+
</div>
36+
</div>
37+
38+
<button aria-label="Show calendar" className="widget-datetimepicker-input-button" type="button">
39+
<span className="mx-icon-filled mx-icon-calendar" />
40+
</button>
41+
</div>
42+
</div>
43+
);
944
}

packages/pluggableWidgets/date-time-picker-web/src/components/DateTimePickerContainer.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,19 @@ export function DateTimePickerContainer(props: DateTimePickerContainerProps) {
3535
data-focusindex={props.tabIndex}
3636
style={props.style}
3737
>
38-
<div className="widget-datetimepicker-label-wrapper">
39-
<div id={portalId} />
38+
{label ? (
39+
<div className="widget-datetimepicker-label-wrapper">
40+
<div id={portalId} />
4041

41-
{label ? (
4242
<label className="widget-datetimepicker-label" id={pickerProps.ariaLabelledBy}>
4343
{label}
4444
</label>
45-
) : (
46-
<span className="sr-only" id={pickerProps.ariaLabelledBy}>
47-
Date picker
48-
</span>
49-
)}
50-
</div>
45+
</div>
46+
) : (
47+
<span className="sr-only" id={pickerProps.ariaLabelledBy}>
48+
Date picker
49+
</span>
50+
)}
5151

5252
<div className="widget-datetimepicker-wrapper">
5353
<ReactDatePicker {...pickerProps} ref={controller.pickerRef} />

packages/pluggableWidgets/date-time-picker-web/src/ui/DateTimePicker.scss

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@
2222
&-wrapper {
2323
align-items: center;
2424
display: flex;
25-
flex: 0 0 75%;
26-
max-width: 75%;
25+
flex: 1;
2726
padding: 0 16px;
2827
}
2928

0 commit comments

Comments
 (0)