Skip to content

🎥 Make videos programmatically with React

counter w input

Patric Salvisbergc0e8b7a06979
diff --git a/packages/docs/components/LandingPage/Counter.tsx b/packages/docs/components/LandingPage/Counter.tsx
index 5b9e272d35..72071ea70b 100644
--- a/packages/docs/components/LandingPage/Counter.tsx
+++ b/packages/docs/components/LandingPage/Counter.tsx
@@ -1,5 +1,5 @@
-import type { SetStateAction } from "react";
-import React from "react";
+import type { ChangeEvent, SetStateAction } from "react";
+import React, { useCallback } from "react";
import styles from "./pricing.module.css";
const triangle = (
@@ -45,9 +45,26 @@ export const Counter: React.FC<{
count: number;
setCount: React.Dispatch<SetStateAction<number>>;
}> = ({ count, setCount }) => {
+ const handleChange = useCallback(
+ (e: ChangeEvent<HTMLInputElement>) => {
+ if (e.target.value.trim() === "") {
+ setCount(1);
+ return;
+ }
+
+ const max = Math.max(parseInt(e.target.value, 10), 1);
+ setCount(max);
+ },
+ [setCount],
+ );
return (
<div style={container}>
- <div className={styles.pricetag}>{count}</div>
+ <input
+ className={styles.counterinput}
+ type="number"
+ value={count}
+ onChange={handleChange}
+ />
<div style={{ display: "flex", flexDirection: "column", marginLeft: 10 }}>
<button
type="button"
diff --git a/packages/docs/components/LandingPage/pricing.module.css b/packages/docs/components/LandingPage/pricing.module.css
index 748be74279..cb14f2f2d4 100644
--- a/packages/docs/components/LandingPage/pricing.module.css
+++ b/packages/docs/components/LandingPage/pricing.module.css
@@ -9,6 +9,22 @@
color: var(--ifm-color-primary);
}
+.counterinput {
+ font-family: "GTPlanar", sans-serif;
+ font-size: 24px;
+ font-weight: 500;
+ width: 38px;
+ border: none;
+ text-align: end;
+}
+
+/* removes up and down arrows from input field */
+input[type="number"]::-webkit-inner-spin-button,
+input[type="number"]::-webkit-outer-spin-button {
+ -webkit-appearance: none;
+ margin: 0;
+}
+
.pricingcontainer {
display: flex;
flex-direction: column;