Skip to content

Commit 0e73c31

Browse files
committed
fix: show expected start date and fix label value for date picker input
1 parent c9f4efe commit 0e73c31

File tree

3 files changed

+29
-27
lines changed

3 files changed

+29
-27
lines changed

apps/website/src/components/DatePicker.astro

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,10 @@ const { classNames, labelProps, label = "", onDark } = Astro.props;
2727
<input
2828
{...Astro.props.inputProps}
2929
type="date"
30-
id="date-picker"
3130
class="peer/input text-transparent relative z-[4] ml-[1px] h-[46px] w-[calc(100%-2px)]
3231
rounded-[6px] border border-transparent bg-transparent px-4 py-2.5
3332
focus:border-transparent focus:outline-0 focus:ring-0
34-
focus:text-secondary valid:text-secondary"
33+
focus:text-secondary"
3534
/>
3635

3736
<label
@@ -48,7 +47,6 @@ const { classNames, labelProps, label = "", onDark } = Astro.props;
4847
z-[3]
4948
peer-focus/input:translate-y-0
5049
peer-focus/input:translate-x-0
51-
peer-valid/input:translate-0
5250
`,
5351
{ "text-secondary": !onDark, "text-neutral-50": onDark },
5452
)}
@@ -71,6 +69,24 @@ const { classNames, labelProps, label = "", onDark } = Astro.props;
7169
</div>
7270
</div>
7371

74-
<script>
75-
72+
<script is:inline>
73+
const dateInput = document.getElementById("form-start-date");
74+
const label = document.getElementById("form-start-date-label");
75+
if (dateInput && label) {
76+
dateInput.addEventListener("change", () => {
77+
if (dateInput.value) {
78+
label.classList.remove("translate-y-[37px]", "translate-x-[17px]");
79+
dateInput.classList.remove("text-transparent");
80+
label.classList.add("translate-y-0", "translate-x-0");
81+
} else {
82+
label.classList.remove("translate-y-0", "translate-x-0");
83+
dateInput.classList.add("text-transparent");
84+
label.classList.add(
85+
"translate-y-[37px]",
86+
"translate-x-[17px]",
87+
"text-transparent",
88+
);
89+
}
90+
});
91+
}
7692
</script>

apps/website/src/components/GetYourPlanForm.astro

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
---
2+
import classNames from "classnames";
23
import * as formContent from "../content/contact/get-your-plan-form.md";
34
import "../styles/loader.css";
45
import Field from "./Field.astro";
@@ -71,9 +72,9 @@ const enableModalForm = import.meta.env.PUBLIC_ENABLE_MODAL_FORM === "true";
7172
type={enableModalForm ? "button" : "submit"}
7273
id="form-submit-button"
7374
class="rounded-md
74-
min-h-14
75-
px-[25px] w-full py-4
76-
text-center
75+
min-h-14
76+
px-[25px] w-full py-4
77+
text-center
7778
text-secondary
7879
text-base
7980
font-medium
@@ -113,13 +114,6 @@ const enableModalForm = import.meta.env.PUBLIC_ENABLE_MODAL_FORM === "true";
113114
"#get-your-plan-form-loader",
114115
);
115116

116-
submitBtn?.addEventListener("click", () => {
117-
const startDateInput = document.getElementById("form-start-date");
118-
if (startDateInput) {
119-
startDateInput.setAttribute("required", "");
120-
}
121-
});
122-
123117
const notificationElem = form?.querySelector("#form-notification");
124118

125119
/* Modal part of form elements */
@@ -151,20 +145,10 @@ const enableModalForm = import.meta.env.PUBLIC_ENABLE_MODAL_FORM === "true";
151145
};
152146

153147
const handleCloseModal = () => {
154-
const startDateInput = document.getElementById("form-start-date");
155-
if (startDateInput) {
156-
startDateInput.removeAttribute("required");
157-
}
158148
getPlanModal?.close();
159149
};
160150

161151
if (getPlanModal) {
162-
getPlanModal.addEventListener("close", () => {
163-
const startDateInput = document.getElementById("form-start-date");
164-
if (startDateInput) {
165-
startDateInput.removeAttribute("required");
166-
}
167-
});
168152
getPlanModal.addEventListener("click", handleModalSoftDismiss);
169153
submitBtn?.addEventListener("click", handleOpenModal);
170154
}
@@ -200,7 +184,8 @@ const enableModalForm = import.meta.env.PUBLIC_ENABLE_MODAL_FORM === "true";
200184
const consent = formData.get("form-consent");
201185
const companyName = formData.get("form-company");
202186
const mainChallenge = formData.get("form-challenge");
203-
const startDate = formData.get("form-start-date");
187+
const expectedStartDate = formData.get("form-start-date");
188+
console.log("startDate", expectedStartDate)
204189

205190
if (!name || !email || !consent) {
206191
return;
@@ -222,7 +207,7 @@ const enableModalForm = import.meta.env.PUBLIC_ENABLE_MODAL_FORM === "true";
222207
hasConsent: consent ? true : false,
223208
companyName: companyName || "",
224209
mainChallenge: mainChallenge || "",
225-
startDate: startDate || "",
210+
expectedStartDate: expectedStartDate || "",
226211
}),
227212
},
228213
);

apps/website/src/components/GetYourPlanModal.astro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ import DatePicker from "./DatePicker.astro";
5151
min: new Date(Date.now()).toISOString().split("T")[0] }}
5252
labelProps={{
5353
for: "form-start-date",
54+
id: "form-start-date-label",
5455
"aria-hidden": false,
5556
}}
5657
/>

0 commit comments

Comments
 (0)