Skip to content

Commit

Permalink
BoxTextInput: Add info icon tooltip
Browse files Browse the repository at this point in the history
  • Loading branch information
victorgcramos authored May 11, 2022
1 parent a4bc6fe commit b74e1f2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/components/BoxTextInput/BoxTextInput.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import PropTypes from "prop-types";
import styles from "./styles.module.css";
import { classNames } from "../../utils";
import Icon from "../Icon/Icon.jsx";
import Tooltip from "../Tooltip/Tooltip.jsx";

const FormWrapper = ({ className, onSubmit, children }) => {
return (
Expand Down Expand Up @@ -31,6 +32,8 @@ const BoxTextInput = ({
searchInput,
className,
inputClassName,
tooltipInfo,
tooltipPlacement,
...props
}) => {
const handleSubmit = (e) => {
Expand Down Expand Up @@ -64,6 +67,13 @@ const BoxTextInput = ({
<Icon type="search" />
</button>
)}
{tooltipInfo && (
<span className={styles.boxtextinputButton}>
<Tooltip content={tooltipInfo} placement={tooltipPlacement}>
<Icon type="info" />
</Tooltip>
</span>
)}
<p
className={classNames(styles.errorMsg, error && styles.errorMsgActive)}>
{error}
Expand Down Expand Up @@ -96,6 +106,8 @@ BoxTextInput.propTypes = {
onChange: PropTypes.func,
className: PropTypes.string,
inputClassName: PropTypes.string,
tooltipInfo: PropTypes.node,
tooltipPlacement: PropTypes.oneOf(["top", "bottom", "right", "left"]),
};

BoxTextInput.defaultProps = {
Expand Down
8 changes: 8 additions & 0 deletions src/stories/BoxTextInput.stories.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,11 @@ Searchable.args = {
searchInput: true,
error: "",
};

export const WithInfoTooltip = Template.bind({});
WithInfoTooltip.args = {
placeholder: "Censorship Token",
name: "token",
tooltipInfo: "Record Censorship Token",
tooltipPlacement: "bottom",
};

0 comments on commit b74e1f2

Please sign in to comment.