Skip to content

Commit

Permalink
WEB-1485 extra to the bottom + tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Pedro Ladaria committed Jul 28, 2023
1 parent f6a6bab commit 814cf85
Show file tree
Hide file tree
Showing 17 changed files with 40 additions and 25 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,15 @@ test.each`

expect(image).toMatchImageSnapshot();
});

test('Advanced Data Card inside Carousel', async () => {
await openStoryPage({
id: 'community-advanceddatacards-in-carousel--default',
device: 'DESKTOP',
});

const element = await screen.findByTestId('advanced-data-card-carousel');
const image = await element.screenshot();

expect(image).toMatchImageSnapshot();
});
29 changes: 15 additions & 14 deletions src/community/__stories__/advanced-data-card-carousel-story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as React from 'react';
import AdvancedDataCard from '../advanced-data-card';
import {Placeholder} from '../../placeholder';
import {Carousel} from '../../carousel';
import Tag from '../../tag';

export default {
title: 'Community/AdvancedDataCards in Carousel',
Expand All @@ -10,48 +11,48 @@ export default {
type Args = {onPress: boolean};

export const Default: StoryComponent<Args> = ({onPress}) => {
const onPressHandler = onPress
? () => {
console.log('click');
}
: undefined;
const onPressHandler = onPress ? () => {} : undefined;
return (
<Carousel
dataAttributes={{testid: 'advanced-data-card-carousel'}}
itemsPerPage={4}
items={[
<AdvancedDataCard
title="Title"
footerText="Footer"
title="Title 1"
description="Description 1"
footerText="Footer 1"
onClose={() => {}}
onPress={onPressHandler}
/>,
<AdvancedDataCard
title="Title"
title="Title 2"
headline={<Tag>Headline 2</Tag>}
extra={[<Placeholder height={48} />]}
footerText="Footer"
footerText="Footer 2"
onClose={() => {}}
onPress={onPressHandler}
/>,
<AdvancedDataCard
title="Title"
title="Title 3"
description="Description 3"
extra={[<Placeholder height={48} />, <Placeholder height={48} />]}
footerText="Footer"
footerText="Footer 3"
onClose={() => {}}
onPress={onPressHandler}
/>,
<AdvancedDataCard
title="Title"
title="Title 4"
extra={[
<Placeholder height={48} />,
<Placeholder height={48} />,
<Placeholder height={48} />,
]}
footerText="Footer"
footerText="Footer 4"
onClose={() => {}}
onPress={onPressHandler}
/>,
]}
></Carousel>
/>
);
};

Expand Down
1 change: 0 additions & 1 deletion src/community/__stories__/advanced-data-card-story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import type {TagType} from '../../tag';

export default {
title: 'Community/AdvancedDataCard',
argTypes: {extra: {control: {type: 'range', min: 0, max: 5}}},
};

type Args = {
Expand Down
15 changes: 10 additions & 5 deletions src/community/advanced-data-card.css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,16 @@ export const actions = style([
},
]);

export const touchableContainer = sprinkles({
height: '100%',
display: 'flex',
flexDirection: 'column',
});
export const touchableContainer = style([
{
// not defined in sprinkles to avoid touchable style override
display: 'flex',
},
sprinkles({
height: '100%',
flexDirection: 'column',
}),
]);

export const hoverEffect = style({
'@media': {
Expand Down
8 changes: 3 additions & 5 deletions src/community/advanced-data-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -279,9 +279,7 @@ export const AdvancedDataCard = React.forwardRef<HTMLDivElement, AdvancedDataCar
onPress={onPress}
tabIndex={0}
maybe
className={classNames(styles.touchableContainer, {
[styles.hoverEffect]: !!onPress,
})}
className={classNames(styles.touchableContainer, {[styles.hoverEffect]: !!onPress})}
aria-label={ariaLabel}
>
<div
Expand All @@ -308,9 +306,8 @@ export const AdvancedDataCard = React.forwardRef<HTMLDivElement, AdvancedDataCar
/>
</Stack>
</Box>
<CardActionsGroup actions={actions} onClose={onClose} />
</div>

<div style={{flexGrow: 1}} />
{hasExtras && (
<Box paddingTop={16} paddingBottom={24}>
{extra.map((item, index) => {
Expand All @@ -331,6 +328,7 @@ export const AdvancedDataCard = React.forwardRef<HTMLDivElement, AdvancedDataCar
</Touchable>
{hasFooter && <CardFooter {...footerProps} />}
</Boxed>
<CardActionsGroup actions={actions} onClose={onClose} />
</section>
);
}
Expand Down

0 comments on commit 814cf85

Please sign in to comment.