Skip to content

Commit

Permalink
Merge pull request #826 from amitamrutiya/update-performer
Browse files Browse the repository at this point in the history
enhance PerformersSection, StatCardProps and improve icon click…
  • Loading branch information
amitamrutiya authored Nov 28, 2024
2 parents 30fd40e + 940494d commit 0f8b16a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
13 changes: 8 additions & 5 deletions src/custom/PerformersSection/PerformersSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ interface BaseQueryParams {

interface StatCardProps {
label: string;
countKey: string;
count: number;
patternName: string;
pattern: Pattern;
Expand All @@ -57,7 +58,7 @@ interface StatCardProps {
status: string;
id: string;
onCardClick: (pattern: Pattern) => void;
onIconClick: () => void;
onIconClick: (sortOrder: string) => void;
onAuthorClick: (userId: string) => void;
onStatusClick: (status: string) => void;
}
Expand Down Expand Up @@ -121,6 +122,7 @@ const createQueryParams = (metric: MetricType): BaseQueryParams => ({

const StatCardComponent: React.FC<StatCardProps> = ({
label,
countKey,
count,
patternName,
pattern,
Expand All @@ -138,9 +140,9 @@ const StatCardComponent: React.FC<StatCardProps> = ({
onCardClick(pattern);
};

const handleIconClick = (e: React.MouseEvent) => {
const handleIconClick = (e: React.MouseEvent, sortOrder: string) => {
e.stopPropagation();
onIconClick();
onIconClick(sortOrder);
};

const handleAuthorClick = (e: React.MouseEvent) => {
Expand All @@ -157,10 +159,10 @@ const StatCardComponent: React.FC<StatCardProps> = ({
<StyledCard elevation={0} status={status} onClick={handleCardClick}>
<ContentWrapper cardId={id}>
<HeaderSection>
<HeaderTitle>{label}</HeaderTitle>
<IconContainer onClick={handleIconClick}>
<IconContainer onClick={(e) => handleIconClick(e, `${countKey}+desc`)}>
<Icon className={id} />
</IconContainer>
<HeaderTitle>{label}</HeaderTitle>
</HeaderSection>

<StatsValue>{count}</StatsValue>
Expand Down Expand Up @@ -238,6 +240,7 @@ const processQueryData = (

return {
label: config.label,
countKey: config.countKey,
count: pattern[config.countKey],
patternName: pattern.name || 'Unknown',
pattern: pattern,
Expand Down
18 changes: 12 additions & 6 deletions src/custom/PerformersSection/styles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,22 +137,21 @@ export const IconContainer = styled(Box)(() => ({
}
}));

export const ContentWrapper = styled(CardContent)<ContentWrapperProps>(({ cardId, theme }) => ({
export const ContentWrapper = styled(CardContent)<ContentWrapperProps>(() => ({
height: '100%',
display: 'flex',
flexDirection: 'column',
padding: theme.spacing(2),
paddingInline: cardId === 'download-icon' ? '12px' : theme.spacing(2),
padding: '12px',
'&:last-child': {
paddingBottom: theme.spacing(2)
paddingBottom: '12px'
}
}));

export const HeaderSection = styled(Box)({
display: 'flex',
justifyContent: 'space-between',
alignItems: 'flex-start',
marginBottom: '1rem',
marginBottom: '0.5rem',
gap: '0.6rem'
});

Expand All @@ -163,7 +162,14 @@ export const HeaderTitle = styled(Typography)(({ theme }) => ({
lineHeight: 1.2,
marginTop: '4px',
textTransform: 'uppercase',
letterSpacing: '0.5px'
letterSpacing: '0.5px',
display: '-webkit-box',
WebkitLineClamp: 2,
WebkitBoxOrient: 'vertical',
overflow: 'hidden',
textOverflow: 'clip',
maxWidth: '70%',
height: '2.4em'
}));

export const StatsValue = styled(Typography)(({ theme }) => ({
Expand Down

0 comments on commit 0f8b16a

Please sign in to comment.