Skip to content

Commit d4ee9bd

Browse files
committed
chore: Bump package version to 1.1.6 and update Badge component to support click events
1 parent f63b5c9 commit d4ee9bd

File tree

16 files changed

+136
-70
lines changed

16 files changed

+136
-70
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@programmer_network/yail",
3-
"version": "1.1.5",
3+
"version": "1.1.6",
44
"description": "Programmer Network's official UI library for React",
55
"author": "Aleksandar Grbic - (https://programmer.network)",
66
"publishConfig": {
@@ -171,4 +171,4 @@
171171
"react-router-dom": ">=7.2.0",
172172
"tailwindcss": ">=4.0.0"
173173
}
174-
}
174+
}

src/Components/AddSocialPlatform/index.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,24 @@ const AddSocialPlatform: FC<IAddSocialPlatformProps> = ({
2323

2424
return (
2525
<div
26-
className={classNames("grid md:grid-cols-12 items-end gap-2", className)}
26+
className={classNames(
27+
"flex flex-col md:flex-row gap-2 items-end",
28+
className
29+
)}
2730
>
2831
<Select
2932
name='platform'
3033
label='Platform'
3134
onChange={form.set}
32-
inputWrapperClassName='col-span-5'
35+
inputWrapperClassName='w-full'
3336
value={form.state.platform.value}
3437
error={form.state.platform.error}
3538
options={platforms.map(({ name }) => ({
3639
label: name,
3740
value: name
3841
}))}
3942
/>
40-
<div className='col-span-5'>
43+
<div className='w-full'>
4144
<Input
4245
name='url'
4346
label={getValueLabel(form.state.platform.value)}

src/Components/Badge/Badge.stories.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,13 @@ export const Custom: Story = {
3939
className: "text-bg bg-red-500"
4040
}
4141
};
42+
43+
export const Clickable: Story = {
44+
args: {
45+
title: "Badge",
46+
variant: BadgeVariantEnum.FILLED,
47+
onClick: () => {
48+
alert("Badge clicked");
49+
}
50+
}
51+
};

src/Components/Badge/Badge.test.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,17 @@ describe("Badge component", () => {
4343
const badgeElement = screen.getByText(testTitle);
4444
expect(badgeElement).toHaveClass("bg-transparent");
4545
});
46+
47+
test("applies clickable class name", () => {
48+
render(
49+
<Badge
50+
title={testTitle}
51+
variant={BadgeVariantEnum.FILLED}
52+
onClick={() => alert("Badge clicked")}
53+
/>
54+
);
55+
56+
const badgeElement = screen.getByText(testTitle);
57+
expect(badgeElement).toHaveClass("cursor-pointer");
58+
});
4659
});

src/Components/Badge/__snapshots__/Badge.test.tsx.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
exports[`Badge component > renders correctly - snapshot test 1`] = `
44
<DocumentFragment>
55
<span
6-
class="rounded px-2 py-1 text-sm font-medium bg-primary text-background border-2 border-background/80"
6+
class="rounded px-2 py-1 text-sm font-medium bg-primary text-background border-2 border-background/80 cursor-default"
77
>
88
Test Badge
99
</span>

src/Components/Badge/index.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { FC } from "react";
33

44
import { BadgeVariantEnum, IBadgeProps } from "./types";
55

6-
const Badge: FC<IBadgeProps> = ({ title, className, variant }) => {
6+
const Badge: FC<IBadgeProps> = ({ title, className, variant, onClick }) => {
77
const variants = {
88
[BadgeVariantEnum.FILLED]:
99
"bg-primary text-background border-2 border-background/80",
@@ -15,8 +15,18 @@ const Badge: FC<IBadgeProps> = ({ title, className, variant }) => {
1515

1616
const variantClassNames = variant ? variants[variant] : "";
1717

18+
const onClickCSSClass = onClick ? "cursor-pointer" : "cursor-default";
19+
1820
return (
19-
<span className={classNames(baseClassNames, variantClassNames, className)}>
21+
<span
22+
className={classNames(
23+
baseClassNames,
24+
variantClassNames,
25+
className,
26+
onClickCSSClass
27+
)}
28+
onClick={onClick}
29+
>
2030
{title}
2131
</span>
2232
);

src/Components/Badge/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ export interface IBadgeProps {
77
title: string;
88
className?: string;
99
variant?: BadgeVariantEnum;
10+
onClick?: () => void;
1011
}

src/Components/Card/Components/CardTags.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,22 @@ const CardTags: FC<ICardTags> = ({
2424
}) => {
2525
if (!visibleTags.length) return null;
2626

27+
const handleTagClick = (tag: ITag) => (e: React.MouseEvent) => {
28+
e.stopPropagation();
29+
if (!onTagClick) {
30+
return;
31+
}
32+
33+
onTagClick(tag)(e);
34+
};
35+
2736
return (
2837
<div className='flex items-center gap-2 flex-wrap mt-4'>
2938
{visibleTags.map((tag, index) => (
3039
<NavLink
3140
key={`${tag.name}-${index}`}
3241
to={tag.url}
33-
onClick={onTagClick ? onTagClick(tag) : undefined}
42+
onClick={handleTagClick(tag)}
3443
className='hover:text-stroke text-primary hover:underline hover:opacity-80 active:opacity-50 transition-all'
3544
>
3645
#{tag.name}

src/Components/Inputs/Checkbox/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const Checkbox: FC<ICheckboxProps> = (
2727
/>
2828
{checked && (
2929
<svg
30-
className='absolute left-1 top-1 h-4 w-4 text-primary pointer-events-none'
30+
className='absolute left-1 top-1 h-4 w-4 text-background pointer-events-none'
3131
fill='currentColor'
3232
viewBox='0 0 20 20'
3333
>

src/Components/Inputs/Common/InputHeader/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ const InputHeader: FC<InputHeaderProps> = (
2222

2323
return (
2424
<div className='mb-2 flex items-center justify-between'>
25-
<div className='flex items-center gap-0.5'>
25+
<div className='flex items-center gap-1'>
2626
{hint && name && (
27-
<Tooltip text={hint} id={name} place='right'>
27+
<Tooltip text={hint} id={name} place='top'>
2828
<Icon
2929
iconName='IconInfo'
30-
className='w-4 text-text relative top-[1px] cursor-pointer'
30+
className='w-4 text-text relative top-px cursor-pointer'
3131
/>
3232
</Tooltip>
3333
)}

0 commit comments

Comments
 (0)