Skip to content

Commit ba55a4b

Browse files
authored
Update - Melhoria na listagem de suplementos (#249)
1 parent afde606 commit ba55a4b

File tree

3 files changed

+33
-16
lines changed

3 files changed

+33
-16
lines changed

src/components/Chip/Chip.tsx

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,32 @@ import { cva } from 'class-variance-authority';
55
const Chip = React.forwardRef<HTMLDivElement, IChipProps>((props, ref) => {
66
const { label, className, variant = 'info', ...rest } = props;
77

8-
const variants = cva('px-4 py-1.5 font-medium text-sm md:text-md rounded-2xl', {
9-
variants: {
10-
variant: {
11-
warn: 'bg-light-yellow',
12-
success: 'bg-light-green',
13-
danger: 'bg-light-red',
14-
alert: 'bg-light-orange',
15-
info: 'bg-light-blue',
8+
const variants = cva(
9+
'px-4 py-1.5 font-medium text-sm md:text-md rounded-2xl',
10+
{
11+
variants: {
12+
variant: {
13+
warn: 'bg-light-yellow',
14+
success: 'bg-light-green',
15+
danger: 'bg-light-red',
16+
alert: 'bg-light-orange',
17+
info: 'bg-light-blue',
18+
moreInfo: 'bg-gray-200 text-black-600',
19+
},
1620
},
17-
},
18-
defaultVariants: {
19-
variant: 'info',
20-
},
21-
});
21+
defaultVariants: {
22+
variant: 'info',
23+
},
24+
}
25+
);
2226

2327
return (
24-
<span tabIndex={0} ref={ref} {...rest} className={variants({ className, variant })}>
28+
<span
29+
tabIndex={0}
30+
ref={ref}
31+
{...rest}
32+
className={variants({ className, variant })}
33+
>
2534
{label}
2635
</span>
2736
);

src/components/Chip/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export type ChipVariant = 'info' | 'success' | 'warn' | 'danger';
1+
export type ChipVariant = 'info' | 'success' | 'warn' | 'danger' | 'moreInfo';
22

33
export interface IChipProps extends React.ComponentPropsWithoutRef<'div'> {
44
label: string;

src/pages/Home/components/ShelterSupplyCategoryRow/ShelterSupplyCategoryRow.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ const ShelterSupplyCategoryRow = React.forwardRef<
1313

1414
if (tags.length === 0) return <Fragment />;
1515

16+
const moreInfoLabel = () => {
17+
return `+${tags.length - 10} ${tags.length > 11 ? 'itens' : 'item'}`;
18+
};
19+
1620
return (
1721
<div className={cn('flex flex-col gap-3', className)} ref={ref} {...rest}>
1822
<Separator className="mt-2" />
@@ -21,9 +25,13 @@ const ShelterSupplyCategoryRow = React.forwardRef<
2125
</p>
2226
{description && <p>{description}</p>}
2327
<div className="flex gap-2 flex-wrap">
24-
{tags.map((s, idx) => (
28+
{tags.slice(0, 10).map((s, idx) => (
2529
<Chip key={idx} {...s} />
2630
))}
31+
32+
{tags.length > 10 && (
33+
<Chip label={moreInfoLabel()} variant="moreInfo" />
34+
)}
2735
</div>
2836
</div>
2937
);

0 commit comments

Comments
 (0)