Skip to content

Commit 58f1145

Browse files
przemyslaw-wlodektommayeliogwklos-iohk
authored
fix(staking): [LW-10546] grid view breakpoints and card fade scale computations (#1148)
* fix(staking): grid view breakpoints and card fade scale computations LW-10546 * test(extension): update LW-9996 --------- Co-authored-by: Tom Mayel <tom.mayel@iohk.io> Co-authored-by: wklos-iohk <wojciech.klos@iohk.io>
1 parent d45434e commit 58f1145

File tree

5 files changed

+30
-30
lines changed

5 files changed

+30
-30
lines changed

packages/e2e-tests/src/features/MultiDelegationPageExtended.part1.feature

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -221,13 +221,13 @@ Feature: Staking Page - Extended View
221221
And I open Browse pools tab
222222
And I switch to grid view on "Browse pools" tab
223223
Then stake pool grid view is displayed
224-
Then I see 5 stake pool cards in a row
225-
When I resize the window to a width of: 1660 and a height of: 1080
226-
Then I see 5 stake pool cards in a row
227-
When I resize the window to a width of: 1659 and a height of: 1080
228224
Then I see 4 stake pool cards in a row
229-
When I resize the window to a width of: 668 and a height of: 1080
225+
When I resize the window to a width of: 1660 and a height of: 1080
230226
Then I see 4 stake pool cards in a row
231-
When I resize the window to a width of: 667 and a height of: 1080
227+
When I resize the window to a width of: 1659 and a height of: 1080
228+
Then I see 3 stake pool cards in a row
229+
When I resize the window to a width of: 669 and a height of: 1080
232230
Then I see 3 stake pool cards in a row
231+
When I resize the window to a width of: 668 and a height of: 1080
232+
Then I see 2 stake pool cards in a row
233233

packages/staking/src/features/BrowsePools/StakePoolCard/StakePoolCard.css.ts

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,28 +48,22 @@ export const skeleton = recipe({
4848
},
4949
],
5050
variants: {
51-
fade3: {
52-
0: style({ opacity: '0.75' }),
53-
1: style({ opacity: '0.5' }),
54-
2: style({ opacity: '0.25' }),
55-
3: style({ opacity: '0.5' }),
51+
fade2: {
52+
0: style({ opacity: '1' }),
53+
1: style({ opacity: '0.75' }),
5654
},
57-
fade4: {
55+
fade3: {
5856
0: style({ opacity: '1' }),
5957
1: style({ opacity: '0.75' }),
6058
2: style({ opacity: '0.5' }),
61-
3: style({ opacity: '0.25' }),
62-
4: style({ opacity: '0.5' }),
6359
},
64-
fade5: {
60+
fade4: {
6561
0: style({ opacity: '1' }),
6662
1: style({ opacity: '0.75' }),
6763
2: style({ opacity: '0.5' }),
6864
3: style({ opacity: '0.25' }),
69-
4: style({ opacity: '0.5' }),
70-
5: style({ opacity: '0.75' }),
7165
},
7266
},
7367
});
7468

75-
export type fadeVariants = Required<NonNullable<RecipeVariants<typeof skeleton>>>;
69+
export type FadeVariant = keyof NonNullable<RecipeVariants<typeof skeleton>>;

packages/staking/src/features/BrowsePools/StakePoolCard/StakePoolCardSkeleton.tsx

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import { Card } from '@lace/ui';
33
import cn from 'classnames';
44
import * as styles from './StakePoolCard.css';
5+
import { FadeVariant } from './StakePoolCard.css';
56

67
interface Props {
78
index?: number;
@@ -10,9 +11,14 @@ interface Props {
1011

1112
const defaultFadeScale = 4;
1213

13-
export const StakePoolCardSkeleton = ({ index = 0, fadeScale = defaultFadeScale }: Props) => (
14-
<Card.Greyed
15-
className={cn(styles.card, styles.skeleton({ [`fade${fadeScale}`]: index % (fadeScale + 1) }))}
16-
data-testid="stake-pool-card-skeleton"
17-
/>
18-
);
14+
export const StakePoolCardSkeleton = ({ index = 0, fadeScale = defaultFadeScale }: Props) => {
15+
// this is necessary because computed key in `styles.skeleton({ [`fade${fadeScale}`]: 0 })` isn't type-safe for some reason
16+
const skeletonVariant: FadeVariant = `fade${fadeScale}`;
17+
18+
return (
19+
<Card.Greyed
20+
className={cn(styles.card, styles.skeleton({ [skeletonVariant]: index % fadeScale }))}
21+
data-testid="stake-pool-card-skeleton"
22+
/>
23+
);
24+
};

packages/staking/src/features/BrowsePools/StakePoolsGrid/StakePoolsGrid.css.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ export const grid = style([
1010
}),
1111
{
1212
'@media': {
13-
'screen and (min-width: 668px)': {
14-
gridTemplateColumns: 'repeat(4, minmax(0, 1fr))',
13+
'screen and (min-width: 669px)': {
14+
gridTemplateColumns: 'repeat(3, minmax(0, 1fr))',
1515
},
1616
'screen and (min-width: 1660px)': {
17-
gridTemplateColumns: 'repeat(5, minmax(0, 1fr))',
17+
gridTemplateColumns: 'repeat(4, minmax(0, 1fr))',
1818
},
1919
},
20-
gridTemplateColumns: 'repeat(3, minmax(0, 1fr))',
20+
gridTemplateColumns: 'repeat(2, minmax(0, 1fr))',
2121
},
2222
]);
2323

packages/staking/src/features/BrowsePools/StakePoolsGrid/StakePoolsGrid.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ export const StakePoolsGrid = ({
4343

4444
const showEmptyPlaceholder = !showSkeleton && pools.length === 0;
4545
const matchTwoColumnsLayout = useMediaQuery({ maxWidth: 668 });
46-
const matchThreeColumnsLayout = useMediaQuery({ maxWidth: 1024, minWidth: 669 });
47-
const matchFourColumnsLayout = useMediaQuery({ minWidth: 1025 });
46+
const matchThreeColumnsLayout = useMediaQuery({ maxWidth: 1660, minWidth: 668 });
47+
const matchFourColumnsLayout = useMediaQuery({ minWidth: 1660 });
4848

4949
const numberOfItemsPerMediaQueryMap: Partial<Record<StakePoolsGridColumnCount, boolean>> = useMemo(
5050
() => ({

0 commit comments

Comments
 (0)