fixed up service editor

This commit is contained in:
ari committed 2022-06-17 14:23:15 -04:00
1 parent 029df7932e
commit 5bef962977
8 files changed
+107 -44

No files matched your search

@@ -38,4 +38,9 @@
max-width: 7em;
text-overflow: ellipsis;
overflow: hidden;
}
.input-autocomplete--popper {
min-width: fit-content;
/* max-width: 90vw; */
}
@@ -2,10 +2,11 @@ import "./InputAutoComplete.css";
import Autocomplete from "@mui/material/Autocomplete";
import TextField from "@mui/material/TextField";
import Chip from "@mui/material/Chip";
import { Badge } from "@mui/material";
import { Badge, Popper } from "@mui/material";
import { SearchItem } from "./extras";
import { ReactNode } from "react";
import { prettyName } from "utils/formatting";
import { ModalStyleProps } from "../Modal/index";
export type BaseOption<T = {}> = {
id: string;
@@ -142,6 +143,16 @@ export function InputAutoComplete<T extends Option>(
options={options}
onChange={onChange}
getOptionLabel={getLabel as any}
PopperComponent={(props) => {
return (
<Popper
{...props}
className={[props.className, "input-autocomplete--popper"].join(
" "
)}
/>
);
}}
filterOptions={(opts, s) => {
const searchTerm = s.inputValue;
if (!searchTerm) {
@@ -4,25 +4,33 @@ import { Page } from "components/Page";
import { SearchItem } from "./extras";
export default {
title: 'Inputs/Extras/SearchItem',
title: "Inputs/Extras/SearchItem",
component: SearchItem,
parameters: { actions: { argTypesRegex: '^on.*' } },
argTypes: {}
parameters: { actions: { argTypesRegex: "^on.*" } },
argTypes: {},
} as ComponentMeta<typeof SearchItem>;
const Template: ComponentStory<typeof SearchItem> = (args) => {
return (
<Page>
<div
style={{
width: "15em",
height: "3em",
border: "1px solid var(--primary-accent)",
}}
>
<SearchItem {...args} />
</div>
</Page>
);
};
const Template: ComponentStory<typeof SearchItem> = args => {
return <Page>
<SearchItem {...args} />
</Page>
}
export const Simple = Template.bind({})
export const Simple = Template.bind({});
Simple.args = {
id: "sensor.humidity_main_bedroom",
label: 'Main Bedroom Humidity',
label: "Main Bedroom Humidity",
searchTerm: "bedroom",
listProps: {},
} as any
onlyShowLabel: false,
};
+37 -4
View File
@@ -1,9 +1,42 @@
.input-extras--search-item--list {
display: flex;
flex-direction: row;
gap: 0.15em;
flex-direction: column;
gap: 0;
justify-content: center;
align-items: flex-start !important;
margin: 0;
padding: 0;
min-height: 2em;
max-height: 100%;
height: 100%;
width: 100%;
max-width: 20em;
text-overflow: ellipsis;
overflow: hidden;
}
.input-extras--search-item--list>small::before {
.input-extras--search-item--list small {
/* max-height: 2em; */
max-width: 100%;
width: fit-content;
overflow: hidden;
text-overflow: ellipsis;
}
.input-extras--search-item--list b {
max-height: 1.5em;
width: fit-content;
max-width: 100%;
padding-right: 0.25em;
overflow: hidden;
text-overflow: ellipsis;
word-break: break-all;
}
/* .input-extras--search-item--list>small::before {
content: "/ ";
}
} */
+15 -20
View File
@@ -36,34 +36,29 @@ export const SearchItem: FC<{
searchTerm: string;
onlyShowLabel?: boolean;
}> = ({ listProps, label, id, searchTerm, onlyShowLabel = false }) => {
const labelElm = (
<b className="input-extras--search-item--list--label">
<HighlightElm text={label} searchTerm={searchTerm} />
</b>
);
const idElm = (
<small className="input-extras--search-item--list--id">
<HighlightElm text={id} searchTerm={searchTerm} />
</small>
);
let inner = (
<>
<b>
<HighlightElm text={prettyName(label)} searchTerm={searchTerm} />
</b>{" "}
<small>
<HighlightElm text={id} searchTerm={searchTerm} />
</small>
{labelElm}
{idElm}
</>
);
if (onlyShowLabel) {
if (label) {
inner = (
<>
<b>
<HighlightElm text={prettyName(label)} searchTerm={searchTerm} />
</b>{" "}
</>
);
inner = labelElm;
} else {
inner = (
<>
<small>
<HighlightElm text={id} searchTerm={searchTerm} />
</small>
</>
);
inner = idElm;
}
}
@@ -3,8 +3,19 @@
flex-direction: row;
gap: 1em;
padding-bottom: 0.5em;
overflow: hidden;
flex-wrap: wrap;
align-items: center;
justify-content: center;
}
.service-editor--targets>div {
flex: 1;
min-width: 8em;
}
@media (max-width: 450px) {
.service-editor--targets>div {
max-width: 38vw;
}
}
@@ -34,7 +34,7 @@ export const ServiceEditorTarget: FC<ServiceEditorTargetProps> = (props) => {
return (
<div className="service-editor--targets">
<InputEntity
label="Target Entities"
label="Entity"
value={value.entity_id}
onChange={(entity_id) =>
props.onChange({
@@ -46,7 +46,7 @@ export const ServiceEditorTarget: FC<ServiceEditorTargetProps> = (props) => {
multiple
/>
<InputDevice
label="Target Devices"
label="Device"
value={value.device_id}
onChange={(device_id) =>
props.onChange({
@@ -57,7 +57,7 @@ export const ServiceEditorTarget: FC<ServiceEditorTargetProps> = (props) => {
multiple
/>
<InputArea
label="Target Areas"
label="Area"
value={value.area_id}
onChange={(area_id) =>
props.onChange({
@@ -1,8 +1,8 @@
.service-editor {
display: flex;
flex-direction: column;
padding: 0.5em 1em;
margin: 0.5em 1em;
padding: 0.5em 0.25em;
margin: 0.5em 0.25em;
border-color: var(--primary-accent);
border-width: 1px;
border-style: solid;