Skip to content

Commit f49a972

Browse files
committed
white spaces removed
1 parent df1ed82 commit f49a972

File tree

2 files changed

+27
-30
lines changed

2 files changed

+27
-30
lines changed

app/page.tsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ const exportPng = async () => {
9191

9292

9393
<SelectBackground background={background} setBackground={setBackground} />
94-
<SelectPadding paddings={paddings} currentPadding={currentPadding} setCurrentPadding={setCurrentPadding} />
94+
<SelectPadding currentPadding={currentPadding} setCurrentPadding={setCurrentPadding} />
95+
9596
<div className="export-btn pt-2">
9697
<button
9798
className="flex items-center gap-1 py-1 px-2 bg-blue-400 rounded-md text-sm text-blue-400
@@ -127,7 +128,8 @@ const exportPng = async () => {
127128

128129

129130
<SelectBackground background={background} setBackground={setBackground} />
130-
<SelectPadding paddings={paddings} currentPadding={currentPadding} setCurrentPadding={setCurrentPadding} />
131+
<SelectPadding currentPadding={currentPadding} setCurrentPadding={setCurrentPadding} />
132+
131133
<div className="export-btn self-center ml-auto pt-4">
132134
<button
133135
className="flex items-center gap-3 py-2 px-3 bg-blue-400 rounded-md text-sm text-blue-400

components/SelectPadding.tsx

+23-28
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,39 @@
11
"use client";
2-
import React from "react";
2+
import React, { useState } from "react";
33

44
interface SelectPaddingProps {
5-
paddings: string[];
65
currentPadding: string;
76
setCurrentPadding: (padding: string) => void;
87
}
98

10-
function SelectPadding({
11-
paddings,
12-
currentPadding,
13-
setCurrentPadding,
14-
}: SelectPaddingProps) {
15-
const changePadding = (newPadding: string) => {
16-
setCurrentPadding(newPadding);
9+
function SelectPadding({ currentPadding, setCurrentPadding }: SelectPaddingProps) {
10+
// Handler to update padding value
11+
const changePadding = (e: React.ChangeEvent<HTMLInputElement>) => {
12+
const value = e.target.value;
13+
14+
// Ensure the padding stays within 0 and 4rem (40px)
15+
if (parseFloat(value) >= 0 && parseFloat(value) <= 4) {
16+
setCurrentPadding(`${value}rem`);
17+
}
1718
};
1819

1920
return (
2021
<div>
21-
<p className="py-[10px] text-sm font-medium">Padding Selector</p>
22-
<div className="flex flex-wrap gap-2 pb-2">
23-
{paddings.map((padding, i) => {
24-
return (
25-
<button
26-
key={i}
27-
onClick={() => changePadding(padding)}
28-
className={`h-[37px] flex flex-col justify-center text-sm px-2 cursor-pointer
29-
${
30-
currentPadding === padding &&
31-
"bg-[#3C3C3C] text-white rounded-md"
32-
} hover:text-white ease-linear transition-all duration-300
33-
`}
34-
>
35-
{padding}
36-
</button>
37-
);
38-
})}
22+
<p className="py-[10px] text-sm font-medium">Padding (0 - 4 rem)</p>
23+
<div className="flex items-center gap-2 pb-2">
24+
<input
25+
type="number"
26+
step="0.1" // Allow decimal steps like 0.5rem
27+
min="0"
28+
max="4"
29+
value={parseFloat(currentPadding)} // Convert 'rem' string to a number for the input value
30+
onChange={changePadding}
31+
className="h-[37px] w-[80px] px-2 text-sm bg-gray-200 rounded-md text-black focus:outline-none"
32+
/>
33+
<span className="text-sm">rem</span>
3934
</div>
4035
</div>
4136
);
4237
}
4338

44-
export default SelectPadding;
39+
export default SelectPadding;

0 commit comments

Comments
 (0)