@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.
Files changed (37) hide show
  1. package/dist/src/components/button.d.ts +6 -2
  2. package/dist/src/components/button.d.ts.map +1 -1
  3. package/dist/src/components/button.js +35 -8
  4. package/dist/src/components/button.js.map +1 -1
  5. package/dist/src/components/button.stories.d.ts +6 -0
  6. package/dist/src/components/button.stories.d.ts.map +1 -0
  7. package/dist/src/components/button.stories.js +46 -0
  8. package/dist/src/components/button.stories.js.map +1 -0
  9. package/dist/src/components/icon_button.d.ts +55 -0
  10. package/dist/src/components/icon_button.d.ts.map +1 -0
  11. package/dist/src/components/icon_button.js +134 -0
  12. package/dist/src/components/icon_button.js.map +1 -0
  13. package/dist/src/components/icon_button.stories.d.ts +36 -0
  14. package/dist/src/components/icon_button.stories.d.ts.map +1 -0
  15. package/dist/src/components/icon_button.stories.js +59 -0
  16. package/dist/src/components/icon_button.stories.js.map +1 -0
  17. package/dist/src/components/index.d.ts +2 -0
  18. package/dist/src/components/index.d.ts.map +1 -1
  19. package/dist/src/components/index.js +2 -0
  20. package/dist/src/components/index.js.map +1 -1
  21. package/dist/src/components/spinner.d.ts +32 -0
  22. package/dist/src/components/spinner.d.ts.map +1 -0
  23. package/dist/src/components/spinner.js +84 -0
  24. package/dist/src/components/spinner.js.map +1 -0
  25. package/dist/src/components/spinner.stories.d.ts +8 -0
  26. package/dist/src/components/spinner.stories.d.ts.map +1 -0
  27. package/dist/src/components/spinner.stories.js +24 -0
  28. package/dist/src/components/spinner.stories.js.map +1 -0
  29. package/dist/tsconfig.build.tsbuildinfo +1 -1
  30. package/package.json +2 -2
  31. package/src/components/{button.stories.jsx → button.stories.tsx} +26 -11
  32. package/src/components/button.tsx +43 -11
  33. package/src/components/icon_button.stories.tsx +251 -0
  34. package/src/components/icon_button.tsx +211 -0
  35. package/src/components/index.ts +2 -0
  36. package/src/components/spinner.stories.tsx +37 -0
  37. package/src/components/spinner.tsx +116 -0
@@ -0,0 +1,84 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import styled, { keyframes } from 'styled-components';
3
+ import { theme } from '../design_system/theme.js';
4
+ export const spinnerClassNames = {
5
+ SPINNER: 'spinner',
6
+ };
7
+ const rotate = keyframes `
8
+ 100% {
9
+ transform: rotate(360deg);
10
+ }
11
+ `;
12
+ const dash = keyframes `
13
+ 0% {
14
+ stroke-dasharray: 1, 150;
15
+ stroke-dashoffset: 0;
16
+ }
17
+ 50% {
18
+ stroke-dasharray: 90, 150;
19
+ stroke-dashoffset: -35;
20
+ }
21
+ 100% {
22
+ stroke-dasharray: 90, 150;
23
+ stroke-dashoffset: -124;
24
+ }
25
+ `;
26
+ // styled-components used in order to make 'as' prop work by default
27
+ // span is intentional instead of div, so it can be validly nested in a <p>
28
+ // display: block is used because it was div before and we don't wanna break anything
29
+ const SpinnerWrapper = styled.span `
30
+ display: block;
31
+
32
+ .${spinnerClassNames.SPINNER} {
33
+ position: absolute;
34
+ top: 50%;
35
+ left: 50%;
36
+ transform: translate(-50%, -50%);
37
+ z-index: 2;
38
+
39
+ width: ${({ $small }) => ($small ? '3rem' : '5rem')};
40
+ height: ${({ $small }) => ($small ? '3rem' : '5rem')};
41
+
42
+ & .path {
43
+ transform-origin: center;
44
+ stroke: ${theme.color.primary.text};
45
+ animation: ${dash} 1.5s ease-in-out infinite, ${rotate} 2s linear infinite;
46
+ }
47
+ }
48
+ `;
49
+ /**
50
+ * Visualize loading state of a component.
51
+ *
52
+ * Use this spinner when a page or section is waiting for asynchronous data.
53
+ * Do not use it for buttons and small components, apply only for bigger sections.
54
+ *
55
+ * Keep the spinner centered (eg. by setting position to parent container).
56
+ */
57
+ export const Spinner = ({ loadingReason, small, ...props }) => {
58
+ return (_jsx(SpinnerWrapper, { ...props, title: loadingReason, "$small": small, children: _jsx("svg", { className: spinnerClassNames.SPINNER, viewBox: "0 0 50 50", children: _jsx("circle", { className: "path", cx: "25", cy: "25", r: "20", fill: "none", strokeWidth: "5", strokeLinecap: "round" }) }) }));
59
+ };
60
+ /**
61
+ * Spinner with basic block styling
62
+ * This styles should probably be in default spinner, but it's dangerous to modify it as it's used on so many places
63
+ */
64
+ export const BlockSpinner = styled(Spinner) `
65
+ position: relative; /* "hold" absolutely positioned spinner */
66
+ width: 100%;
67
+ min-height: 8rem;
68
+ `;
69
+ /**
70
+ * Use the inline variant within buttons, texts etc. The color of the spinner is set to current color of text.
71
+ */
72
+ export const InlineSpinner = styled(Spinner) `
73
+ display: inline-block;
74
+ position: relative;
75
+ height: ${({ size }) => size || theme.space.space12};
76
+ width: ${({ size }) => size || theme.space.space12};
77
+ vertical-align: middle;
78
+
79
+ .${spinnerClassNames.SPINNER} {
80
+ width: 100%;
81
+ height: 100%;
82
+ }
83
+ `;
84
+ //# sourceMappingURL=spinner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spinner.js","sourceRoot":"","sources":["../../../src/components/spinner.tsx"],"names":[],"mappings":";AAAA,OAAO,MAAM,EAAE,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEtD,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAGlD,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC7B,OAAO,EAAE,SAAS;CACrB,CAAC;AAEF,MAAM,MAAM,GAAG,SAAS,CAAA;;;;CAIvB,CAAC;AAEF,MAAM,IAAI,GAAG,SAAS,CAAA;;;;;;;;;;;;;CAarB,CAAC;AAaF,oEAAoE;AACpE,2EAA2E;AAC3E,qFAAqF;AACrF,MAAM,cAAc,GAAG,MAAM,CAAC,IAAI,CAAqB;;;OAGhD,iBAAiB,CAAC,OAAO;;;;;;;iBAOf,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC;kBACzC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC;;;;sBAItC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI;yBACrB,IAAI,+BAA+B,MAAM;;;CAGjE,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,EAAE,aAAa,EAAE,KAAK,EAAE,GAAG,KAAK,EAAgB,EAAE,EAAE;IACxE,OAAO,CACH,KAAC,cAAc,OAAK,KAAK,EAAE,KAAK,EAAE,aAAa,YAAU,KAAK,YAC1D,cAAK,SAAS,EAAE,iBAAiB,CAAC,OAAO,EAAE,OAAO,EAAC,WAAW,YAC1D,iBACI,SAAS,EAAC,MAAM,EAChB,EAAE,EAAC,IAAI,EACP,EAAE,EAAC,IAAI,EACP,CAAC,EAAC,IAAI,EACN,IAAI,EAAC,MAAM,EACX,WAAW,EAAC,GAAG,EACf,aAAa,EAAC,OAAO,GACf,GACR,GACO,CACpB,CAAC;AACN,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC,OAAO,CAAC,CAAA;;;;CAI1C,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC,OAAO,CAAC,CAAiB;;;cAG/C,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,IAAI,KAAK,CAAC,KAAK,CAAC,OAAO;aAC1C,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,IAAI,KAAK,CAAC,KAAK,CAAC,OAAO;;;OAG/C,iBAAiB,CAAC,OAAO;;;;CAI/B,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type { Meta } from '@storybook/react-vite';
2
+ import { Spinner, type SpinnerProps } from './spinner.js';
3
+ declare const _default: Meta<typeof Spinner>;
4
+ export default _default;
5
+ export declare const Standalone: (args: SpinnerProps) => import("react/jsx-runtime").JSX.Element;
6
+ export declare const WithinContainer: (args: SpinnerProps) => import("react/jsx-runtime").JSX.Element;
7
+ export declare const Inline: () => import("react/jsx-runtime").JSX.Element;
8
+ //# sourceMappingURL=spinner.stories.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spinner.stories.d.ts","sourceRoot":"","sources":["../../../src/components/spinner.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAElD,OAAO,EAAiB,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC;wBAOpE,IAAI,CAAC,OAAO,OAAO,CAAC;AALzB,wBAK0B;AAI1B,eAAO,MAAM,UAAU,SAFC,YAAY,4CAEO,CAAC;AAE5C,eAAO,MAAM,eAAe,SAAU,YAAY,4CAYjD,CAAC;AAEF,eAAO,MAAM,MAAM,+CAOlB,CAAC"}
@@ -0,0 +1,24 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { InlineSpinner, Spinner } from './spinner.js';
3
+ export default {
4
+ title: 'UI-Library/Spinner',
5
+ parameters: { layout: 'padded' },
6
+ component: Spinner,
7
+ args: {},
8
+ };
9
+ const Template = (args) => _jsx(Spinner, { ...args });
10
+ export const Standalone = Template.bind({});
11
+ export const WithinContainer = (args) => {
12
+ return (_jsx("div", { style: {
13
+ minWidth: '100px',
14
+ minHeight: '200px',
15
+ border: 'solid 1px lightgray',
16
+ borderRadius: '1rem',
17
+ position: 'relative',
18
+ }, children: _jsx(Spinner, { ...args }) }));
19
+ };
20
+ export const Inline = () => {
21
+ const elements = ['h1', 'h2', 'h3', 'p'];
22
+ return (_jsx("div", { style: { width: '100%' }, children: elements.map((Element) => _jsxs(Element, { children: [Element, ": There was a ", _jsx(InlineSpinner, {}), " in New Orleans."] }, Element)) }));
23
+ };
24
+ //# sourceMappingURL=spinner.stories.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spinner.stories.js","sourceRoot":"","sources":["../../../src/components/spinner.stories.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,aAAa,EAAE,OAAO,EAAqB,MAAM,cAAc,CAAC;AAEzE,eAAe;IACX,KAAK,EAAE,oBAAoB;IAC3B,UAAU,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE;IAChC,SAAS,EAAE,OAAO;IAClB,IAAI,EAAE,EAAE;CACa,CAAC;AAE1B,MAAM,QAAQ,GAAG,CAAC,IAAkB,EAAE,EAAE,CAAC,KAAC,OAAO,OAAK,IAAI,GAAI,CAAC;AAE/D,MAAM,CAAC,MAAM,UAAU,GAAG,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAE5C,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,IAAkB,EAAE,EAAE;IAClD,OAAO,CACH,cAAK,KAAK,EAAE;YACR,QAAQ,EAAE,OAAO;YACjB,SAAS,EAAE,OAAO;YAClB,MAAM,EAAE,qBAAqB;YAC7B,YAAY,EAAE,MAAM;YACpB,QAAQ,EAAE,UAAU;SACvB,YACG,KAAC,OAAO,OAAK,IAAI,GAAI,GACnB,CACT,CAAC;AACN,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,EAAE;IACvB,MAAM,QAAQ,GAAwB,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC;IAC9D,OAAO,CACH,cAAK,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,YACxB,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,MAAC,OAAO,eAAgB,OAAO,oBAAe,KAAC,aAAa,KAAG,yBAAjD,OAAO,CAAoE,CAAC,GACnH,CACT,CAAC;AACN,CAAC,CAAC"}