@apify/ui-library 1.108.1 → 1.109.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/components/card_container.d.ts +27 -0
- package/dist/src/components/card_container.d.ts.map +1 -0
- package/dist/src/components/card_container.js +46 -0
- package/dist/src/components/card_container.js.map +1 -0
- package/dist/src/components/card_container.stories.d.ts +10 -0
- package/dist/src/components/card_container.stories.d.ts.map +1 -0
- package/dist/src/components/card_container.stories.js +33 -0
- package/dist/src/components/card_container.stories.js.map +1 -0
- package/dist/src/components/index.d.ts +1 -0
- package/dist/src/components/index.d.ts.map +1 -1
- package/dist/src/components/index.js +1 -0
- package/dist/src/components/index.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/components/card_container.stories.tsx +63 -0
- package/src/components/card_container.tsx +78 -0
- package/src/components/index.ts +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apify/ui-library",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.109.0",
|
|
4
4
|
"description": "React UI library used by apify.com",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"It's not nice, but helps us to get around the problem of multiple react instances."
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@apify/ui-icons": "^1.
|
|
29
|
+
"@apify/ui-icons": "^1.23.0",
|
|
30
30
|
"@floating-ui/react": "^0.26.2",
|
|
31
31
|
"@react-hook/resize-observer": "^2.0.2",
|
|
32
32
|
"clsx": "^2.0.0",
|
|
@@ -64,5 +64,5 @@
|
|
|
64
64
|
"src",
|
|
65
65
|
"style"
|
|
66
66
|
],
|
|
67
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "a53c82a8136684f79742ff9360f27494a8944d61"
|
|
68
68
|
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
|
|
4
|
+
import { DragIndicatorIcon } from '@apify/ui-icons';
|
|
5
|
+
|
|
6
|
+
import { CardContainer, type CardContainerProps } from './card_container.js';
|
|
7
|
+
import { IconButton } from './icon_button.js';
|
|
8
|
+
|
|
9
|
+
export default {
|
|
10
|
+
title: 'UI-Library/CardContainer',
|
|
11
|
+
component: CardContainer,
|
|
12
|
+
argTypes: {
|
|
13
|
+
headerPlacement: {
|
|
14
|
+
control: { type: 'select' },
|
|
15
|
+
options: ['TOP', 'BOTTOM'],
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
} as Meta<CardContainerProps>;
|
|
19
|
+
|
|
20
|
+
type Story = StoryObj<CardContainerProps>;
|
|
21
|
+
|
|
22
|
+
const StoryWrapper = styled.div`
|
|
23
|
+
display: grid;
|
|
24
|
+
gap: 1rem;
|
|
25
|
+
grid-template-columns: 1fr 1fr 1fr;
|
|
26
|
+
`;
|
|
27
|
+
/**
|
|
28
|
+
* Default color wheel gradient with standard settings
|
|
29
|
+
*/
|
|
30
|
+
export const Default: Story = {
|
|
31
|
+
args: {
|
|
32
|
+
children: 'This is the content',
|
|
33
|
+
header: 'Recently viewed',
|
|
34
|
+
},
|
|
35
|
+
render: (args: CardContainerProps) => {
|
|
36
|
+
return <StoryWrapper>
|
|
37
|
+
<CardContainer {...args} />
|
|
38
|
+
<CardContainer {...args} headerPlacement='BOTTOM'/>
|
|
39
|
+
<CardContainer
|
|
40
|
+
{...args}
|
|
41
|
+
header={<>
|
|
42
|
+
<CardContainer.Heading>TEst</CardContainer.Heading>
|
|
43
|
+
<IconButton Icon={DragIndicatorIcon}/>
|
|
44
|
+
</>}
|
|
45
|
+
/>
|
|
46
|
+
<CardContainer
|
|
47
|
+
{...args}
|
|
48
|
+
header={<>
|
|
49
|
+
<div>
|
|
50
|
+
<CardContainer.Heading># Videos with this hashtag</CardContainer.Heading>
|
|
51
|
+
<code style={{ marginLeft: 8 }}>Required</code>
|
|
52
|
+
</div>
|
|
53
|
+
</>}
|
|
54
|
+
/>
|
|
55
|
+
<CardContainer
|
|
56
|
+
{...args}
|
|
57
|
+
header={<>
|
|
58
|
+
Completely custom header content
|
|
59
|
+
</>}
|
|
60
|
+
/>
|
|
61
|
+
</StoryWrapper>;
|
|
62
|
+
},
|
|
63
|
+
};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
|
|
4
|
+
import type { ValueOf } from '@apify-packages/types';
|
|
5
|
+
|
|
6
|
+
import { theme } from '../design_system/theme.js';
|
|
7
|
+
import { Box, type BoxProps } from './box.js';
|
|
8
|
+
|
|
9
|
+
const classNames = {
|
|
10
|
+
CONTENT: 'CardContainer-Content',
|
|
11
|
+
HEADER: 'CardContainer-Header',
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const HEADER_PLACEMENT = {
|
|
15
|
+
TOP: 'TOP',
|
|
16
|
+
BOTTOM: 'BOTTOM',
|
|
17
|
+
} as const;
|
|
18
|
+
|
|
19
|
+
const Wrapper = styled(Box)<{$headerPlacement: ValueOf<typeof HEADER_PLACEMENT>}>`
|
|
20
|
+
background-color: ${theme.color.neutral.backgroundSubtle};
|
|
21
|
+
border-radius: ${theme.radius.radius12};
|
|
22
|
+
|
|
23
|
+
padding: ${theme.space.space2};
|
|
24
|
+
|
|
25
|
+
display: flex;
|
|
26
|
+
flex-direction: ${({ $headerPlacement }) => ($headerPlacement === HEADER_PLACEMENT.TOP ? 'column' : 'column-reverse')};
|
|
27
|
+
|
|
28
|
+
.${classNames.CONTENT} {
|
|
29
|
+
/* Inner radius = outer radius - padding */
|
|
30
|
+
border-radius: calc(${theme.radius.radius12} - ${theme.space.space2});
|
|
31
|
+
background-color: ${theme.color.neutral.background};
|
|
32
|
+
|
|
33
|
+
padding: ${theme.space.space16};
|
|
34
|
+
flex-grow: 1;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.${classNames.HEADER} {
|
|
38
|
+
padding: ${theme.space.space4} ${theme.space.space8};
|
|
39
|
+
display: flex;
|
|
40
|
+
justify-content: space-between;
|
|
41
|
+
align-items: center;
|
|
42
|
+
}
|
|
43
|
+
`;
|
|
44
|
+
|
|
45
|
+
const CardContainerHeading = styled.span`${theme.typography.shared.desktop.bodyMMedium}`;
|
|
46
|
+
|
|
47
|
+
export type CardContainerProps = BoxProps & {
|
|
48
|
+
/** The header can be placed on the bottom of the card or on the top. */
|
|
49
|
+
headerPlacement?: ValueOf<typeof HEADER_PLACEMENT>,
|
|
50
|
+
/**
|
|
51
|
+
* If string is passed, the correct styles are applied automatically.
|
|
52
|
+
* In case of custom component, use `CardContainer.Heading` component to get the same styles.
|
|
53
|
+
*/
|
|
54
|
+
header: React.ReactNode,
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* CardContainer visually wraps it's children and shows a simple header.
|
|
59
|
+
*
|
|
60
|
+
* The header can be customized.
|
|
61
|
+
*/
|
|
62
|
+
export const CardContainer = ({
|
|
63
|
+
children,
|
|
64
|
+
header,
|
|
65
|
+
headerPlacement = HEADER_PLACEMENT.TOP,
|
|
66
|
+
...rest
|
|
67
|
+
}: CardContainerProps) => (
|
|
68
|
+
<Wrapper {...rest} $headerPlacement={headerPlacement}>
|
|
69
|
+
<div className={classNames.HEADER}>
|
|
70
|
+
{typeof header === 'string' ? <CardContainerHeading>{header}</CardContainerHeading> : header}
|
|
71
|
+
</div>
|
|
72
|
+
<div className={classNames.CONTENT}>
|
|
73
|
+
{children}
|
|
74
|
+
</div>
|
|
75
|
+
</Wrapper>
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
CardContainer.Heading = CardContainerHeading;
|