Skip to content

Commit 11e274a

Browse files
committed
Improve Card styling, fix regression with DraggableList
1 parent f10ef06 commit 11e274a

File tree

6 files changed

+51
-36
lines changed

6 files changed

+51
-36
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@programmer_network/yail",
3-
"version": "1.0.165",
3+
"version": "1.0.166",
44
"description": "Programmer Network's official UI library for React",
55
"author": "Aleksandar Grbic - (https://programmer.network)",
66
"publishConfig": {

src/Components/Card/Card.stories.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ const CardStories: Meta<ICard> = {
99
title: "Components/Card",
1010
decorators: [withRouter],
1111
component: Card,
12-
argTypes: {}
12+
parameters: {
13+
layout: "centered"
14+
}
1315
};
1416

1517
export const Default = () => {

src/Components/Card/Card.test.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,10 @@ describe("Card component", () => {
109109
<Card {...mockProps} />
110110
</BrowserRouter>
111111
);
112-
const cardElement = screen.getByText(mockProps.data.title).closest("div");
112+
const cardElement = screen
113+
.getByText(mockProps.data.title)
114+
.closest("div")?.parentElement;
115+
113116
expect(cardElement).toHaveClass("custom-class");
114117
});
115118
});

src/Components/Card/index.tsx

Lines changed: 37 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -11,42 +11,49 @@ const Card: FC<ICard> = ({ data, className, NavLink }) => {
1111
const { title, description, author, date, tags, titleUrl, authorUrl } = data;
1212

1313
return (
14-
<div className={classNames("group yl-mb-4", className)}>
15-
<div className='yl-flex yl-items-center yl-text-primary-text-color'>
16-
<div className='yl-flex yl-flex-1 yl-justify-between yl-gap-2 md:yl-my-1'>
17-
<div className='yl-flex yl-flex-col md:yl-flex-row md:yl-items-center md:yl-gap-2'>
18-
{author && (
19-
<>
20-
{authorUrl ? (
21-
<NavLink to={authorUrl}>
14+
<div
15+
className={classNames(
16+
"group yl-bg-primary-text-color/5 yl-p-4 yl-rounded-md yl-border yl-border-primary-text-color/20 yl-flex yl-flex-col yl-justify-between",
17+
className
18+
)}
19+
>
20+
<div>
21+
<div className='yl-flex yl-items-center yl-text-primary-text-color'>
22+
<div className='yl-flex yl-flex-1 yl-justify-between yl-gap-2 md:yl-my-1'>
23+
<div className='yl-flex yl-flex-col md:yl-flex-row md:yl-items-center md:yl-gap-2'>
24+
{author && (
25+
<>
26+
{authorUrl ? (
27+
<NavLink to={authorUrl}>
28+
<span className='yl-flex yl-items-center yl-gap-2 yl-text-primary hover:yl-text-primary'>
29+
{author}
30+
</span>
31+
</NavLink>
32+
) : (
2233
<span className='yl-flex yl-items-center yl-gap-2 yl-text-primary hover:yl-text-primary'>
2334
{author}
2435
</span>
25-
</NavLink>
26-
) : (
27-
<span className='yl-flex yl-items-center yl-gap-2 yl-text-primary hover:yl-text-primary'>
28-
{author}
29-
</span>
30-
)}
31-
</>
32-
)}
33-
{date && <time dateTime={date}>{date}</time>}
36+
)}
37+
</>
38+
)}
39+
{date && <time dateTime={date}>{date}</time>}
40+
</div>
3441
</div>
3542
</div>
36-
</div>
43+
{URLUtils.isExternalLink(titleUrl) ? (
44+
<Anchor href={titleUrl} target='_blank'>
45+
<H3 className='yl-flex yl-items-center yl-justify-start yl-gap-2'>
46+
{title}
47+
</H3>
48+
</Anchor>
49+
) : (
50+
<NavLink to={titleUrl}>
51+
<H3>{title}</H3>
52+
</NavLink>
53+
)}
3754

38-
{URLUtils.isExternalLink(titleUrl) ? (
39-
<Anchor href={titleUrl} target='_blank'>
40-
<H3 className='yl-flex yl-items-center yl-justify-start yl-gap-2'>
41-
{title}
42-
</H3>
43-
</Anchor>
44-
) : (
45-
<NavLink to={titleUrl}>
46-
<H3>{title}</H3>
47-
</NavLink>
48-
)}
49-
<Paragraph>{description}</Paragraph>
55+
<Paragraph className='yl-py-4'>{description}</Paragraph>
56+
</div>
5057
{tags && tags.length > 0 && (
5158
<div className='yl-mt-2 yl-flex yl-items-center yl-gap-2'>
5259
{tags.map((tag, index) => (

src/Components/Cards/Cards.stories.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ import { ICardsProps } from "./types";
88
const CardsStories: Meta<ICardsProps> = {
99
title: "Components/Cards",
1010
decorators: [withRouter],
11+
parameters: {
12+
layout: "centered"
13+
},
1114
component: Cards,
1215
argTypes: {}
1316
} satisfies Meta<typeof Cards>;
@@ -205,8 +208,8 @@ export const Default = () => {
205208
}));
206209

207210
return (
208-
<div className='yl-mt-8'>
209-
<Cards cards={cards} columns={2} NavLink={NavLink} />
211+
<div className='yl-max-w-5xl'>
212+
<Cards cards={cards} columns={2} NavLink={NavLink} className='yl-gap-4' />
210213
</div>
211214
);
212215
};

src/Components/DraggableList/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ const DraggableList: FC<IDraggableList> = ({
6262

6363
useEffect(() => {
6464
setListItems(items);
65-
}, [items.length]);
65+
}, [items]);
6666

6767
return (
6868
<ul

0 commit comments

Comments
 (0)