@apify/ui-library 1.120.0 → 1.120.1
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/boring_avatar.d.ts +13 -0
- package/dist/src/components/boring_avatar.d.ts.map +1 -0
- package/dist/src/components/boring_avatar.js +98 -0
- package/dist/src/components/boring_avatar.js.map +1 -0
- package/dist/src/components/index.d.ts +2 -0
- package/dist/src/components/index.d.ts.map +1 -1
- package/dist/src/components/index.js +2 -0
- package/dist/src/components/index.js.map +1 -1
- package/dist/src/components/store/actor_avatar.d.ts +18 -0
- package/dist/src/components/store/actor_avatar.d.ts.map +1 -0
- package/dist/src/components/store/actor_avatar.js +64 -0
- package/dist/src/components/store/actor_avatar.js.map +1 -0
- package/dist/src/components/store/index.d.ts +3 -0
- package/dist/src/components/store/index.d.ts.map +1 -0
- package/dist/src/components/store/index.js +3 -0
- package/dist/src/components/store/index.js.map +1 -0
- package/dist/src/components/store/store_actor_header.d.ts +13 -0
- package/dist/src/components/store/store_actor_header.d.ts.map +1 -0
- package/dist/src/components/store/store_actor_header.js +70 -0
- package/dist/src/components/store/store_actor_header.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +3 -2
- package/src/components/boring_avatar.stories.tsx +188 -0
- package/src/components/boring_avatar.tsx +262 -0
- package/src/components/index.ts +2 -0
- package/src/components/store/actor_avatar.stories.tsx +65 -0
- package/src/components/store/actor_avatar.tsx +129 -0
- package/src/components/store/index.ts +2 -0
- package/src/components/store/store_actor_header.stories.tsx +126 -0
- package/src/components/store/store_actor_header.tsx +131 -0
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
|
|
4
|
+
import { StoreActorHeader } from './store_actor_header.js';
|
|
5
|
+
|
|
6
|
+
const meta = {
|
|
7
|
+
title: 'UI-Library/Store/StoreActorHeader',
|
|
8
|
+
component: StoreActorHeader,
|
|
9
|
+
parameters: {
|
|
10
|
+
layout: 'padded',
|
|
11
|
+
},
|
|
12
|
+
argTypes: {
|
|
13
|
+
name: {
|
|
14
|
+
control: 'text',
|
|
15
|
+
description: 'Actor name (slug)',
|
|
16
|
+
},
|
|
17
|
+
title: {
|
|
18
|
+
control: 'text',
|
|
19
|
+
description: 'Display title of the actor',
|
|
20
|
+
},
|
|
21
|
+
username: {
|
|
22
|
+
control: 'text',
|
|
23
|
+
description: 'Username of the actor owner',
|
|
24
|
+
},
|
|
25
|
+
pictureUrl: {
|
|
26
|
+
control: 'text',
|
|
27
|
+
description: 'URL of the actor picture/avatar',
|
|
28
|
+
},
|
|
29
|
+
isUnderMaintenance: {
|
|
30
|
+
control: 'boolean',
|
|
31
|
+
description: 'Shows warning triangle when actor is under maintenance',
|
|
32
|
+
},
|
|
33
|
+
hasRisingStarBadge: {
|
|
34
|
+
control: 'boolean',
|
|
35
|
+
description: 'Shows the rising star badge',
|
|
36
|
+
},
|
|
37
|
+
avatarSize: {
|
|
38
|
+
control: 'number',
|
|
39
|
+
description: 'Size of the avatar in pixels',
|
|
40
|
+
},
|
|
41
|
+
newStyle: {
|
|
42
|
+
control: 'boolean',
|
|
43
|
+
description: 'Uses new styling with larger gap and different typography',
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
} satisfies Meta<typeof StoreActorHeader>;
|
|
47
|
+
|
|
48
|
+
export default meta;
|
|
49
|
+
|
|
50
|
+
type Story = StoryObj<typeof meta>;
|
|
51
|
+
|
|
52
|
+
export const Default: Story = {
|
|
53
|
+
args: {
|
|
54
|
+
name: 'web-scraper',
|
|
55
|
+
title: 'Web Scraper',
|
|
56
|
+
username: 'apify',
|
|
57
|
+
avatarSize: 40,
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export const WithLongNames: Story = {
|
|
62
|
+
args: {
|
|
63
|
+
name: 'very-long-actor-name-that-should-be-truncated',
|
|
64
|
+
title: 'This is a very long actor title that should be truncated with ellipses',
|
|
65
|
+
username: 'apify',
|
|
66
|
+
avatarSize: 40,
|
|
67
|
+
},
|
|
68
|
+
render: (args) => (
|
|
69
|
+
<div style={{ width: '250px', border: '1px solid #ccc', padding: '8px' }}>
|
|
70
|
+
<StoreActorHeader {...args} />
|
|
71
|
+
</div>
|
|
72
|
+
),
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export const Variants: Story = {
|
|
76
|
+
render: () => (
|
|
77
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: '24px' }}>
|
|
78
|
+
<div>
|
|
79
|
+
<h4>Basic</h4>
|
|
80
|
+
<StoreActorHeader
|
|
81
|
+
name="web-scraper"
|
|
82
|
+
title="Web Scraper"
|
|
83
|
+
username="apify"
|
|
84
|
+
/>
|
|
85
|
+
</div>
|
|
86
|
+
<div>
|
|
87
|
+
<h4>With Picture</h4>
|
|
88
|
+
<StoreActorHeader
|
|
89
|
+
name="web-scraper"
|
|
90
|
+
title="Web Scraper"
|
|
91
|
+
username="apify"
|
|
92
|
+
pictureUrl="https://apify.github.io/apify-web/img/apify-logo/logomark-32x32.svg"
|
|
93
|
+
/>
|
|
94
|
+
</div>
|
|
95
|
+
<div>
|
|
96
|
+
<h4>With Rising Star Badge</h4>
|
|
97
|
+
<StoreActorHeader
|
|
98
|
+
name="instagram-scraper"
|
|
99
|
+
title="Instagram Scraper"
|
|
100
|
+
username="apify"
|
|
101
|
+
hasRisingStarBadge={true}
|
|
102
|
+
/>
|
|
103
|
+
</div>
|
|
104
|
+
<div>
|
|
105
|
+
<h4>Under Maintenance</h4>
|
|
106
|
+
<StoreActorHeader
|
|
107
|
+
name="amazon-scraper"
|
|
108
|
+
title="Amazon Product Scraper"
|
|
109
|
+
username="junglee"
|
|
110
|
+
isUnderMaintenance={true}
|
|
111
|
+
/>
|
|
112
|
+
</div>
|
|
113
|
+
<div>
|
|
114
|
+
<h4>All Features Combined</h4>
|
|
115
|
+
<StoreActorHeader
|
|
116
|
+
name="twitter-scraper"
|
|
117
|
+
title="Twitter Scraper"
|
|
118
|
+
username="vdrmota"
|
|
119
|
+
pictureUrl="https://apify.com/img/actors/twitter-scraper.png"
|
|
120
|
+
hasRisingStarBadge={true}
|
|
121
|
+
isUnderMaintenance={true}
|
|
122
|
+
/>
|
|
123
|
+
</div>
|
|
124
|
+
</div>
|
|
125
|
+
),
|
|
126
|
+
};
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
|
|
3
|
+
import { StarEmptyIcon, WarningTriangleIcon } from '@apify/ui-icons';
|
|
4
|
+
|
|
5
|
+
import { Badge, Box, type BoxProps, Heading, Text, theme } from '../../index.js';
|
|
6
|
+
import { ActorAvatar, actorAvatarClassnames } from './actor_avatar.js';
|
|
7
|
+
|
|
8
|
+
const storeActorHeaderClassNames = {
|
|
9
|
+
title: 'ActorStoreItem-title',
|
|
10
|
+
slug: 'ActorStoreItem-slug',
|
|
11
|
+
badge: 'ActorStoreItem-badge',
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const StyledStoreActorHeader = styled(Box)<{ $newStyle?: boolean }>`
|
|
15
|
+
display: flex;
|
|
16
|
+
gap: ${({ $newStyle }) => ($newStyle ? theme.space.space12 : theme.space.space8)};
|
|
17
|
+
align-items: center;
|
|
18
|
+
|
|
19
|
+
.${actorAvatarClassnames.BASE} {
|
|
20
|
+
border: 1px solid ${theme.color.neutral.border};
|
|
21
|
+
flex-shrink: 0;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.${storeActorHeaderClassNames.badge} {
|
|
25
|
+
position: absolute;
|
|
26
|
+
top: -${theme.space.space8};
|
|
27
|
+
right: -${theme.space.space8};
|
|
28
|
+
}
|
|
29
|
+
`;
|
|
30
|
+
|
|
31
|
+
const ActorAvatarWrapper = styled(Box)`
|
|
32
|
+
position: relative;
|
|
33
|
+
display: inline-block;
|
|
34
|
+
`;
|
|
35
|
+
|
|
36
|
+
const StyledCompactBadge = styled(Badge)`
|
|
37
|
+
padding: ${theme.space.space4};
|
|
38
|
+
`;
|
|
39
|
+
|
|
40
|
+
const ActorTitleWrapper = styled(Box)`
|
|
41
|
+
overflow: hidden;
|
|
42
|
+
display: flex;
|
|
43
|
+
flex-direction: column;
|
|
44
|
+
justify-content: center;
|
|
45
|
+
|
|
46
|
+
.${storeActorHeaderClassNames.title} {
|
|
47
|
+
overflow: hidden;
|
|
48
|
+
display: flex;
|
|
49
|
+
align-items: center;
|
|
50
|
+
flex-direction: row;
|
|
51
|
+
justify-content: flex-start;
|
|
52
|
+
gap: ${theme.space.space4};
|
|
53
|
+
|
|
54
|
+
h3 {
|
|
55
|
+
white-space: nowrap;
|
|
56
|
+
overflow: hidden;
|
|
57
|
+
text-overflow: ellipsis;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
svg {
|
|
61
|
+
flex-shrink: 0;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.${storeActorHeaderClassNames.slug} {
|
|
66
|
+
white-space: nowrap;
|
|
67
|
+
overflow: hidden;
|
|
68
|
+
text-overflow: ellipsis;
|
|
69
|
+
}
|
|
70
|
+
`;
|
|
71
|
+
|
|
72
|
+
export type StoreActorHeaderProps = {
|
|
73
|
+
name: string,
|
|
74
|
+
title: string,
|
|
75
|
+
pictureUrl?: string,
|
|
76
|
+
username: string,
|
|
77
|
+
isUnderMaintenance?: boolean,
|
|
78
|
+
hasRisingStarBadge?: boolean,
|
|
79
|
+
avatarSize?: number,
|
|
80
|
+
newStyle?: boolean,
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export const StoreActorHeader: React.FC<StoreActorHeaderProps & BoxProps> = ({
|
|
84
|
+
name,
|
|
85
|
+
title,
|
|
86
|
+
pictureUrl,
|
|
87
|
+
username,
|
|
88
|
+
isUnderMaintenance = false,
|
|
89
|
+
hasRisingStarBadge = false,
|
|
90
|
+
avatarSize = 40,
|
|
91
|
+
newStyle = false,
|
|
92
|
+
...rest
|
|
93
|
+
}) => {
|
|
94
|
+
return (
|
|
95
|
+
<StyledStoreActorHeader data-test="actor-store-item-header" $newStyle={newStyle} {...rest}>
|
|
96
|
+
<ActorAvatarWrapper>
|
|
97
|
+
<ActorAvatar
|
|
98
|
+
size={avatarSize}
|
|
99
|
+
url={pictureUrl}
|
|
100
|
+
name={title}
|
|
101
|
+
/>
|
|
102
|
+
{hasRisingStarBadge && <StyledCompactBadge
|
|
103
|
+
variant='primary_blue'
|
|
104
|
+
size='small'
|
|
105
|
+
LeadingIcon={StarEmptyIcon}
|
|
106
|
+
className={storeActorHeaderClassNames.badge}
|
|
107
|
+
/>}
|
|
108
|
+
</ActorAvatarWrapper>
|
|
109
|
+
<ActorTitleWrapper>
|
|
110
|
+
<div className={storeActorHeaderClassNames.title}>
|
|
111
|
+
{ newStyle
|
|
112
|
+
? <Text as='h3' weight='bold' color={theme.color.neutral.text}>{title}</Text>
|
|
113
|
+
: <Heading as='h3' type="titleS" color={theme.color.neutral.text}>
|
|
114
|
+
{title}
|
|
115
|
+
</Heading>}
|
|
116
|
+
|
|
117
|
+
{isUnderMaintenance && (<WarningTriangleIcon size="12" color={theme.color.warning.icon} />)}
|
|
118
|
+
</div>
|
|
119
|
+
<Text
|
|
120
|
+
size="small"
|
|
121
|
+
weight={newStyle ? 'medium' : 'normal'}
|
|
122
|
+
type="code"
|
|
123
|
+
color={theme.color.neutral.textSubtle}
|
|
124
|
+
className={storeActorHeaderClassNames.slug}
|
|
125
|
+
>
|
|
126
|
+
{username}/{name}
|
|
127
|
+
</Text>
|
|
128
|
+
</ActorTitleWrapper>
|
|
129
|
+
</StyledStoreActorHeader>
|
|
130
|
+
);
|
|
131
|
+
};
|