diff --git a/packages/dashboard-v2/src/components/Icons/icons/SearchIcon.js b/packages/dashboard-v2/src/components/Icons/icons/SearchIcon.js
new file mode 100644
index 00000000..f551dea6
--- /dev/null
+++ b/packages/dashboard-v2/src/components/Icons/icons/SearchIcon.js
@@ -0,0 +1,10 @@
+import { withIconProps } from "../withIconProps";
+
+export const SearchIcon = withIconProps(({ size, ...props }) => (
+
+));
diff --git a/packages/dashboard-v2/src/components/Icons/index.js b/packages/dashboard-v2/src/components/Icons/index.js
index 41552e34..31b34b56 100644
--- a/packages/dashboard-v2/src/components/Icons/index.js
+++ b/packages/dashboard-v2/src/components/Icons/index.js
@@ -9,3 +9,4 @@ export * from "./icons/CircledErrorIcon";
export * from "./icons/CircledProgressIcon";
export * from "./icons/CircledArrowUpIcon";
export * from "./icons/PlusIcon";
+export * from "./icons/SearchIcon";
diff --git a/packages/dashboard-v2/src/components/Icons/withIconProps.js b/packages/dashboard-v2/src/components/Icons/withIconProps.js
index d4267318..5da47331 100644
--- a/packages/dashboard-v2/src/components/Icons/withIconProps.js
+++ b/packages/dashboard-v2/src/components/Icons/withIconProps.js
@@ -4,7 +4,7 @@ const propTypes = {
/**
* Size of the icon's bounding box.
*/
- size: PropTypes.number,
+ size: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
};
const defaultProps = {
diff --git a/packages/dashboard-v2/src/components/TextInputIcon/TextInputIcon.js b/packages/dashboard-v2/src/components/TextInputIcon/TextInputIcon.js
index 892da996..506ee1fc 100644
--- a/packages/dashboard-v2/src/components/TextInputIcon/TextInputIcon.js
+++ b/packages/dashboard-v2/src/components/TextInputIcon/TextInputIcon.js
@@ -1,20 +1,45 @@
import PropTypes from "prop-types";
+import cn from "classnames";
+import { useEffect, useRef, useState } from "react";
+import { PlusIcon } from "../Icons";
+
+export const TextInputIcon = ({ className, icon, placeholder, onChange }) => {
+ const inputRef = useRef();
+ const [focused, setFocused] = useState(false);
+ const [value, setValue] = useState("");
+
+ useEffect(() => {
+ onChange(value);
+ }, [value, onChange]);
-/**
- * Primary UI component for user interaction
- */
-export const TextInputIcon = ({ icon, position, placeholder }) => {
return (
-
- {position === "left" ?
{icon}
: null}
-
+
{icon}
+
setFocused(true)}
+ onBlur={() => setFocused(false)}
+ onChange={(event) => setValue(event.target.value)}
+ placeholder={placeholder}
+ className="focus:outline-none bg-transparent placeholder:text-palette-400"
/>
- {position === "right" ?
{icon}
: null}
+ {value && (
+
setValue("")}
+ />
+ )}
);
};
@@ -23,13 +48,13 @@ TextInputIcon.propTypes = {
/**
* Icon to place in text input
*/
- icon: PropTypes.element,
- /**
- * Side to place icon
- */
- position: PropTypes.oneOf(["left", "right"]),
+ icon: PropTypes.element.isRequired,
/**
* Input placeholder
*/
placeholder: PropTypes.string,
+ /**
+ * Function to be called whenever value changes
+ */
+ onChange: PropTypes.func.isRequired,
};
diff --git a/packages/dashboard-v2/src/components/TextInputIcon/TextInputIcon.stories.js b/packages/dashboard-v2/src/components/TextInputIcon/TextInputIcon.stories.js
index 676ca9cf..521b90df 100644
--- a/packages/dashboard-v2/src/components/TextInputIcon/TextInputIcon.stories.js
+++ b/packages/dashboard-v2/src/components/TextInputIcon/TextInputIcon.stories.js
@@ -1,5 +1,6 @@
import { TextInputIcon } from "./TextInputIcon";
-import { CogIcon } from "../Icons";
+import { SearchIcon } from "../Icons";
+import { Panel } from "../Panel";
// More on default export: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
export default {
@@ -9,19 +10,21 @@ export default {
};
// More on component templates: https://storybook.js.org/docs/react/writing-stories/introduction#using-args
-const Template = (args) => ;
+const Template = (args) => (
+
+
+
+);
export const IconLeft = Template.bind({});
// More on args: https://storybook.js.org/docs/react/writing-stories/args
IconLeft.args = {
- icon: ,
- position: "left",
+ icon: ,
placeholder: "Search",
};
export const IconRight = Template.bind({});
IconRight.args = {
- icon: ,
- position: "right",
+ icon: ,
placeholder: "Search",
};
diff --git a/packages/dashboard-v2/tailwind.config.js b/packages/dashboard-v2/tailwind.config.js
index 4afa0cb2..6f4242d9 100644
--- a/packages/dashboard-v2/tailwind.config.js
+++ b/packages/dashboard-v2/tailwind.config.js
@@ -28,6 +28,7 @@ module.exports = {
borderColor: (theme) => ({ ...theme("colors"), ...colors }),
textColor: (theme) => ({ ...theme("colors"), ...colors }),
placeholderColor: (theme) => ({ ...theme("colors"), ...colors }),
+ outlineColor: (theme) => ({ ...theme("colors"), ...colors }),
extend: {
fontFamily: {
sans: ["Sora", ...defaultTheme.fontFamily.sans],