initial work with mui
This commit is contained in:
1 parent
f8233dd6ab
commit
44c4ac12dd
35 files changed
+216
-145
No files matched your search
@@ -1,24 +0,0 @@
|
||||
.input-boolean {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
max-width: fit-content;
|
||||
border: 1px solid var(--secondary-accent);
|
||||
border-radius: 5px;
|
||||
padding: 0.5em;
|
||||
background-color: var(--secondary);
|
||||
}
|
||||
|
||||
.input-boolean.disabled:hover, .input-boolean.disabled:hover * {
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.input-boolean:hover, .input-boolean:hover * {
|
||||
cursor: pointer;
|
||||
background-color: var(--secondary-opaque);
|
||||
}
|
||||
|
||||
.input-boolean * {
|
||||
user-select: none;
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
import { ComponentMeta, ComponentStory } from "@storybook/react";
|
||||
import { Page } from "components/Page";
|
||||
import { useState } from "react";
|
||||
|
||||
import InputBoolean from "./InputBoolean";
|
||||
@@ -12,12 +13,12 @@ export default {
|
||||
|
||||
const Template: ComponentStory<typeof InputBoolean> = args => {
|
||||
const [state, onChange] = useState(args.value)
|
||||
return <div className="page">
|
||||
return <Page>
|
||||
<InputBoolean {...args} value={state} onChange={v => {
|
||||
args.onChange(v)
|
||||
onChange(v)
|
||||
}} />
|
||||
</div>
|
||||
</Page>
|
||||
}
|
||||
|
||||
export const SimpleText = Template.bind({})
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import "./InputBoolean.css";
|
||||
import Checkbox from "@mui/material/Checkbox";
|
||||
import FormGroup from '@mui/material/FormGroup';
|
||||
import FormControlLabel from '@mui/material/FormControlLabel';
|
||||
|
||||
export interface Props {
|
||||
label: string;
|
||||
@@ -12,8 +14,7 @@ export default function InputBoolean({
|
||||
onChange,
|
||||
disabled = false,
|
||||
}: Props) {
|
||||
return <div className={["input-boolean", disabled ? 'disabled' : ''].join(' ')} onClick={() => onChange(!value)}>
|
||||
<input type="checkbox" checked={value} onChange={() => { }} disabled={disabled} />
|
||||
<label>{label}</label>
|
||||
</div>
|
||||
return <FormGroup>
|
||||
<FormControlLabel disabled={disabled} control={<Checkbox checked={value} onChange={() => onChange(!value)} />} label={label} />
|
||||
</FormGroup>
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
import { ComponentMeta, ComponentStory } from "@storybook/react";
|
||||
import { Page } from "components/Page";
|
||||
import { useState, useEffect } from 'react';
|
||||
|
||||
import { InputList } from "./InputList";
|
||||
@@ -18,9 +19,9 @@ const Template: ComponentStory<typeof InputList> = args => {
|
||||
setValue(args.current)
|
||||
}
|
||||
}, [args.current])
|
||||
return <div className="page">
|
||||
return <Page>
|
||||
<InputList {...args} current={value} onChange={setValue} />
|
||||
</div>
|
||||
</Page>
|
||||
}
|
||||
|
||||
export const SimpleText = Template.bind({})
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { ComponentMeta, ComponentStory } from "@storybook/react";
|
||||
import { Page } from "components/Page";
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
import InputMultiSelect from "./InputMultiSelect";
|
||||
@@ -18,12 +19,12 @@ const Template: ComponentStory<typeof InputMultiSelect> = args => {
|
||||
setValue(args.selected);
|
||||
}, [args.selected])
|
||||
|
||||
return <div className="page">
|
||||
return <Page>
|
||||
<InputMultiSelect {...args} onChange={a => {
|
||||
setValue(a);
|
||||
args.onChange(a);
|
||||
}} options={args.options} selected={value} />
|
||||
</div>
|
||||
</Page>
|
||||
}
|
||||
|
||||
export const Simple = Template.bind({})
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { ComponentMeta, ComponentStory } from "@storybook/react";
|
||||
import { Page } from "components/Page";
|
||||
import { useState } from "react";
|
||||
|
||||
import InputNumber from "./InputNumber";
|
||||
@@ -18,14 +19,14 @@ export default {
|
||||
export const NullStart: ComponentStory<typeof InputNumber> = args => {
|
||||
|
||||
const [value, setValue] = useState<number | undefined>(undefined)
|
||||
return <div className="page">
|
||||
return <Page>
|
||||
<InputNumber {...args} value={value} onChange={setValue} />
|
||||
</div>
|
||||
</Page>
|
||||
}
|
||||
export const SomeStuffAtStart: ComponentStory<typeof InputNumber> = args => {
|
||||
|
||||
const [value, setValue] = useState<number | undefined>(10)
|
||||
return <div className="page">
|
||||
return <Page>
|
||||
<InputNumber {...args} value={value} onChange={setValue} />
|
||||
</div>
|
||||
</Page>
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
import { ComponentMeta, ComponentStory } from "@storybook/react";
|
||||
import { Page } from "components/Page";
|
||||
import { useState } from "react";
|
||||
|
||||
import InputText from "./InputText";
|
||||
@@ -13,9 +14,9 @@ export default {
|
||||
const Template: ComponentStory<typeof InputText> = args => {
|
||||
|
||||
const [value, setValue] = useState('')
|
||||
return <div className="page">
|
||||
return <Page>
|
||||
<InputText {...args} value={value} onChange={setValue} />
|
||||
</div>
|
||||
</Page>
|
||||
}
|
||||
|
||||
export const SimpleText = Template.bind({})
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { PropsWithChildren, useState } from "react";
|
||||
import { useToolTip } from "tooltip/context";
|
||||
import InputWrapper from "./InputWrapper";
|
||||
import { useInputTextStyles } from "./styles";
|
||||
import TextField from '@mui/material/TextField';
|
||||
|
||||
export interface Props {
|
||||
textBoxFor?: string;
|
||||
@@ -20,40 +19,69 @@ export default function InputText({
|
||||
additionalTooltipFilters = {},
|
||||
children,
|
||||
}: PropsWithChildren<Props>) {
|
||||
const { classes } = useInputTextStyles({});
|
||||
const tooltip = useToolTip();
|
||||
const [isFocused, setIsFocused] = useState(false)
|
||||
return <InputWrapper label={label} labelSize={(value === '') && !isFocused ? 'normal' : 'small'}>
|
||||
<input
|
||||
className={classes.input}
|
||||
value={value}
|
||||
onKeyDown={e => {
|
||||
if (e.key === 'Enter') {
|
||||
onEnter();
|
||||
}
|
||||
}}
|
||||
onChange={e => {
|
||||
e.preventDefault();
|
||||
onChange(e.target.value)
|
||||
}}
|
||||
onBlur={e => {
|
||||
setIsFocused(false)
|
||||
}}
|
||||
onFocus={e => {
|
||||
setIsFocused(true)
|
||||
if (textBoxFor) {
|
||||
tooltip.setFocus(
|
||||
e.target.getBoundingClientRect(),
|
||||
{
|
||||
searchObject: textBoxFor,
|
||||
searchText: value,
|
||||
filterObjects: additionalTooltipFilters,
|
||||
},
|
||||
onChange
|
||||
)
|
||||
}
|
||||
}}
|
||||
/>
|
||||
return <TextField inputMode="text" variant="filled" focused={isFocused} label={label} value={value}
|
||||
onKeyDown={e => {
|
||||
if (e.key === 'Enter') {
|
||||
onEnter();
|
||||
}
|
||||
}}
|
||||
onChange={e => {
|
||||
e.preventDefault();
|
||||
onChange(e.target.value)
|
||||
}}
|
||||
onBlur={() => {
|
||||
setIsFocused(false)
|
||||
}}
|
||||
onFocus={e => {
|
||||
setIsFocused(true)
|
||||
if (textBoxFor) {
|
||||
tooltip.setFocus(
|
||||
e.target.getBoundingClientRect(),
|
||||
{
|
||||
searchObject: textBoxFor,
|
||||
searchText: value,
|
||||
filterObjects: additionalTooltipFilters,
|
||||
},
|
||||
onChange
|
||||
)
|
||||
}
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
</InputWrapper>
|
||||
</TextField>
|
||||
// return <InputWrapper label={label} labelSize={(value === '') && !isFocused ? 'normal' : 'small'}>
|
||||
// <input
|
||||
// className={classes.input}
|
||||
// value={value}
|
||||
// onKeyDown={e => {
|
||||
// if (e.key === 'Enter') {
|
||||
// onEnter();
|
||||
// }
|
||||
// }}
|
||||
// onChange={e => {
|
||||
// e.preventDefault();
|
||||
// onChange(e.target.value)
|
||||
// }}
|
||||
// onBlur={e => {
|
||||
// setIsFocused(false)
|
||||
// }}
|
||||
// onFocus={e => {
|
||||
// setIsFocused(true)
|
||||
// if (textBoxFor) {
|
||||
// tooltip.setFocus(
|
||||
// e.target.getBoundingClientRect(),
|
||||
// {
|
||||
// searchObject: textBoxFor,
|
||||
// searchText: value,
|
||||
// filterObjects: additionalTooltipFilters,
|
||||
// },
|
||||
// onChange
|
||||
// )
|
||||
// }
|
||||
// }}
|
||||
// />
|
||||
// {children}
|
||||
// </InputWrapper>
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
import { ComponentMeta, ComponentStory } from "@storybook/react";
|
||||
import { Page } from "components/Page";
|
||||
import { useState } from "react";
|
||||
|
||||
import InputTextArea from "./InputTextArea";
|
||||
@@ -13,9 +14,9 @@ export default {
|
||||
const Template: ComponentStory<typeof InputTextArea> = args => {
|
||||
|
||||
const [value, setValue] = useState('')
|
||||
return <div className="page">
|
||||
return <Page>
|
||||
<InputTextArea {...args} value={value} onChange={setValue} />
|
||||
</div>
|
||||
</Page>
|
||||
}
|
||||
|
||||
export const SimpleText = Template.bind({})
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { ComponentMeta, ComponentStory } from "@storybook/react";
|
||||
import { Page } from "components/Page";
|
||||
import { useState } from "react";
|
||||
|
||||
import InputTextBubble, { InputEntity } from "./InputTextBubble";
|
||||
@@ -18,26 +19,26 @@ export default {
|
||||
export const ArrayText: ComponentStory<typeof InputTextBubble> = args => {
|
||||
|
||||
const [value, setValue] = useState<string | string[]>(['wow', 'lots of bubbles', 'itchen', 'bathroom'])
|
||||
return <div className="page">
|
||||
return <Page>
|
||||
<div style={{ maxWidth: '200px', overflow: 'hidden' }}>
|
||||
<InputTextBubble {...args} value={value} onChange={setValue} />
|
||||
</div>
|
||||
</div>
|
||||
</Page>
|
||||
}
|
||||
|
||||
export const JustText: ComponentStory<typeof InputTextBubble> = args => {
|
||||
|
||||
const [value, setValue] = useState<string | string[]>('hello')
|
||||
return <div className="page">
|
||||
return <Page>
|
||||
<InputTextBubble {...args} value={value} onChange={setValue} />
|
||||
</div>
|
||||
</Page>
|
||||
}
|
||||
|
||||
|
||||
export const EntityId: ComponentStory<typeof InputTextBubble> = args => {
|
||||
|
||||
const [value, setValue] = useState<string | string[]>(['sensor.bathroom'])
|
||||
return <div className="page">
|
||||
return <Page>
|
||||
<InputEntity value={value} onChange={setValue} />
|
||||
</div>
|
||||
</Page>
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
import { ComponentMeta, ComponentStory } from "@storybook/react";
|
||||
import { Page } from "components/Page";
|
||||
import { useState } from "react";
|
||||
import { AutomationTime } from "types/automations/common";
|
||||
|
||||
@@ -14,9 +15,9 @@ export default {
|
||||
const Template: ComponentStory<typeof InputTime> = args => {
|
||||
|
||||
const [value, setValue] = useState<AutomationTime | undefined>(undefined);
|
||||
return <div className="page">
|
||||
return <Page>
|
||||
<InputTime {...args} value={value} onChange={setValue} />
|
||||
</div>
|
||||
</Page>
|
||||
}
|
||||
|
||||
export const SimpleText = Template.bind({})
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { ComponentMeta, ComponentStory } from "@storybook/react";
|
||||
import { Page } from "components/Page";
|
||||
import { useState } from "react";
|
||||
|
||||
import InputYaml from "./InputYaml";
|
||||
@@ -15,9 +16,9 @@ const Template: ComponentStory<typeof InputYaml> = args => {
|
||||
const [value, setValue] = useState({
|
||||
"test": "data"
|
||||
})
|
||||
return <div className="page">
|
||||
return <Page>
|
||||
<InputYaml {...args} value={value} onChange={setValue} />
|
||||
</div>
|
||||
</Page>
|
||||
}
|
||||
|
||||
export const SimpleText = Template.bind({})
|
||||
|
||||
Reference in new issue
Block a user