Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes presets overflow issue in live monitoring #7928

Merged
merged 1 commit into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions src/Components/CameraFeed/AssetBedSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export default function CameraPresetSelect(props: Props) {
return (
<>
<div className="hidden gap-2 whitespace-nowrap pr-2 md:flex">
{/* Desktop View */}
{props.options
.slice(0, props.options.length > 5 ? 4 : 5)
.map((option) => (
Expand All @@ -31,20 +32,19 @@ export default function CameraPresetSelect(props: Props) {
{label(option)}
</button>
))}
{/* Desktop View */}
{props.options.length > 5 && (
<ShowMoreDropdown {...props} options={props.options.slice(4)} />
<CameraPresetDropdown {...props} options={props.options.slice(4)} />
)}
</div>
<div className="md:hidden">
{/* Mobile View */}
<ShowMoreDropdown {...props} />
<CameraPresetDropdown {...props} />
</div>
</>
);
}

const ShowMoreDropdown = (props: Props) => {
export const CameraPresetDropdown = (props: Props) => {
const selected = props.value;

const options = props.options.filter(({ meta }) => meta.type !== "boundary");
Expand All @@ -54,9 +54,14 @@ const ShowMoreDropdown = (props: Props) => {
return (
<Listbox value={selected} onChange={props.onChange}>
<div className="relative flex-1">
<Listbox.Button className="relative w-full cursor-default pr-6 text-right text-xs text-white focus:outline-none disabled:cursor-not-allowed disabled:bg-transparent disabled:text-zinc-700 sm:text-sm md:pl-2">
<span className="block truncate">
{selected ? label(selected) : "No Preset"}
<Listbox.Button className="relative w-full cursor-default pr-6 text-left text-xs text-white focus:outline-none disabled:cursor-not-allowed disabled:bg-transparent disabled:text-zinc-700 sm:text-sm md:pl-2">
<span
className={classNames(
"block truncate",
!selected && "text-gray-500",
)}
>
{selected ? label(selected) : "Select preset"}
</span>
<span className="pointer-events-none absolute inset-y-0 right-0 mt-1 flex items-center">
<CareIcon icon="l-angle-down" className="text-lg text-zinc-500" />
Expand Down
4 changes: 2 additions & 2 deletions src/Components/CameraFeed/CameraFeedWithBedPresets.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { useState } from "react";
import { AssetBedModel, AssetData } from "../Assets/AssetTypes";
import CameraFeed from "./CameraFeed";
import AssetBedSelect from "./AssetBedSelect";
import useQuery from "../../Utils/request/useQuery";
import routes from "../../Redux/api";
import useSlug from "../../Common/hooks/useSlug";
import { CameraPresetDropdown } from "./AssetBedSelect";

interface Props {
asset: AssetData;
Expand All @@ -29,7 +29,7 @@ export default function LocationFeedTile(props: Props) {
{loading ? (
<span>loading presets...</span>
) : (
<AssetBedSelect
<CameraPresetDropdown
options={data?.results ?? []}
value={preset}
onChange={setPreset}
Expand Down
Loading