settings -> dark/light mode

This commit is contained in:
ari committed 2022-08-30 21:50:43 -04:00
1 parent 416d88b965
commit 03a735b281
47 files changed
+867 -736

No files matched your search

@@ -1,36 +1,39 @@
import { ComponentMeta, ComponentStory } from "@storybook/react";
import { Page } from "components/Page";
import { useState } from "react";
import { InputDevice } from "./InputDevice";
export default {
title: 'Inputs/InputDevice',
component: InputDevice,
parameters: { actions: { argTypesRegex: '^on.*' } },
argTypes: {}
} as ComponentMeta<typeof InputDevice>;
import { makeStory } from "devUtils";
const { make, componentMeta } = makeStory({
Component: InputDevice,
meta: {
title: "Inputs/InputDevice",
},
BaseTemplate: (args) => {
const [value, setValue] = useState(args.value);
return (
<div
style={{
maxWidth: 200,
}}
>
<InputDevice
{...args}
value={value as any}
onChange={(v: any) => {
setValue(v);
args.onChange(v as any);
}}
/>
</div>
);
},
});
export default componentMeta;
export const Example = make({});
const Template: ComponentStory<typeof InputDevice> = args => {
const [value, setValue] = useState(args.value)
return <Page>
<div style={{
maxWidth: 200
}}>
<InputDevice {...args} value={value as any} onChange={(v: any) => {
setValue(v)
args.onChange(v as any)
}} />
</div>
</Page>
}
export const Single = Template.bind({})
Single.args = {
...Single.args,
export const Single = make({
multiple: false,
value: 'sensor.humidity_bathroom'
} as any
value: "sensor.humidity_bathroom",
});
@@ -1,84 +1,77 @@
import { ComponentMeta, ComponentStory } from "@storybook/react";
import { Page } from "components/Page";
import { useState } from "react";
import { InputEntity } from "./InputEntities";
export default {
title: 'Inputs/InputEntity',
component: InputEntity,
parameters: { actions: { argTypesRegex: '^on.*' } },
argTypes: {}
} as ComponentMeta<typeof InputEntity>;
import { makeStory } from "devUtils";
const { make, componentMeta } = makeStory({
Component: InputEntity,
meta: {
title: "Inputs/InputEntity",
},
BaseTemplate: (args) => {
const [value, setValue] = useState(args.value);
return (
<div
style={{
maxWidth: 200,
}}
>
<InputEntity
{...args}
value={value as any}
onChange={(v: any) => {
setValue(v);
args.onChange(v as any);
}}
/>
</div>
);
},
});
export default componentMeta;
export const Example = make({});
const Template: ComponentStory<typeof InputEntity> = args => {
const [value, setValue] = useState(args.value)
return <Page>
<div style={{
maxWidth: 200
}}>
<InputEntity {...args} value={value as any} onChange={(v: any) => {
setValue(v)
args.onChange(v as any)
}} />
</div>
</Page>
}
export const Single = Template.bind({})
Single.args = {
...Single.args,
export const Single = make({
multiple: false,
value: 'sensor.bathroom'
} as any
value: "sensor.bathroom",
});
export const Many = Template.bind({})
Many.args = {
...Many.args,
export const Many = make({
multiple: true,
value: ['sensor.bathroom', 'person.ari']
} as any
value: ["sensor.bathroom", "person.ari"],
});
export const ManyEmpty = Template.bind({})
ManyEmpty.args = {
...ManyEmpty.args,
export const ManyEmpty = make({
multiple: true,
value: []
} as any
value: [],
});
export const ManyButGotSingle = Template.bind({})
ManyButGotSingle.args = {
...ManyButGotSingle.args,
export const ManyButGotSingle = make({
multiple: true,
value: 'sensor.bathroom'
} as any
value: "sensor.bathroom",
});
export const InvalidDomain = Template.bind({})
InvalidDomain.args = {
...InvalidDomain.args,
export const InvalidDomain = make({
multiple: true,
value: 'sensor.bathroom',
restrictToDomain: ['zone'],
} as any
value: "sensor.bathroom",
restrictToDomain: ["zone"],
});
export const InvalidManyDomain = Template.bind({})
InvalidManyDomain.args = {
...InvalidManyDomain.args,
export const InvalidManyDomain = make({
multiple: true,
value: 'sensor.bathroom',
restrictToDomain: ['zone', 'switch'],
} as any
value: "sensor.bathroom",
restrictToDomain: ["zone", "switch"],
});
export const InvalidLots = Template.bind({})
InvalidLots.args = {
...InvalidLots.args,
export const InvalidLots = make({
multiple: true,
value: ['person.ari', 'sensor.bathroom', 'binary_sensor.ping_tv', 'device_tracker.phone'],
restrictToDomain: ['zone', 'switch'],
} as any
value: [
"person.ari",
"sensor.bathroom",
"binary_sensor.ping_tv",
"device_tracker.phone",
],
restrictToDomain: ["zone", "switch"],
});
@@ -1,36 +1,39 @@
import { ComponentMeta, ComponentStory } from "@storybook/react";
import { Page } from "components/Page";
import { useState } from "react";
import { InputService } from "./InputService";
export default {
title: 'Inputs/InputService',
component: InputService,
parameters: { actions: { argTypesRegex: '^on.*' } },
argTypes: {}
} as ComponentMeta<typeof InputService>;
import { makeStory } from "devUtils";
const { make, componentMeta } = makeStory({
Component: InputService,
meta: {
title: "Inputs/InputService",
},
BaseTemplate: (args) => {
const [value, setValue] = useState(args.value);
return (
<div
style={{
maxWidth: 200,
}}
>
<InputService
{...args}
value={value as any}
onChange={(v: any) => {
setValue(v);
args.onChange(v as any);
}}
/>
</div>
);
},
});
export default componentMeta;
export const Example = make({});
const Template: ComponentStory<typeof InputService> = args => {
const [value, setValue] = useState(args.value)
return <Page>
<div style={{
maxWidth: 200
}}>
<InputService {...args} value={value as any} onChange={(v: any) => {
setValue(v)
args.onChange(v as any)
}} />
</div>
</Page>
}
export const Single = Template.bind({})
Single.args = {
...Single.args,
export const Single = make({
multiple: false,
value: ''
} as any
value: "",
});
@@ -1,19 +1,17 @@
import { ComponentMeta, ComponentStory } from "@storybook/react";
import { Page } from "components/Page";
import { useState } from "react";
import { InputTimeEntity } from "./InputTimeEntity";
export default {
title: "Inputs/InputTimeEntity",
component: InputTimeEntity,
parameters: { actions: { argTypesRegex: "^on.*" } },
} as ComponentMeta<typeof InputTimeEntity>;
import { makeStory } from "devUtils";
const Template: ComponentStory<typeof InputTimeEntity> = (args) => {
const [value, setValue] = useState("");
return (
<Page>
const { make, componentMeta } = makeStory({
Component: InputTimeEntity,
meta: {
title: "Inputs/InputTimeEntity",
},
BaseTemplate: (args) => {
const [value, setValue] = useState("");
return (
<div
style={{
padding: "1em",
@@ -28,8 +26,8 @@ const Template: ComponentStory<typeof InputTimeEntity> = (args) => {
}}
/>
</div>
</Page>
);
};
);
},
});
export const SimpleText = Template.bind({});
export const SimpleText = make({});
@@ -1,18 +1,14 @@
import { ComponentMeta, ComponentStory } from "@storybook/react";
import { Page } from "components/Page";
import { SearchItem } from "./extras";
export default {
title: "Inputs/Extras/SearchItem",
component: SearchItem,
parameters: { actions: { argTypesRegex: "^on.*" } },
argTypes: {},
} as ComponentMeta<typeof SearchItem>;
import { makeStory } from "devUtils";
const Template: ComponentStory<typeof SearchItem> = (args) => {
return (
<Page>
const { make, componentMeta } = makeStory({
Component: SearchItem,
meta: {
title: "Inputs/Extras/SearchItem",
},
BaseTemplate: (args) => {
return (
<div
style={{
width: "15em",
@@ -22,15 +18,16 @@ const Template: ComponentStory<typeof SearchItem> = (args) => {
>
<SearchItem {...args} />
</div>
</Page>
);
};
);
},
});
export const Simple = Template.bind({});
Simple.args = {
export default componentMeta;
export const Simple = make({
id: "sensor.humidity_main_bedroom",
label: "Main Bedroom Humidity",
searchTerm: "bedroom",
listProps: {},
onlyShowLabel: false,
};
});
@@ -4,24 +4,30 @@ import { useState } from "react";
import InputBoolean from "./InputBoolean";
export default {
title: 'Inputs/InputBoolean',
component: InputBoolean,
parameters: { actions: { argTypesRegex: '^on.*' } },
} as ComponentMeta<typeof InputBoolean>;
import { makeStory } from "devUtils";
const { make, componentMeta } = makeStory({
Component: InputBoolean,
meta: {
title: "Inputs/InputBoolean",
args: {
label: "Template",
},
},
BaseTemplate: (args) => {
const [state, onChange] = useState(args.value);
return (
<InputBoolean
{...args}
value={state}
onChange={(v) => {
args.onChange(v);
onChange(v);
}}
/>
);
},
});
const Template: ComponentStory<typeof InputBoolean> = args => {
const [state, onChange] = useState(args.value)
return <Page>
<InputBoolean {...args} value={state} onChange={v => {
args.onChange(v)
onChange(v)
}} />
</Page>
}
export const SimpleText = Template.bind({})
SimpleText.args = {
label: "Template",
}
export default componentMeta;
export const Example = make({});
@@ -1,32 +1,31 @@
import { ComponentMeta, ComponentStory } from "@storybook/react";
import { Page } from "components/Page";
import { useState } from "react";
import InputNumber from "./InputNumber";
export default {
title: 'Inputs/InputNumber',
component: InputNumber,
parameters: { actions: { argTypesRegex: '^on.*' } },
argTypes: {
label: {
defaultValue: 'Sample Title'
}
}
} as ComponentMeta<typeof InputNumber>;
import { makeStory } from "devUtils";
const { make, componentMeta } = makeStory({
Component: InputNumber,
meta: {
title: "Inputs/InputNumber",
argTypes: {
label: {
defaultValue: "Sample Title",
},
},
},
BaseTemplate: (args) => {
const [value, setValue] = useState<number | undefined>(args.value);
return <InputNumber {...args} value={value} onChange={setValue} />;
},
});
export const NullStart: ComponentStory<typeof InputNumber> = args => {
export default componentMeta;
const [value, setValue] = useState<number | undefined>(undefined)
return <Page>
<InputNumber {...args} value={value} onChange={setValue} />
</Page>
}
export const SomeStuffAtStart: ComponentStory<typeof InputNumber> = args => {
export const NullStart = make({
value: undefined,
});
const [value, setValue] = useState<number | undefined>(10)
return <Page>
<InputNumber {...args} value={value} onChange={setValue} />
</Page>
}
export const SomeStuffAtStart = make({
value: 10,
});
@@ -4,22 +4,21 @@ import { useState } from "react";
import InputText from "./InputText";
export default {
title: 'Inputs/InputText',
component: InputText,
parameters: { actions: { argTypesRegex: '^on.*' } },
} as ComponentMeta<typeof InputText>;
import { makeStory } from "devUtils";
const { make, componentMeta } = makeStory({
Component: InputText,
meta: {
title: "Inputs/InputText",
},
BaseTemplate: (args) => {
const [value, setValue] = useState("");
return <InputText {...args} value={value} onChange={setValue} />;
},
});
const Template: ComponentStory<typeof InputText> = args => {
export default componentMeta;
const [value, setValue] = useState('')
return <Page>
<InputText {...args} value={value} onChange={setValue} />
</Page>
}
export const SimpleText = Template.bind({})
SimpleText.args = {
export const SimpleText = make({
label: "Entity ID",
}
});
@@ -1,20 +1,15 @@
import { ComponentMeta, ComponentStory } from "@storybook/react";
import { Page } from "components/Page";
import { useState } from "react";
import { AutomationTime } from "types/automations/common";
import { InputTime } from "./InputTime";
export default {
title: "Inputs/InputTime",
component: InputTime,
parameters: { actions: { argTypesRegex: "^on.*" } },
} as ComponentMeta<typeof InputTime>;
import { makeStory } from "devUtils";
const Template: ComponentStory<typeof InputTime> = (args) => {
const [value, setValue] = useState<AutomationTime | undefined>(undefined);
return (
<Page>
const { make, componentMeta } = makeStory({
Component: InputTime,
BaseTemplate: (args) => {
const [value, setValue] = useState<AutomationTime | undefined>(undefined);
return (
<div
style={{
padding: "1em",
@@ -29,12 +24,17 @@ const Template: ComponentStory<typeof InputTime> = (args) => {
}}
/>
</div>
</Page>
);
};
);
},
meta: {
title: "Inputs/InputTime",
},
});
export const SimpleText = Template.bind({});
SimpleText.args = {
export default componentMeta;
export const Example = make({});
export const SimpleText = make({
label: "Time Stamp",
value: "10",
};
});
@@ -4,24 +4,24 @@ import { useState } from "react";
import InputYaml from "./InputYaml";
export default {
title: 'Inputs/InputYaml',
component: InputYaml,
parameters: { actions: { argTypesRegex: '^on.*' } },
} as ComponentMeta<typeof InputYaml>;
import { makeStory } from "devUtils";
const { make, componentMeta } = makeStory({
Component: InputYaml,
BaseTemplate: (args) => {
const [value, setValue] = useState({
test: "data",
});
return <InputYaml {...args} value={value} onChange={setValue} />;
},
meta: {
title: "Inputs/InputYaml",
},
});
const Template: ComponentStory<typeof InputYaml> = args => {
export default componentMeta;
export const Example = make({});
const [value, setValue] = useState({
"test": "data"
})
return <Page>
<InputYaml {...args} value={value} onChange={setValue} />
</Page>
}
export const SimpleText = Template.bind({})
SimpleText.args = {
export const SimpleText = make({
label: "Template",
}
});
@@ -1,29 +1,22 @@
import { ComponentMeta, ComponentStory } from "@storybook/react";
import { Page } from "components/Page";
import InputAutoText from "./InputAutoText";
export default {
title: "Inputs/InputAutoText",
component: InputAutoText,
parameters: { actions: { argTypesRegex: "^on.*" } },
args: {
label: "Something",
value: "",
options: ["test", "usa", "canada"],
import { makeStory } from "devUtils";
const { make, componentMeta } = makeStory({
Component: InputAutoText,
meta: {
title: "Inputs/InputAutoText",
args: {
label: "Something",
value: "",
options: ["test", "usa", "canada"],
},
},
} as ComponentMeta<typeof InputAutoText>;
});
const Template: ComponentStory<typeof InputAutoText> = (args) => {
return (
<Page>
<InputAutoText {...args} />
</Page>
);
};
export default componentMeta;
export const Example = make({});
export const Basic = Template.bind({});
export const WithError = Template.bind({});
WithError.args = {
...WithError.args,
export const WithError = make({
error: "Oh no!",
};
});
@@ -1,47 +1,35 @@
import { ComponentMeta, ComponentStory } from "@storybook/react";
import { Page } from "components/Page";
import { useState, useEffect } from 'react';
import { useState, useEffect } from "react";
import { InputList } from "./InputList";
export default {
title: 'Inputs/InputList',
component: InputList,
parameters: { actions: { argTypesRegex: '^on.*' } },
} as ComponentMeta<typeof InputList>;
import { makeStory } from "devUtils";
const { make, componentMeta } = makeStory({
Component: InputList,
BaseTemplate: (args) => {
const [value, setValue] = useState(args.current);
useEffect(() => {
if (value !== args.current) {
setValue(args.current);
}
}, [args.current]);
return <InputList {...args} current={value} onChange={setValue} />;
},
meta: {
title: "Inputs/InputList",
},
});
const Template: ComponentStory<typeof InputList> = args => {
export default componentMeta;
const [value, setValue] = useState(args.current);
useEffect(() => {
if (value !== args.current) {
setValue(args.current)
}
}, [args.current])
return <Page>
<InputList {...args} current={value} onChange={setValue} />
</Page>
}
export const SimpleText = Template.bind({})
SimpleText.args = {
export const SimpleText = make({
label: "Entity ID",
options: [
'Bob',
'Martin',
"Toots"
]
}
options: ["Bob", "Martin", "Toots"],
});
export const InvalidSelection = Template.bind({})
InvalidSelection.args = {
export const InvalidSelection = make({
current: "Derek",
label: "Entity ID",
options: [
'Bob',
'Martin',
"Toots"
]
}
options: ["Bob", "Martin", "Toots"],
});
@@ -1,24 +1,19 @@
import { ComponentMeta, ComponentStory } from "@storybook/react";
import { Page } from "components/Page";
import { useEffect, useState } from "react";
import InputMultiSelect from "./InputMultiSelect";
export default {
title: "Inputs/InputMultiSelect",
component: InputMultiSelect,
parameters: { actions: { argTypesRegex: "^on.*" } },
} as ComponentMeta<typeof InputMultiSelect>;
import { makeStory } from "devUtils";
const Template: ComponentStory<typeof InputMultiSelect> = (args) => {
const [value, setValue] = useState<number[]>(args.selected);
const { make, componentMeta } = makeStory({
Component: InputMultiSelect,
BaseTemplate: (args) => {
const [value, setValue] = useState<number[]>(args.selected);
useEffect(() => {
setValue(args.selected);
}, [args.selected]);
useEffect(() => {
setValue(args.selected);
}, [args.selected]);
return (
<Page>
return (
<InputMultiSelect
{...args}
onChange={(a) => {
@@ -28,14 +23,18 @@ const Template: ComponentStory<typeof InputMultiSelect> = (args) => {
options={args.options}
selected={value}
/>
</Page>
);
};
);
},
meta: {
title: "Inputs/InputMultiSelect",
},
});
export const Simple = Template.bind({});
Simple.args = {
export default componentMeta;
export const Simple = make({
label: "Room Tags",
options: ["Bears", "Cats", "Kitchen", "Bathroom"],
selected: [1],
max: 2,
};
});
@@ -1,58 +1,49 @@
import { ComponentMeta, ComponentStory } from "@storybook/react";
import { Page } from "components/Page";
import { useState } from "react";
import InputTextBubble from "./InputTextBubble";
export default {
title: 'Inputs/InputTextBubble',
component: InputTextBubble,
parameters: { actions: { argTypesRegex: '^on.*' } },
argTypes: {
label: {
defaultValue: 'Sample Title'
}
}
} as ComponentMeta<typeof InputTextBubble>;
import { makeStory } from "devUtils";
const { make, componentMeta } = makeStory({
Component: InputTextBubble,
BaseTemplate: (args) => {
const [value, setValue] = useState<string | string[]>(args.value ?? "");
return (
<div style={{ maxWidth: "200px", overflow: "hidden" }}>
<InputTextBubble {...args} value={value} onChange={setValue} />
</div>
);
},
meta: {
title: "Inputs/InputTextBubble",
argTypes: {
label: {
defaultValue: "Sample Title",
},
},
},
});
export const ArrayText: ComponentStory<typeof InputTextBubble> = args => {
export default componentMeta;
const [value, setValue] = useState<string | string[]>(['wow', 'lots of bubbles', 'itchen', 'bathroom'])
return <Page>
<div style={{ maxWidth: '200px', overflow: 'hidden' }}>
<InputTextBubble {...args} value={value} onChange={setValue} />
</div>
</Page>
}
export const ArrayText = make({
value: ["wow", "lots of bubbles", "itchen", "bathroom"],
});
export const JustText = make({
value: "hello",
});
export const JustText: ComponentStory<typeof InputTextBubble> = args => {
const [value, setValue] = useState<string | string[]>('hello')
return <Page>
<InputTextBubble {...args} value={value} onChange={setValue} />
</Page>
}
export const ManyOptions: ComponentStory<typeof InputTextBubble> = args => {
const [value, setValue] = useState<string | string[]>('hello')
return <Page>
<InputTextBubble {...args} value={value} onChange={setValue} />
</Page>
}
ManyOptions.args = {
...ManyOptions.args,
export const ManyOptions = make({
value: "hello",
options: [
'sensor.humidity_bathroom',
'sensor.humidity_bedroom',
'sensor.humidity_laundry',
'sensor.temp_bathroom',
'sensor.temp_bedroom',
'switch.living_room',
'switch.bathroom',
'light.bedroom_main',
'light.bedroom_second',
]
}
"sensor.humidity_bathroom",
"sensor.humidity_bedroom",
"sensor.humidity_laundry",
"sensor.temp_bathroom",
"sensor.temp_bedroom",
"switch.living_room",
"switch.bathroom",
"light.bedroom_main",
"light.bedroom_second",
],
});
@@ -4,17 +4,11 @@ import InputText from "./Base/InputText";
import { InputTextView } from "./InputTextView";
export default {
title: "Inputs/InputTextView",
component: InputTextView,
parameters: { actions: { argTypesRegex: "^on.*" } },
args: {
value: "example",
},
} as ComponentMeta<typeof InputTextView>;
import { makeStory } from "devUtils";
export const Basic: ComponentStory<typeof InputTextView> = (args) => (
<Page>
const { make, componentMeta } = makeStory({
Component: InputTextView,
BaseTemplate: (args) => (
<div
style={{
display: "flex",
@@ -26,5 +20,15 @@ export const Basic: ComponentStory<typeof InputTextView> = (args) => (
<InputTextView {...args} />
<InputText {...args} />
</div>
</Page>
);
),
meta: {
title: "Inputs/InputTextView",
args: {
value: "example",
},
},
});
export default componentMeta;
export const Basic = make({});