Skip to content

Commit 07150a0

Browse files
authored
Merge pull request #566 from devtron-labs/feat/template-create
fix: GenericInfoCard stylings
2 parents 240c214 + f6b01f0 commit 07150a0

File tree

4 files changed

+57
-10
lines changed

4 files changed

+57
-10
lines changed

src/Shared/Components/GenericInfoCard/GenericInfoCard.component.tsx

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import { cloneElement } from 'react'
22
import { Link } from 'react-router-dom'
3+
import { ReactComponent as ICCaretSmall } from '@Icons/ic-caret-left-small.svg'
4+
import { Tooltip } from '@Common/Tooltip'
35
import { GenericInfoCardProps } from './types'
46
import { getClassNameForBorderVariant } from './utils'
7+
import './styles.scss'
58

69
const GenericInfoCard = ({
710
title,
@@ -22,7 +25,7 @@ const GenericInfoCard = ({
2225
</div>
2326

2427
<div className="flexbox-col dc__gap-8 flex-grow-1">
25-
<div className="flexbox-col dc__gap-2">
28+
<div className="flexbox-col dc__gap-4">
2629
<span className={isLoading ? 'shimmer w-300' : ''} />
2730
<span className={isLoading ? 'shimmer w-150 pt-2' : ''} />
2831
</div>
@@ -33,7 +36,9 @@ const GenericInfoCard = ({
3336
)
3437

3538
const renderContent = () => (
36-
<div className={`flexbox dc__gap-16 p-12 bg__primary ${getClassNameForBorderVariant(borderVariant)}`}>
39+
<div
40+
className={`flexbox dc__gap-16 p-12 bg__primary generic-info-card br-8 ${getClassNameForBorderVariant(borderVariant)}`}
41+
>
3742
{isLoading ? (
3843
renderShimmerContent()
3944
) : (
@@ -44,11 +49,24 @@ const GenericInfoCard = ({
4449

4550
<div className="flexbox-col dc__gap-8 flex-grow-1">
4651
<div className="flexbox-col">
47-
<h3 className="fw-6 fs-13 lh-20 cn-9 m-0">{title}</h3>
48-
<h4 className="fw-4 fs-12 lh-16 cn-7 m-0">By {author}</h4>
52+
<div className="flexbox dc__align-items-center">
53+
<Tooltip content={title}>
54+
<h3 className="fw-6 fs-13 lh-20 cn-9 m-0 generic-info-card__title dc__truncate dc__mxw-600">
55+
{title}
56+
</h3>
57+
</Tooltip>
58+
59+
<div className="generic-info-card__arrow dc__no-shrink flex">
60+
<ICCaretSmall className="icon-dim-16 dc__flip-180 scb-5" />
61+
</div>
62+
</div>
63+
64+
<Tooltip content={author}>
65+
<h4 className="fw-4 fs-12 lh-16 cn-7 m-0 dc__truncate w-300">By {author}</h4>
66+
</Tooltip>
4967
</div>
5068

51-
<p className="fw-4 fs-12 lh-16 cn-7 m-0">{description}</p>
69+
<p className="fw-4 fs-12 lh-16 cn-7 m-0 dc__truncate--clamp-3">{description}</p>
5270
</div>
5371
</>
5472
)}
@@ -64,9 +82,9 @@ const GenericInfoCard = ({
6482
}
6583

6684
return (
67-
<button type="button" onClick={onClick} className="dc__unset-button-styles">
85+
<div role="button" tabIndex={0} onClick={onClick} className="dc__unset-button-styles dc__align-unset">
6886
{renderContent()}
69-
</button>
87+
</div>
7088
)
7189
}
7290

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
.generic-info-card {
2+
transition: box-shadow 0.2s ease-out;
3+
4+
&__title {
5+
transition: color 0.2s ease-out;
6+
}
7+
8+
&__arrow {
9+
transition: all 0.2s ease-out;
10+
transform: translateX(-20%);
11+
visibility: hidden;
12+
}
13+
14+
&:hover {
15+
position: relative;
16+
z-index: 1;
17+
box-shadow: var(--shadow-card-secondary);
18+
19+
// NOTE: &__title was not working here
20+
.generic-info-card__title {
21+
color: var(--B500);
22+
}
23+
24+
.generic-info-card__arrow {
25+
transform: translateX(30%);
26+
visibility: visible;
27+
}
28+
}
29+
}

src/Shared/Components/GenericInfoCard/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ type BaseGenericInfoCardProps = {
1212
linkProps?: Pick<LinkProps, 'to' | 'target' | 'rel'>
1313
}
1414
| {
15-
onClick?: MouseEventHandler<HTMLButtonElement>
15+
onClick?: MouseEventHandler<HTMLDivElement>
1616
linkProps?: never
1717
}
1818
)
@@ -25,7 +25,7 @@ export enum GenericInfoCardBorderVariant {
2525
export type GenericInfoCardProps = { borderVariant: GenericInfoCardBorderVariant } & (
2626
| ({
2727
isLoading: true
28-
} & Partial<BaseGenericInfoCardProps>)
28+
} & Partial<Record<keyof BaseGenericInfoCardProps, never>>)
2929
| ({
3030
isLoading?: boolean
3131
} & BaseGenericInfoCardProps)

src/Shared/Components/GenericInfoCard/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ export const getClassNameForBorderVariant = (variant: GenericInfoCardBorderVaria
55
return ''
66
}
77

8-
return 'br-4 dc__border-n1'
8+
return 'dc__border-n1'
99
}

0 commit comments

Comments
 (0)