From 0764feb4328822a079453b2604e17f0e23f4fb7c Mon Sep 17 00:00:00 2001 From: Ari Sosnovsky Date: Wed, 1 Dec 2021 16:38:30 -0500 Subject: [PATCH] moved back the components --- webapp/src/components/Inputs/Button.tsx | 26 +++ webapp/src/components/Inputs/InputBoolean.tsx | 26 +++ .../components/Inputs/InputList.stories.tsx | 29 +++ webapp/src/components/Inputs/InputList.tsx | 30 +++ .../components/Inputs/InputNumber.stories.tsx | 31 +++ webapp/src/components/Inputs/InputNumber.tsx | 29 +++ .../components/Inputs/InputText.stories.tsx | 24 +++ webapp/src/components/Inputs/InputText.tsx | 59 ++++++ .../Inputs/InputTextArea.stories.tsx | 24 +++ .../src/components/Inputs/InputTextArea.tsx | 52 +++++ .../Inputs/InputTextBubble.stories.tsx | 43 ++++ .../src/components/Inputs/InputTextBubble.tsx | 68 +++++++ webapp/src/components/Inputs/InputWrapper.tsx | 16 ++ .../components/Inputs/InputYaml.stories.tsx | 26 +++ webapp/src/components/Inputs/InputYaml.tsx | 39 ++++ webapp/src/components/Inputs/styles.ts | 183 ++++++++++++++++++ webapp/src/tooltip/context.ts | 41 ++++ webapp/src/tooltip/index.tsx | 40 ++++ 18 files changed, 786 insertions(+) create mode 100644 webapp/src/components/Inputs/Button.tsx create mode 100644 webapp/src/components/Inputs/InputBoolean.tsx create mode 100644 webapp/src/components/Inputs/InputList.stories.tsx create mode 100644 webapp/src/components/Inputs/InputList.tsx create mode 100644 webapp/src/components/Inputs/InputNumber.stories.tsx create mode 100644 webapp/src/components/Inputs/InputNumber.tsx create mode 100644 webapp/src/components/Inputs/InputText.stories.tsx create mode 100644 webapp/src/components/Inputs/InputText.tsx create mode 100644 webapp/src/components/Inputs/InputTextArea.stories.tsx create mode 100644 webapp/src/components/Inputs/InputTextArea.tsx create mode 100644 webapp/src/components/Inputs/InputTextBubble.stories.tsx create mode 100644 webapp/src/components/Inputs/InputTextBubble.tsx create mode 100644 webapp/src/components/Inputs/InputWrapper.tsx create mode 100644 webapp/src/components/Inputs/InputYaml.stories.tsx create mode 100644 webapp/src/components/Inputs/InputYaml.tsx create mode 100644 webapp/src/components/Inputs/styles.ts create mode 100644 webapp/src/tooltip/context.ts create mode 100644 webapp/src/tooltip/index.tsx diff --git a/webapp/src/components/Inputs/Button.tsx b/webapp/src/components/Inputs/Button.tsx new file mode 100644 index 0000000..d23e157 --- /dev/null +++ b/webapp/src/components/Inputs/Button.tsx @@ -0,0 +1,26 @@ +import { ButtonHTMLAttributes, FC } from "react"; +import { createAppUseStyles } from "styles/theme"; +import { useButtonStyles } from "./styles"; + +// const useButtonStyles = createAppUseStyles(theme => ({ +// button: { +// backgroundColor: theme.secondary, +// color: theme.primaryAccent, +// borderColor: theme.primaryAccent, +// borderStyle: 'solid', +// borderWidth: 1, +// padding: '2.5%', +// marginLeft: '5%', +// marginRight: '5%', +// borderRadius: '5px', +// cursor: 'pointer', +// '&:hover': { +// backgroundColor: theme.primary, +// borderColor: theme.secondaryAccent, +// } +// } +// })) +export const Button: FC> = props => { + const { classes } = useButtonStyles({}); + return } + +} \ No newline at end of file diff --git a/webapp/src/components/Inputs/InputText.stories.tsx b/webapp/src/components/Inputs/InputText.stories.tsx new file mode 100644 index 0000000..1888afd --- /dev/null +++ b/webapp/src/components/Inputs/InputText.stories.tsx @@ -0,0 +1,24 @@ +import { ComponentMeta, ComponentStory } from "@storybook/react"; +import { useState } from "react"; +import { usePageTheme } from "styles/page"; +import InputText from "./InputText"; + +export default { + title: 'Inputs/InputText', + component: InputText, + parameters: { actions: { argTypesRegex: '^on.*' } }, +} as ComponentMeta; + + +const Template: ComponentStory = args => { + const { classes } = usePageTheme({}); + const [value, setValue] = useState('') + return
+ +
+} + +export const SimpleText = Template.bind({}) +SimpleText.args = { + label: "Entity ID", +} diff --git a/webapp/src/components/Inputs/InputText.tsx b/webapp/src/components/Inputs/InputText.tsx new file mode 100644 index 0000000..71fd947 --- /dev/null +++ b/webapp/src/components/Inputs/InputText.tsx @@ -0,0 +1,59 @@ +import { PropsWithChildren, useState } from "react"; +import { useToolTip } from "tooltip/context"; +import InputWrapper from "./InputWrapper"; +import { useInputTextStyles } from "./styles"; + +export interface Props { + textBoxFor?: string; + label: string; + value: string; + onChange: (v: string) => void; + onEnter?: () => void; + additionalTooltipFilters?: Record; +} +export default function InputText({ + label, + textBoxFor, + value = "", + onChange, + onEnter = () => { }, + additionalTooltipFilters = {}, + children, +}: PropsWithChildren) { + const { classes } = useInputTextStyles({}); + const tooltip = useToolTip(); + const [isFocused, setIsFocused] = useState(false) + return + { + 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} + +} diff --git a/webapp/src/components/Inputs/InputTextArea.stories.tsx b/webapp/src/components/Inputs/InputTextArea.stories.tsx new file mode 100644 index 0000000..0b75a26 --- /dev/null +++ b/webapp/src/components/Inputs/InputTextArea.stories.tsx @@ -0,0 +1,24 @@ +import { ComponentMeta, ComponentStory } from "@storybook/react"; +import { useState } from "react"; +import { usePageTheme } from "styles/page"; +import InputTextArea from "./InputTextArea"; + +export default { + title: 'Inputs/InputTextArea', + component: InputTextArea, + parameters: { actions: { argTypesRegex: '^on.*' } }, +} as ComponentMeta; + + +const Template: ComponentStory = args => { + const { classes } = usePageTheme({}); + const [value, setValue] = useState('') + return
+ +
+} + +export const SimpleText = Template.bind({}) +SimpleText.args = { + label: "Entity ID", +} diff --git a/webapp/src/components/Inputs/InputTextArea.tsx b/webapp/src/components/Inputs/InputTextArea.tsx new file mode 100644 index 0000000..917ca7a --- /dev/null +++ b/webapp/src/components/Inputs/InputTextArea.tsx @@ -0,0 +1,52 @@ +import { useState } from "react"; +import { useToolTip } from "tooltip/context"; +import InputWrapper from "./InputWrapper"; +import { useInputTextAreaStyles } from "./styles"; + +export interface Props { + textBoxFor?: string; + label: string; + value: string; + onChange: (v: string) => void; + additionalTooltipFilters?: Record; + resizable?: boolean; +} +export default function InputTextArea({ + label, + textBoxFor, + value = "", + onChange, + additionalTooltipFilters = {}, + resizable = false, +}: Props) { + const { classes } = useInputTextAreaStyles({ resizable }); + const tooltip = useToolTip(); + const [isFocused, setIsFocused] = useState(false) + return +