@apify/ui-library 1.168.1 → 1.168.3
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/components/avatar/bordered_actor_avatar.d.ts +9 -0
- package/dist/components/avatar/bordered_actor_avatar.d.ts.map +1 -0
- package/dist/components/avatar/bordered_actor_avatar.js +43 -0
- package/dist/components/avatar/index.d.ts +1 -0
- package/dist/components/avatar/index.d.ts.map +1 -1
- package/dist/components/dropdown/dropdown.types.d.ts +2 -2
- package/dist/components/dropdown/dropdown.types.d.ts.map +1 -1
- package/dist/components/split_button/split_button.d.ts +3 -3
- package/dist/components/split_button/split_button.d.ts.map +1 -1
- package/dist/files_hash_at_build.txt +1 -1
- package/dist/index.js +2 -1
- package/dist/src/components/avatar/bordered_actor_avatar.d.ts +9 -0
- package/dist/src/components/avatar/bordered_actor_avatar.d.ts.map +1 -0
- package/dist/src/components/avatar/bordered_actor_avatar.js +28 -0
- package/dist/src/components/avatar/bordered_actor_avatar.js.map +1 -0
- package/dist/src/components/avatar/index.d.ts +1 -0
- package/dist/src/components/avatar/index.d.ts.map +1 -1
- package/dist/src/components/avatar/index.js +1 -0
- package/dist/src/components/avatar/index.js.map +1 -1
- package/dist/src/components/dropdown/dropdown.types.d.ts +2 -2
- package/dist/src/components/dropdown/dropdown.types.d.ts.map +1 -1
- package/dist/src/components/split_button/split_button.d.ts +3 -3
- package/dist/src/components/split_button/split_button.d.ts.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/components/avatar/bordered_actor_avatar.stories.tsx +54 -0
- package/src/components/avatar/bordered_actor_avatar.tsx +45 -0
- package/src/components/avatar/index.ts +1 -0
- package/src/components/dropdown/dropdown.types.ts +2 -2
- package/src/components/split_button/split_button.tsx +3 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apify/ui-library",
|
|
3
|
-
"version": "1.168.
|
|
3
|
+
"version": "1.168.3",
|
|
4
4
|
"description": "React UI library used by apify.com",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -94,5 +94,5 @@
|
|
|
94
94
|
"src",
|
|
95
95
|
"style"
|
|
96
96
|
],
|
|
97
|
-
"gitHead": "
|
|
97
|
+
"gitHead": "fed97f595c48ce93b0f230388cf98113cd62791f"
|
|
98
98
|
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
+
|
|
3
|
+
import { BorderedActorAvatar } from './bordered_actor_avatar';
|
|
4
|
+
|
|
5
|
+
const AVATAR_SIZES = [24, 32, 40, 44] as const;
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
title: 'UI-Library/Avatar/BorderedActorAvatar',
|
|
9
|
+
component: BorderedActorAvatar,
|
|
10
|
+
argTypes: {
|
|
11
|
+
size: { control: 'select', options: AVATAR_SIZES },
|
|
12
|
+
name: { control: 'text' },
|
|
13
|
+
url: { control: 'text' },
|
|
14
|
+
},
|
|
15
|
+
args: {
|
|
16
|
+
name: 'Web Scraper',
|
|
17
|
+
size: 24,
|
|
18
|
+
},
|
|
19
|
+
tags: ['new'],
|
|
20
|
+
} as Meta<typeof BorderedActorAvatar>;
|
|
21
|
+
|
|
22
|
+
type Story = StoryObj<typeof BorderedActorAvatar>;
|
|
23
|
+
|
|
24
|
+
export const Default: Story = {};
|
|
25
|
+
|
|
26
|
+
export const Sizes: Story = {
|
|
27
|
+
render: () => (
|
|
28
|
+
<div style={{ display: 'flex', gap: '16px', alignItems: 'flex-end' }}>
|
|
29
|
+
{AVATAR_SIZES.map((size) => (
|
|
30
|
+
<div key={size} style={{ textAlign: 'center' }}>
|
|
31
|
+
<BorderedActorAvatar name="Web Scraper" size={size} />
|
|
32
|
+
<p style={{ marginTop: '8px', fontSize: '12px' }}>{size}px</p>
|
|
33
|
+
</div>
|
|
34
|
+
))}
|
|
35
|
+
</div>
|
|
36
|
+
),
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export const WithImageUrl: Story = {
|
|
40
|
+
render: () => (
|
|
41
|
+
<div style={{ display: 'flex', gap: '16px', alignItems: 'flex-end' }}>
|
|
42
|
+
{AVATAR_SIZES.map((size) => (
|
|
43
|
+
<div key={size} style={{ textAlign: 'center' }}>
|
|
44
|
+
<BorderedActorAvatar
|
|
45
|
+
name="Actors MCP Server"
|
|
46
|
+
url="https://apify.github.io/apify-web/img/apify-logo/logomark-32x32.svg"
|
|
47
|
+
size={size}
|
|
48
|
+
/>
|
|
49
|
+
<p style={{ marginTop: '8px', fontSize: '12px' }}>{size}px</p>
|
|
50
|
+
</div>
|
|
51
|
+
))}
|
|
52
|
+
</div>
|
|
53
|
+
),
|
|
54
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
|
|
3
|
+
import { theme } from '../../design_system/theme';
|
|
4
|
+
import { Box, type BoxProps } from '../box';
|
|
5
|
+
import { ActorAvatar, getActorAvatarBorderRadius } from './actor_avatar';
|
|
6
|
+
|
|
7
|
+
const BORDER_WIDTH = 1;
|
|
8
|
+
|
|
9
|
+
/** Computes border, padding, and radius dimensions for the bordered wrapper. */
|
|
10
|
+
const getBorderedStyle = (size: number) => {
|
|
11
|
+
const padding = size < 40 ? 2 : 3;
|
|
12
|
+
const outerRadius = getActorAvatarBorderRadius(size);
|
|
13
|
+
const innerRadius = Math.max(outerRadius - 3, 2);
|
|
14
|
+
const innerSize = Math.max(size - (BORDER_WIDTH + padding) * 2, 1);
|
|
15
|
+
|
|
16
|
+
return { padding, outerRadius, innerRadius, innerSize };
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
type StyledBorderProps = { $outerRadius: number; $padding: number };
|
|
20
|
+
|
|
21
|
+
const StyledBorder = styled(Box)<StyledBorderProps>`
|
|
22
|
+
display: inline-flex;
|
|
23
|
+
align-items: center;
|
|
24
|
+
justify-content: center;
|
|
25
|
+
border: ${BORDER_WIDTH}px solid ${theme.color.neutral.border};
|
|
26
|
+
border-radius: ${({ $outerRadius }) => $outerRadius}px;
|
|
27
|
+
padding: ${({ $padding }) => $padding}px;
|
|
28
|
+
overflow: hidden;
|
|
29
|
+
`;
|
|
30
|
+
|
|
31
|
+
type BorderedActorAvatarProps = BoxProps & {
|
|
32
|
+
name?: string;
|
|
33
|
+
url?: string | null;
|
|
34
|
+
size: 24 | 32 | 40 | 44;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export const BorderedActorAvatar = ({ size, name, url, ...rest }: BorderedActorAvatarProps) => {
|
|
38
|
+
const { padding, outerRadius, innerRadius, innerSize } = getBorderedStyle(size);
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<StyledBorder $outerRadius={outerRadius} $padding={padding} {...rest}>
|
|
42
|
+
<ActorAvatar size={innerSize} borderRadius={`${innerRadius}px`} name={name} url={url} />
|
|
43
|
+
</StyledBorder>
|
|
44
|
+
);
|
|
45
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { DropdownMenuContentProps } from '@radix-ui/react-dropdown-menu';
|
|
2
2
|
import type * as React from 'react';
|
|
3
3
|
|
|
4
4
|
export type BaseDropdownItemProps = {
|
|
@@ -14,5 +14,5 @@ export type BaseDropdownContentProps = {
|
|
|
14
14
|
height?: string;
|
|
15
15
|
closeOnSelect?: boolean;
|
|
16
16
|
zIndex?: number;
|
|
17
|
-
contentProps?:
|
|
17
|
+
contentProps?: DropdownMenuContentProps;
|
|
18
18
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { DropdownMenuContentProps } from '@radix-ui/react-dropdown-menu';
|
|
2
2
|
import clsx from 'clsx';
|
|
3
3
|
import type { ComponentPropsWithoutRef, ElementType, ReactNode } from 'react';
|
|
4
4
|
import { useRef, useState } from 'react';
|
|
@@ -32,8 +32,8 @@ export interface SplitButtonProps
|
|
|
32
32
|
/** Must contain at least two actions - a single action should just be a regular Button. */
|
|
33
33
|
actions: SplitButtonAction[];
|
|
34
34
|
label?: ReactNode;
|
|
35
|
-
side?:
|
|
36
|
-
align?:
|
|
35
|
+
side?: DropdownMenuContentProps['side'];
|
|
36
|
+
align?: DropdownMenuContentProps['align'];
|
|
37
37
|
width?: string;
|
|
38
38
|
showMainIcon?: boolean;
|
|
39
39
|
/** @deprecated Wrap `SplitButton` in `Tooltip` instead. */
|