Доработки по главной странице, итерация 6
This commit is contained in:
parent
40985fb7a3
commit
9083c29a26
|
|
@ -2,14 +2,14 @@
|
||||||
|
|
||||||
import React, { useState } from "react";
|
import React, { useState } from "react";
|
||||||
import {
|
import {
|
||||||
Select,
|
Popover,
|
||||||
SelectContent,
|
PopoverContent,
|
||||||
SelectTrigger,
|
PopoverTrigger,
|
||||||
SelectValue,
|
} from "@/components/ui/popover";
|
||||||
} from "@/components/ui/select";
|
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import Icon from "../ui/icon";
|
import Icon from "../ui/icon";
|
||||||
import { Counter } from "../ui/counter";
|
import { Counter } from "../ui/counter";
|
||||||
|
import { ChevronUp, ChevronDown } from "lucide-react";
|
||||||
|
|
||||||
interface GuestPickerProps {
|
interface GuestPickerProps {
|
||||||
onApply?: (adults: number, children: number) => void;
|
onApply?: (adults: number, children: number) => void;
|
||||||
|
|
@ -17,7 +17,7 @@ interface GuestPickerProps {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const GuestPicker: React.FC<GuestPickerProps> = ({ onApply }) => {
|
export const GuestPicker: React.FC<GuestPickerProps> = ({ onApply }) => {
|
||||||
const [adults, setAdults] = useState<number>(1);
|
const [adults, setAdults] = useState<number>(0);
|
||||||
const [children, setChildren] = useState<number>(0);
|
const [children, setChildren] = useState<number>(0);
|
||||||
const [isOpen, setIsOpen] = useState<boolean>(false);
|
const [isOpen, setIsOpen] = useState<boolean>(false);
|
||||||
|
|
||||||
|
|
@ -38,26 +38,36 @@ export const GuestPicker: React.FC<GuestPickerProps> = ({ onApply }) => {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<Select
|
<Popover
|
||||||
open={isOpen}
|
open={isOpen}
|
||||||
onOpenChange={setIsOpen}
|
onOpenChange={setIsOpen}
|
||||||
>
|
>
|
||||||
<SelectTrigger className="h-[64px] px-4">
|
<PopoverTrigger asChild>
|
||||||
|
<Button
|
||||||
|
variant="outline"
|
||||||
|
className="h-[64px] px-4 w-full justify-between"
|
||||||
|
>
|
||||||
<div className="flex items-center">
|
<div className="flex items-center">
|
||||||
<Icon
|
<Icon
|
||||||
name="people"
|
name="people"
|
||||||
className="mr-3"
|
className="mr-3"
|
||||||
/>
|
/>
|
||||||
<SelectValue placeholder={getDisplayText()} />
|
<span>{getDisplayText()}</span>
|
||||||
</div>
|
</div>
|
||||||
</SelectTrigger>
|
{isOpen ? (
|
||||||
<SelectContent className="rounded-[20px] p-6 pb-4">
|
<ChevronUp className="h-4 w-4" />
|
||||||
|
) : (
|
||||||
|
<ChevronDown className="h-4 w-4" />
|
||||||
|
)}
|
||||||
|
</Button>
|
||||||
|
</PopoverTrigger>
|
||||||
|
<PopoverContent className="rounded-[20px] p-6 pb-4 w-56">
|
||||||
<div className="mb-4">
|
<div className="mb-4">
|
||||||
<Counter
|
<Counter
|
||||||
label="Взрослые"
|
label="Взрослые"
|
||||||
value={adults}
|
value={adults}
|
||||||
onChange={setAdults}
|
onChange={setAdults}
|
||||||
min={1}
|
min={0}
|
||||||
max={10}
|
max={10}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -77,8 +87,8 @@ export const GuestPicker: React.FC<GuestPickerProps> = ({ onApply }) => {
|
||||||
>
|
>
|
||||||
Применить
|
Применить
|
||||||
</Button>
|
</Button>
|
||||||
</SelectContent>
|
</PopoverContent>
|
||||||
</Select>
|
</Popover>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -31,14 +31,14 @@ export const Counter: React.FC<CounterProps> = ({
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="relative flex w-full items-center justify-between items-center border border-gray-200 rounded-full px-8 py-4 bg-white">
|
<div className="relative flex w-full items-center justify-between items-center border border-gray-200 rounded-full px-8 py-3 bg-white">
|
||||||
<label className="absolute left-[32px] top-0 transform -translate-y-1/2 text-xs text-gray-500 transition-all duration-200 bg-white px-1">
|
<label className="absolute left-[32px] top-0 transform -translate-y-1/2 text-xs text-gray-500 transition-all duration-200 bg-white px-1">
|
||||||
{label}
|
{label}
|
||||||
</label>
|
</label>
|
||||||
<button
|
<button
|
||||||
onClick={handleDecrement}
|
onClick={handleDecrement}
|
||||||
disabled={value <= min}
|
disabled={value <= min}
|
||||||
className={`w-8 h-8 rounded-[8px] border flex items-center justify-center ${
|
className={`w-7 h-7 rounded-[8px] border flex items-center justify-center ${
|
||||||
value <= min
|
value <= min
|
||||||
? "border-gray-300 text-gray-300 cursor-not-allowed"
|
? "border-gray-300 text-gray-300 cursor-not-allowed"
|
||||||
: "border-gray-400 text-gray-600 hover:border-gray-500"
|
: "border-gray-400 text-gray-600 hover:border-gray-500"
|
||||||
|
|
@ -52,13 +52,13 @@ export const Counter: React.FC<CounterProps> = ({
|
||||||
<button
|
<button
|
||||||
onClick={handleIncrement}
|
onClick={handleIncrement}
|
||||||
disabled={value >= max}
|
disabled={value >= max}
|
||||||
className={`w-8 h-8 rounded-[8px] border flex items-center justify-center ${
|
className={`w-7 h-7 rounded-[8px] border flex items-center justify-center ${
|
||||||
value >= max
|
value >= max
|
||||||
? "border-gray-300 text-gray-300 cursor-not-allowed"
|
? "border-gray-300 text-gray-300 cursor-not-allowed"
|
||||||
: "border-teal-500 text-[#008299] hover:border-[#008299]"
|
: "border-[#008299] text-[#008299] hover:border-[#008299]"
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
<Plus className="w-4 h-4" />
|
<Plus className="w-4 h-4 text-gray-600" />
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue