Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@agility/plenum-ui",
"version": "2.3.1",
"version": "2.3.2",
"license": "MIT",
"main": "dist/index.js",
"module": "dist/index.js",
Expand Down
5 changes: 3 additions & 2 deletions stories/atoms/icons/TablerIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ export interface ITablerIconProps extends React.DetailedHTMLProps<React.HTMLAttr

const TablerIcon: React.FC<ITablerIconProps> = ({
icon,
className = "w-6 h-6 text-gray-600"
className = "w-6 h-6 text-gray-600",
...rest
}: ITablerIconProps): JSX.Element | null => {
const [Icon, setIcon] = useState<ComponentType<any> | null>(
iconRegistry && icon ? (iconRegistry[icon] ?? null) : null
Expand All @@ -38,7 +39,7 @@ const TablerIcon: React.FC<ITablerIconProps> = ({

if (!Icon) return null;
return (
<i>
<i {...rest}>
<Icon className={className} />
</i>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { Meta, StoryObj } from "@storybook/react";
import FormInputWithAddons, { IFormInputWithAddonsProps } from "./FormInputWithAddons";
import { action } from "@storybook/addon-actions";
import FormInputWithAddons from "./FormInputWithAddons";

const meta: Meta<typeof FormInputWithAddons> = {
title: "Design System/organisms/Form Input With Addons",
Expand Down Expand Up @@ -27,6 +28,19 @@ export const DefaultFormInputWithAddons: Story = {
trailIcon: { icon: "IconSearch" }
}
};
export const TrailIconWithOnClick: Story = {
args: {
id: "appSearch",
name: "appSearch",
type: "text",
placeholder: "Search...",
trailIcon: {
icon: "IconX",
onClick: action("trailIcon clicked")
}
}
};

export const FormInputWithAddonBTN: Story = {
args: {
id: "appSearch",
Expand Down
67 changes: 46 additions & 21 deletions stories/organisms/FormInputWithAddons/FormInputWithAddons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,27 +121,52 @@ const FormInputWithAddons: React.FC<IFormInputWithAddonsProps> = ({
}}
/>
{(trailLabel || trailIcon) && (
<label
ref={trailLabelRef}
htmlFor={id}
className={cn(
"right absolute top-0 bottom-0 right-3 flex items-center justify-center text-sm !text-gray-500 ",
labelClass
)}
>
{trailIcon && (
<span>
<DynamicIcon
{...{
...trailIcon,
className: cn("h-5 w-5 text-gray-400", customIconClass, trailIcon.className),
outline: iconOutlined
}}
/>
</span>
)}
{trailLabel && trailLabel}
</label>
trailIcon?.onClick ? (
<button
ref={trailLabelRef as unknown as React.RefObject<HTMLButtonElement>}
type="button"
onClick={(e) => { e.preventDefault(); trailIcon.onClick!(e as unknown as React.MouseEvent<HTMLElement>); }}
className={cn(
"right absolute top-0 bottom-0 right-3 flex items-center justify-center text-sm !text-gray-500 bg-transparent border-0 p-0 cursor-pointer",
labelClass
)}
>
{trailIcon && (
<span>
<DynamicIcon
{...{
...trailIcon,
className: cn("h-5 w-5 text-gray-400", customIconClass, trailIcon.className),
outline: iconOutlined
}}
/>
</span>
)}
{trailLabel && trailLabel}
</button>
) : (
<label
ref={trailLabelRef}
htmlFor={id}
className={cn(
"right absolute top-0 bottom-0 right-3 flex items-center justify-center text-sm !text-gray-500 ",
labelClass
)}
>
{trailIcon && (
<span>
<DynamicIcon
{...{
...trailIcon,
className: cn("h-5 w-5 text-gray-400", customIconClass, trailIcon.className),
outline: iconOutlined
}}
/>
</span>
)}
{trailLabel && trailLabel}
</label>
)
)}
{addonBTN && (
<div className="absolute top-0 bottom-0 right-0 flex items-center ">
Expand Down
Loading