@apify/ui-library 1.99.0 → 1.99.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/button.d.ts +6 -2
- package/dist/src/components/button.d.ts.map +1 -1
- package/dist/src/components/button.js +35 -8
- package/dist/src/components/button.js.map +1 -1
- package/dist/src/components/button.stories.d.ts +6 -0
- package/dist/src/components/button.stories.d.ts.map +1 -0
- package/dist/src/components/button.stories.js +46 -0
- package/dist/src/components/button.stories.js.map +1 -0
- package/dist/src/components/icon_button.d.ts +55 -0
- package/dist/src/components/icon_button.d.ts.map +1 -0
- package/dist/src/components/icon_button.js +134 -0
- package/dist/src/components/icon_button.js.map +1 -0
- package/dist/src/components/icon_button.stories.d.ts +36 -0
- package/dist/src/components/icon_button.stories.d.ts.map +1 -0
- package/dist/src/components/icon_button.stories.js +59 -0
- package/dist/src/components/icon_button.stories.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/spinner.d.ts +32 -0
- package/dist/src/components/spinner.d.ts.map +1 -0
- package/dist/src/components/spinner.js +84 -0
- package/dist/src/components/spinner.js.map +1 -0
- package/dist/src/components/spinner.stories.d.ts +8 -0
- package/dist/src/components/spinner.stories.d.ts.map +1 -0
- package/dist/src/components/spinner.stories.js +24 -0
- package/dist/src/components/spinner.stories.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/components/{button.stories.jsx → button.stories.tsx} +26 -11
- package/src/components/button.tsx +43 -11
- package/src/components/icon_button.stories.tsx +251 -0
- package/src/components/icon_button.tsx +211 -0
- package/src/components/index.ts +2 -0
- package/src/components/spinner.stories.tsx +37 -0
- package/src/components/spinner.tsx +116 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { Meta } from '@storybook/react-vite';
|
|
2
|
+
|
|
3
|
+
import { InlineSpinner, Spinner, type SpinnerProps } from './spinner.js';
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
title: 'UI-Library/Spinner',
|
|
7
|
+
parameters: { layout: 'padded' },
|
|
8
|
+
component: Spinner,
|
|
9
|
+
args: {},
|
|
10
|
+
} as Meta<typeof Spinner>;
|
|
11
|
+
|
|
12
|
+
const Template = (args: SpinnerProps) => <Spinner {...args} />;
|
|
13
|
+
|
|
14
|
+
export const Standalone = Template.bind({});
|
|
15
|
+
|
|
16
|
+
export const WithinContainer = (args: SpinnerProps) => {
|
|
17
|
+
return (
|
|
18
|
+
<div style={{
|
|
19
|
+
minWidth: '100px',
|
|
20
|
+
minHeight: '200px',
|
|
21
|
+
border: 'solid 1px lightgray',
|
|
22
|
+
borderRadius: '1rem',
|
|
23
|
+
position: 'relative',
|
|
24
|
+
}}>
|
|
25
|
+
<Spinner {...args} />
|
|
26
|
+
</div>
|
|
27
|
+
);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export const Inline = () => {
|
|
31
|
+
const elements: React.ElementType[] = ['h1', 'h2', 'h3', 'p'];
|
|
32
|
+
return (
|
|
33
|
+
<div style={{ width: '100%' }}>
|
|
34
|
+
{elements.map((Element) => <Element key={Element}>{Element}: There was a <InlineSpinner /> in New Orleans.</Element>)}
|
|
35
|
+
</div>
|
|
36
|
+
);
|
|
37
|
+
};
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import styled, { keyframes } from 'styled-components';
|
|
2
|
+
|
|
3
|
+
import { theme } from '../design_system/theme.js';
|
|
4
|
+
import type { WithTransientProps } from '../type_utils.js';
|
|
5
|
+
|
|
6
|
+
export const spinnerClassNames = {
|
|
7
|
+
SPINNER: 'spinner',
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const rotate = keyframes`
|
|
11
|
+
100% {
|
|
12
|
+
transform: rotate(360deg);
|
|
13
|
+
}
|
|
14
|
+
`;
|
|
15
|
+
|
|
16
|
+
const dash = keyframes`
|
|
17
|
+
0% {
|
|
18
|
+
stroke-dasharray: 1, 150;
|
|
19
|
+
stroke-dashoffset: 0;
|
|
20
|
+
}
|
|
21
|
+
50% {
|
|
22
|
+
stroke-dasharray: 90, 150;
|
|
23
|
+
stroke-dashoffset: -35;
|
|
24
|
+
}
|
|
25
|
+
100% {
|
|
26
|
+
stroke-dasharray: 90, 150;
|
|
27
|
+
stroke-dashoffset: -124;
|
|
28
|
+
}
|
|
29
|
+
`;
|
|
30
|
+
|
|
31
|
+
export type SpinnerProps = {
|
|
32
|
+
id?: string;
|
|
33
|
+
as?: React.ElementType;
|
|
34
|
+
className?: string;
|
|
35
|
+
style?: React.CSSProperties;
|
|
36
|
+
small?: boolean,
|
|
37
|
+
loadingReason?: string,
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
type SpinnerWrapperProps = WithTransientProps<Pick<SpinnerProps, 'small'>>;
|
|
41
|
+
|
|
42
|
+
// styled-components used in order to make 'as' prop work by default
|
|
43
|
+
// span is intentional instead of div, so it can be validly nested in a <p>
|
|
44
|
+
// display: block is used because it was div before and we don't wanna break anything
|
|
45
|
+
const SpinnerWrapper = styled.span<SpinnerWrapperProps>`
|
|
46
|
+
display: block;
|
|
47
|
+
|
|
48
|
+
.${spinnerClassNames.SPINNER} {
|
|
49
|
+
position: absolute;
|
|
50
|
+
top: 50%;
|
|
51
|
+
left: 50%;
|
|
52
|
+
transform: translate(-50%, -50%);
|
|
53
|
+
z-index: 2;
|
|
54
|
+
|
|
55
|
+
width: ${({ $small }) => ($small ? '3rem' : '5rem')};
|
|
56
|
+
height: ${({ $small }) => ($small ? '3rem' : '5rem')};
|
|
57
|
+
|
|
58
|
+
& .path {
|
|
59
|
+
transform-origin: center;
|
|
60
|
+
stroke: ${theme.color.primary.text};
|
|
61
|
+
animation: ${dash} 1.5s ease-in-out infinite, ${rotate} 2s linear infinite;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
`;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Visualize loading state of a component.
|
|
68
|
+
*
|
|
69
|
+
* Use this spinner when a page or section is waiting for asynchronous data.
|
|
70
|
+
* Do not use it for buttons and small components, apply only for bigger sections.
|
|
71
|
+
*
|
|
72
|
+
* Keep the spinner centered (eg. by setting position to parent container).
|
|
73
|
+
*/
|
|
74
|
+
export const Spinner = ({ loadingReason, small, ...props }: SpinnerProps) => {
|
|
75
|
+
return (
|
|
76
|
+
<SpinnerWrapper {...props} title={loadingReason} $small={small}>
|
|
77
|
+
<svg className={spinnerClassNames.SPINNER} viewBox="0 0 50 50">
|
|
78
|
+
<circle
|
|
79
|
+
className="path"
|
|
80
|
+
cx="25"
|
|
81
|
+
cy="25"
|
|
82
|
+
r="20"
|
|
83
|
+
fill="none"
|
|
84
|
+
strokeWidth="5"
|
|
85
|
+
strokeLinecap="round"
|
|
86
|
+
></circle>
|
|
87
|
+
</svg>
|
|
88
|
+
</SpinnerWrapper>
|
|
89
|
+
);
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Spinner with basic block styling
|
|
94
|
+
* This styles should probably be in default spinner, but it's dangerous to modify it as it's used on so many places
|
|
95
|
+
*/
|
|
96
|
+
export const BlockSpinner = styled(Spinner)`
|
|
97
|
+
position: relative; /* "hold" absolutely positioned spinner */
|
|
98
|
+
width: 100%;
|
|
99
|
+
min-height: 8rem;
|
|
100
|
+
`;
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Use the inline variant within buttons, texts etc. The color of the spinner is set to current color of text.
|
|
104
|
+
*/
|
|
105
|
+
export const InlineSpinner = styled(Spinner)<{size?: string}>`
|
|
106
|
+
display: inline-block;
|
|
107
|
+
position: relative;
|
|
108
|
+
height: ${({ size }) => size || theme.space.space12};
|
|
109
|
+
width: ${({ size }) => size || theme.space.space12};
|
|
110
|
+
vertical-align: middle;
|
|
111
|
+
|
|
112
|
+
.${spinnerClassNames.SPINNER} {
|
|
113
|
+
width: 100%;
|
|
114
|
+
height: 100%;
|
|
115
|
+
}
|
|
116
|
+
`;
|