@squiz/resource-browser 1.35.1-alpha.6 → 1.38.1-alpha.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 (164) hide show
  1. package/lib/Hooks/useChildResources.d.ts +1 -1
  2. package/lib/Hooks/useChildResources.js +2 -2
  3. package/lib/Hooks/useResource.js +2 -2
  4. package/lib/PreviewPanel/PreviewPanel.d.ts +5 -13
  5. package/lib/PreviewPanel/PreviewPanel.js +2 -53
  6. package/lib/PreviewPanel/details/MatrixResource.js +2 -2
  7. package/lib/ResourceBreadcrumb/ResourceBreadcrumb.js +2 -5
  8. package/lib/ResourceList/ResourceList.js +9 -15
  9. package/lib/ResourcePicker/ResourcePicker.js +2 -2
  10. package/lib/ResourcePicker/States/Error.js +3 -4
  11. package/lib/ResourcePicker/States/Loading.js +2 -2
  12. package/lib/ResourcePicker/States/Selected.js +3 -4
  13. package/lib/ResourcePickerContainer/ResourcePickerContainer.js +4 -3
  14. package/lib/SourceDropdown/SourceDropdown.js +9 -10
  15. package/lib/SourceList/SourceList.js +10 -13
  16. package/lib/index.css +3 -51
  17. package/package.json +4 -3
  18. package/src/Hooks/useChildResources.ts +1 -1
  19. package/src/Hooks/useResource.ts +1 -1
  20. package/src/Hooks/useSources.ts +1 -1
  21. package/src/PreviewPanel/PreviewPanel.tsx +3 -84
  22. package/src/PreviewPanel/details/MatrixResource.tsx +1 -1
  23. package/src/ResourceBreadcrumb/ResourceBreadcrumb.tsx +1 -1
  24. package/src/ResourceList/ResourceList.tsx +9 -18
  25. package/src/ResourcePicker/ResourcePicker.tsx +1 -1
  26. package/src/ResourcePicker/States/Error.tsx +1 -3
  27. package/src/ResourcePicker/States/Loading.tsx +1 -2
  28. package/src/ResourcePicker/States/Selected.tsx +1 -2
  29. package/src/ResourcePickerContainer/ResourcePickerContainer.spec.tsx +28 -0
  30. package/src/ResourcePickerContainer/ResourcePickerContainer.tsx +11 -9
  31. package/src/SourceDropdown/SourceDropdown.spec.tsx +5 -1
  32. package/src/SourceDropdown/SourceDropdown.tsx +2 -3
  33. package/src/SourceList/SourceList.tsx +16 -20
  34. package/src/index.scss +1 -3
  35. package/tailwind.config.cjs +6 -1
  36. package/vite.config.js +20 -0
  37. package/lib/Hooks/useAsync.d.ts +0 -21
  38. package/lib/Hooks/useAsync.js +0 -53
  39. package/lib/Icons/Generics/ArrowDown.d.ts +0 -15
  40. package/lib/Icons/Generics/ArrowDown.js +0 -23
  41. package/lib/Icons/Generics/ArrowRight.d.ts +0 -15
  42. package/lib/Icons/Generics/ArrowRight.js +0 -23
  43. package/lib/Icons/Generics/Back.d.ts +0 -4
  44. package/lib/Icons/Generics/Back.js +0 -12
  45. package/lib/Icons/Generics/Close.d.ts +0 -15
  46. package/lib/Icons/Generics/Close.js +0 -23
  47. package/lib/Icons/Generics/Empty.d.ts +0 -4
  48. package/lib/Icons/Generics/Empty.js +0 -12
  49. package/lib/Icons/Generics/Error.d.ts +0 -4
  50. package/lib/Icons/Generics/Error.js +0 -12
  51. package/lib/Icons/Generics/GenericIconMap.d.ts +0 -14
  52. package/lib/Icons/Generics/GenericIconMap.js +0 -18
  53. package/lib/Icons/Generics/ResourceSelect.d.ts +0 -15
  54. package/lib/Icons/Generics/ResourceSelect.js +0 -28
  55. package/lib/Icons/Generics/Retry.d.ts +0 -4
  56. package/lib/Icons/Generics/Retry.js +0 -12
  57. package/lib/Icons/Generics/Root.d.ts +0 -15
  58. package/lib/Icons/Generics/Root.js +0 -23
  59. package/lib/Icons/Generics/Selected.d.ts +0 -15
  60. package/lib/Icons/Generics/Selected.js +0 -23
  61. package/lib/Icons/Generics/index.d.ts +0 -10
  62. package/lib/Icons/Generics/index.js +0 -27
  63. package/lib/Icons/Icon.d.ts +0 -51
  64. package/lib/Icons/Icon.js +0 -42
  65. package/lib/Icons/MatrixResources/Audio.d.ts +0 -15
  66. package/lib/Icons/MatrixResources/Audio.js +0 -28
  67. package/lib/Icons/MatrixResources/Excel.d.ts +0 -15
  68. package/lib/Icons/MatrixResources/Excel.js +0 -27
  69. package/lib/Icons/MatrixResources/Folder.d.ts +0 -15
  70. package/lib/Icons/MatrixResources/Folder.js +0 -24
  71. package/lib/Icons/MatrixResources/GenericFile.d.ts +0 -15
  72. package/lib/Icons/MatrixResources/GenericFile.js +0 -28
  73. package/lib/Icons/MatrixResources/Image.d.ts +0 -15
  74. package/lib/Icons/MatrixResources/Image.js +0 -26
  75. package/lib/Icons/MatrixResources/MatrixResourceMap.d.ts +0 -15
  76. package/lib/Icons/MatrixResources/MatrixResourceMap.js +0 -19
  77. package/lib/Icons/MatrixResources/Page.d.ts +0 -15
  78. package/lib/Icons/MatrixResources/Page.js +0 -30
  79. package/lib/Icons/MatrixResources/Pdf.d.ts +0 -15
  80. package/lib/Icons/MatrixResources/Pdf.js +0 -31
  81. package/lib/Icons/MatrixResources/Powerpoint.d.ts +0 -15
  82. package/lib/Icons/MatrixResources/Powerpoint.js +0 -28
  83. package/lib/Icons/MatrixResources/Site.d.ts +0 -15
  84. package/lib/Icons/MatrixResources/Site.js +0 -30
  85. package/lib/Icons/MatrixResources/Video.d.ts +0 -15
  86. package/lib/Icons/MatrixResources/Video.js +0 -24
  87. package/lib/Icons/MatrixResources/Word.d.ts +0 -17
  88. package/lib/Icons/MatrixResources/Word.js +0 -28
  89. package/lib/Icons/MatrixResources/index.d.ts +0 -11
  90. package/lib/Icons/MatrixResources/index.js +0 -29
  91. package/lib/Modal/Modal.d.ts +0 -11
  92. package/lib/Modal/Modal.js +0 -46
  93. package/lib/Modal/ModalOpeningButton.d.ts +0 -10
  94. package/lib/Modal/ModalOpeningButton.js +0 -13
  95. package/lib/Modal/ModalTrigger.d.ts +0 -10
  96. package/lib/Modal/ModalTrigger.js +0 -25
  97. package/lib/PreviewPanel/PreviewModal.d.ts +0 -11
  98. package/lib/PreviewPanel/PreviewModal.js +0 -81
  99. package/lib/ResourceItem/ResourceItem.d.ts +0 -16
  100. package/lib/ResourceItem/ResourceItem.js +0 -28
  101. package/lib/ResourcePicker/ResetButton.d.ts +0 -5
  102. package/lib/ResourcePicker/ResetButton.js +0 -11
  103. package/lib/ResourceState/ResourceState.d.ts +0 -7
  104. package/lib/ResourceState/ResourceState.js +0 -16
  105. package/lib/Skeleton/List/SkeletonList.d.ts +0 -5
  106. package/lib/Skeleton/List/SkeletonList.js +0 -13
  107. package/lib/Skeleton/ListItem/SkeletonListItem.d.ts +0 -1
  108. package/lib/Skeleton/ListItem/SkeletonListItem.js +0 -15
  109. package/lib/Spinner/Spinner.d.ts +0 -8
  110. package/lib/Spinner/Spinner.js +0 -12
  111. package/src/Hooks/useAsync.spec.ts +0 -106
  112. package/src/Hooks/useAsync.ts +0 -62
  113. package/src/Icons/Generics/ArrowDown.tsx +0 -27
  114. package/src/Icons/Generics/ArrowRight.tsx +0 -27
  115. package/src/Icons/Generics/Back.tsx +0 -13
  116. package/src/Icons/Generics/Close.tsx +0 -26
  117. package/src/Icons/Generics/Empty.tsx +0 -13
  118. package/src/Icons/Generics/Error.tsx +0 -13
  119. package/src/Icons/Generics/GenericIconMap.ts +0 -18
  120. package/src/Icons/Generics/ResourceSelect.tsx +0 -40
  121. package/src/Icons/Generics/Retry.tsx +0 -13
  122. package/src/Icons/Generics/Root.tsx +0 -24
  123. package/src/Icons/Generics/Selected.tsx +0 -27
  124. package/src/Icons/Generics/index.tsx +0 -11
  125. package/src/Icons/Icon.spec.tsx +0 -62
  126. package/src/Icons/Icon.stories.tsx +0 -110
  127. package/src/Icons/Icon.tsx +0 -56
  128. package/src/Icons/MatrixResources/Audio.tsx +0 -30
  129. package/src/Icons/MatrixResources/Excel.tsx +0 -29
  130. package/src/Icons/MatrixResources/Folder.tsx +0 -29
  131. package/src/Icons/MatrixResources/GenericFile.tsx +0 -34
  132. package/src/Icons/MatrixResources/Image.tsx +0 -36
  133. package/src/Icons/MatrixResources/MatrixResourceMap.ts +0 -19
  134. package/src/Icons/MatrixResources/Page.tsx +0 -33
  135. package/src/Icons/MatrixResources/Pdf.tsx +0 -34
  136. package/src/Icons/MatrixResources/Powerpoint.tsx +0 -34
  137. package/src/Icons/MatrixResources/Site.tsx +0 -37
  138. package/src/Icons/MatrixResources/Video.tsx +0 -27
  139. package/src/Icons/MatrixResources/Word.tsx +0 -30
  140. package/src/Icons/MatrixResources/index.tsx +0 -12
  141. package/src/Modal/Modal.spec.tsx +0 -269
  142. package/src/Modal/Modal.tsx +0 -58
  143. package/src/Modal/ModalContainer.stories.tsx +0 -33
  144. package/src/Modal/ModalOpeningButton.tsx +0 -20
  145. package/src/Modal/ModalTrigger.tsx +0 -57
  146. package/src/PreviewPanel/PreviewModal.spec.tsx +0 -164
  147. package/src/PreviewPanel/PreviewModal.tsx +0 -92
  148. package/src/ResourceItem/ResourceItem.spec.tsx +0 -65
  149. package/src/ResourceItem/ResourceItem.tsx +0 -84
  150. package/src/ResourcePicker/ResetButton.tsx +0 -20
  151. package/src/ResourceState/ResourceState.spec.tsx +0 -26
  152. package/src/ResourceState/ResourceState.stories.tsx +0 -24
  153. package/src/ResourceState/ResourceState.tsx +0 -31
  154. package/src/Skeleton/List/SkeletonList.spec.tsx +0 -18
  155. package/src/Skeleton/List/SkeletonList.stories.tsx +0 -15
  156. package/src/Skeleton/List/SkeletonList.tsx +0 -16
  157. package/src/Skeleton/ListItem/SkeletonListItem.stories.tsx +0 -15
  158. package/src/Skeleton/ListItem/SkeletonListItem.tsx +0 -14
  159. package/src/Skeleton/_skeleton.scss +0 -15
  160. package/src/Spinner/Spinner.spec.tsx +0 -18
  161. package/src/Spinner/Spinner.stories.tsx +0 -26
  162. package/src/Spinner/Spinner.tsx +0 -18
  163. package/src/Spinner/_spinner.scss +0 -14
  164. /package/src/ResourceBreadcrumb/{ResourceBreadcrumb.scss → resource-breadcrumb.scss} +0 -0
@@ -1,65 +0,0 @@
1
- import React from 'react';
2
- import { render, fireEvent } from '@testing-library/react';
3
- import ResourceItem from './ResourceItem';
4
-
5
- const mockOnSelect = jest.fn();
6
- const mockOnDrillDown = jest.fn();
7
- const previewModalState = jest.fn();
8
-
9
- const defaultProps: any = {
10
- id: '123',
11
- selected: false,
12
- label: 'My Resource',
13
- type: 'site',
14
- childCount: 0,
15
- previewModalState: previewModalState,
16
- onSelect: mockOnSelect,
17
- onDrillDown: mockOnDrillDown,
18
- className: '',
19
- };
20
-
21
- describe('ResourceItem', () => {
22
- it('should render the component with the correct label', () => {
23
- const { getByText } = render(<ResourceItem {...defaultProps} />);
24
- const labelElement = getByText('My Resource');
25
-
26
- expect(labelElement).toBeInTheDocument();
27
- });
28
-
29
- it('should call the onSelect function when the button is pressed', () => {
30
- const { getByRole } = render(<ResourceItem {...defaultProps} />);
31
- const buttonElement = getByRole('button');
32
- fireEvent.click(buttonElement);
33
-
34
- expect(mockOnSelect).toHaveBeenCalledTimes(1);
35
- });
36
-
37
- it('should call the onDrillDown function when the drill down button is pressed', () => {
38
- const { getByLabelText } = render(<ResourceItem {...defaultProps} childCount={1} />);
39
- const drillDownButtonElement = getByLabelText('Drill down to My Resource children');
40
- fireEvent.click(drillDownButtonElement);
41
-
42
- expect(mockOnDrillDown).toHaveBeenCalledTimes(1);
43
- });
44
-
45
- it('should disable the button when the allowedTypes prop is not in the list of allowedItems', () => {
46
- const { getByRole } = render(<ResourceItem {...defaultProps} allowedTypes={['page']} />);
47
- const buttonElement = getByRole('button');
48
-
49
- expect(buttonElement).toBeDisabled();
50
- });
51
-
52
- it('should not disable the button when the allowedTypes prop is in the list of allowedItems', () => {
53
- const { getByRole } = render(<ResourceItem {...defaultProps} allowedTypes={['site']} />);
54
- const buttonElement = getByRole('button');
55
-
56
- expect(buttonElement).not.toBeDisabled();
57
- });
58
-
59
- it('should not disable the button when the allowedTypes is undefined', () => {
60
- const { getByRole } = render(<ResourceItem {...defaultProps} />);
61
- const buttonElement = getByRole('button');
62
-
63
- expect(buttonElement).not.toBeDisabled();
64
- });
65
- });
@@ -1,84 +0,0 @@
1
- import React from 'react';
2
- import { DOMAttributes, FocusableElement } from '@react-types/shared';
3
- import { useOverlayTrigger } from 'react-aria';
4
- import { OverlayTriggerState } from 'react-stately';
5
-
6
- import Icon, { IconOptions } from '../Icons/Icon';
7
- import ModalOpeningButton from '../Modal/ModalOpeningButton';
8
-
9
- interface ResourceItem<T> {
10
- item: T;
11
- selected?: boolean;
12
- label: string;
13
- type: string;
14
- childCount?: number;
15
- previewModalState: OverlayTriggerState;
16
- onSelect: (node: T, overlayProps: DOMAttributes<FocusableElement>) => void;
17
- onDrillDown?: (node: T) => void;
18
- className: string;
19
- allowedTypes?: string[] | undefined;
20
- }
21
-
22
- const ResourceItem = <T,>({
23
- item,
24
- selected,
25
- label,
26
- type,
27
- childCount,
28
- previewModalState,
29
- onSelect,
30
- onDrillDown,
31
- className,
32
- allowedTypes,
33
- }: ResourceItem<T>) => {
34
- const { triggerProps, overlayProps } = useOverlayTrigger({ type: 'dialog' }, previewModalState);
35
- const isDisabled = allowedTypes !== undefined && !allowedTypes.includes(type);
36
- const title = isDisabled ? "You can't select this item" : label;
37
-
38
- return (
39
- <li className={`flex items-stretch p-1 bg-white border-1 border-grey-200 min-h-[64px] ${className}`}>
40
- <ModalOpeningButton
41
- type="button"
42
- {...triggerProps}
43
- isDisabled={isDisabled}
44
- onPress={() => onSelect(item, overlayProps)}
45
- aria-label={childCount === undefined ? `Drill down to ${label} children` : ''}
46
- className={`
47
- relative grow flex items-center px-4 py-2 rounded outline-0 ${selected ? 'bg-blue-100 text-blue-400' : ''} ${
48
- childCount !== undefined && childCount > 0 ? 'mr-2' : ''
49
- } ${isDisabled ? 'font-normal text-gray-600 cursor-not-allowed' : 'hover:bg-gray-50 focus:bg-gray-50'}
50
- `}
51
- title={title}
52
- >
53
- <Icon
54
- icon={type as IconOptions}
55
- resourceSource="matrix"
56
- aria-label={type}
57
- className={`mr-4 shrink-0 ${isDisabled && 'opacity-40'}`}
58
- />
59
- <span className={`relative flex items-center ${selected ? 'mr-8' : ''}`}>
60
- <span className="line-clamp-2 text-left break-word">{label}</span>
61
- {selected && <Icon icon={'selected' as IconOptions} aria-label="selected" className="absolute -right-8" />}
62
- </span>
63
- {childCount === undefined && <Icon icon={'arrow-right' as IconOptions} className="absolute right-5" />}
64
- </ModalOpeningButton>
65
- {childCount !== undefined && childCount > 0 && onDrillDown && (
66
- <button
67
- type="button"
68
- aria-label={`Drill down to ${label} children`}
69
- onClick={() => onDrillDown(item)}
70
- className={`relative shrink-0 flex items-center p-4 rounded outline-0 before:w-px before:h-[calc(100%-0.75rem)] before:bg-gray-200 before:absolute before:top-1.5 before:-left-1 hover:bg-gray-50 focus:bg-gray-50`}
71
- >
72
- <span className="ml-auto flex items-center">
73
- <span className="truncate w-14 text-right" title={String(childCount)}>
74
- {childCount}
75
- </span>
76
- <Icon icon={'arrow-right' as IconOptions} className="ml-1" />
77
- </span>
78
- </button>
79
- )}
80
- </li>
81
- );
82
- };
83
-
84
- export default ResourceItem;
@@ -1,20 +0,0 @@
1
- import React from 'react';
2
- import CloseRoundedIcon from '@mui/icons-material/CloseRounded';
3
-
4
- export type ResetButtonProps = {
5
- onClick: () => void;
6
- isDisabled?: boolean;
7
- };
8
-
9
- export const ResetButton = ({ onClick, isDisabled }: ResetButtonProps) => (
10
- <button
11
- type="button"
12
- aria-label={`Remove selection`}
13
- title={`Remove selection`}
14
- className="text-gray-500 hover:text-gray-800 focus:text-gray-800 w-6 h-6 disabled:text-gray-500 disabled:cursor-not-allowed"
15
- disabled={isDisabled}
16
- onClick={onClick}
17
- >
18
- <CloseRoundedIcon />
19
- </button>
20
- );
@@ -1,26 +0,0 @@
1
- import React from 'react';
2
- import { render, fireEvent } from '@testing-library/react';
3
- import ResourceState from './ResourceState';
4
-
5
- const defaultProps: any = {
6
- state: 'error',
7
- message: 'This is a test error!',
8
- handleReload: jest.fn(),
9
- };
10
-
11
- describe('ResourceError', () => {
12
- it('should render the component with the correct error message', () => {
13
- const { getByText } = render(<ResourceState {...defaultProps} />);
14
- const errorMessage = getByText(defaultProps.message);
15
-
16
- expect(errorMessage).toBeInTheDocument();
17
- });
18
-
19
- it('should call the reload function when the button is pressed', () => {
20
- const { getByRole } = render(<ResourceState {...defaultProps} />);
21
- const buttonElement = getByRole('button');
22
- fireEvent.click(buttonElement);
23
-
24
- expect(defaultProps.handleReload).toHaveBeenCalledTimes(1);
25
- });
26
- });
@@ -1,24 +0,0 @@
1
- import React from 'react';
2
- import { StoryFn, Meta } from '@storybook/react';
3
-
4
- import ResourceState from './ResourceState';
5
-
6
- export default {
7
- title: 'Resource State',
8
- component: ResourceState,
9
- } as Meta<typeof ResourceState>;
10
-
11
- const Template: StoryFn<typeof ResourceState> = ({ state, message }) => (
12
- <ResourceState state={state} message={message} handleReload={() => alert('Resource browser reload')} />
13
- );
14
-
15
- export const Error = Template.bind({});
16
- Error.args = {
17
- state: 'error',
18
- message: 'This is a resource browser error!',
19
- };
20
-
21
- export const Empty = Template.bind({});
22
- Empty.args = {
23
- state: 'empty',
24
- };
@@ -1,31 +0,0 @@
1
- import React from 'react';
2
- import Icon, { IconOptions } from '../Icons/Icon';
3
-
4
- interface ResourceState {
5
- state: 'error' | 'empty';
6
- message?: string;
7
- handleReload: () => void;
8
- }
9
-
10
- const ResourceState = function ({ state, message, handleReload }: ResourceState) {
11
- return (
12
- <div className="flex flex-col items-center rounded-lg py-8 bg-white h-204 gap-3">
13
- <Icon icon={state as IconOptions} aria-hidden />
14
- {/* Message */}
15
- <span className="text-md text-gray-800 font-semibold leading-5">
16
- {state === 'empty' ? 'There are no items to display' : message}
17
- </span>
18
- {/* Retry button */}
19
- <button
20
- type="button"
21
- onClick={handleReload}
22
- className="flex flex-row items-center justify-center gap-3 bg-black bg-opacity-10 h-9 mt-3 rounded text-md font-bold text-gray-700 py-2 px-3"
23
- >
24
- <Icon icon={state === 'empty' ? 'back' : 'retry'} aria-hidden />
25
- {state === 'empty' ? 'Back to source list' : 'Try again'}
26
- </button>
27
- </div>
28
- );
29
- };
30
-
31
- export default ResourceState;
@@ -1,18 +0,0 @@
1
- import React from 'react';
2
- import { screen, render } from '@testing-library/react';
3
-
4
- import { SkeletonList } from './SkeletonList';
5
-
6
- describe('SkeletonList', () => {
7
- it('Should render the skeleton list', async () => {
8
- render(<SkeletonList itemCount={17} />);
9
-
10
- expect(screen.getByLabelText('Skeleton loader list')).toBeInTheDocument();
11
- });
12
-
13
- it('Should list out the amount of items we set as the count', async () => {
14
- render(<SkeletonList itemCount={5} />);
15
-
16
- expect(screen.getAllByRole('listitem')).toHaveLength(5);
17
- });
18
- });
@@ -1,15 +0,0 @@
1
- import React from 'react';
2
- import { StoryFn, Meta } from '@storybook/react';
3
-
4
- import { SkeletonList, SkeletonListProps } from './SkeletonList';
5
-
6
- export default {
7
- title: 'Global/Skeleton/List',
8
- component: SkeletonList,
9
- } as Meta<typeof SkeletonList>;
10
-
11
- const Template: StoryFn<SkeletonListProps> = (args: SkeletonListProps) => <SkeletonList {...args} />;
12
-
13
- export const Default = Template.bind({});
14
-
15
- Default.args = {};
@@ -1,16 +0,0 @@
1
- import React from 'react';
2
- import { SkeletonListItem } from '../ListItem/SkeletonListItem';
3
- import clsx from 'clsx';
4
-
5
- export type SkeletonListProps = {
6
- itemCount: number;
7
- className?: string;
8
- };
9
-
10
- export const SkeletonList = ({ itemCount = 8, className }: SkeletonListProps) => (
11
- <ul className={clsx(`flex flex-col px-7 my-4`, className)} aria-label="Skeleton loader list">
12
- {[...Array(itemCount)].map((_item, index: number) => {
13
- return <SkeletonListItem key={index} />;
14
- })}
15
- </ul>
16
- );
@@ -1,15 +0,0 @@
1
- import React from 'react';
2
- import { StoryFn, Meta } from '@storybook/react';
3
-
4
- import { SkeletonListItem } from './SkeletonListItem';
5
-
6
- export default {
7
- title: 'Global/Skeleton/List item',
8
- component: SkeletonListItem,
9
- } as Meta<typeof SkeletonListItem>;
10
-
11
- const Template: StoryFn<typeof SkeletonListItem> = () => <SkeletonListItem />;
12
-
13
- export const Default = Template.bind({});
14
-
15
- Default.args = {};
@@ -1,14 +0,0 @@
1
- import React from 'react';
2
-
3
- export const SkeletonListItem = () => (
4
- <li className="flex items-center p-1 first:mt-0 bg-white border-1 border-b-0 border-grey-200 first:rounded-t-lg last:rounded-b-lg last:border-b">
5
- <div className="animate-skeleton-pulse grid grid-cols-[24px_1fr_45px] w-full flex items-center p-4 rounded">
6
- <span className="w-6 h-6 bg-gray-200 rounded-full" />
7
- <div className="w-full d-flex flex-col mx-4">
8
- <div className="mb-1 w-3/4 h-2 bg-gray-200 rounded" />
9
- <div className="w-1/2 h-2 bg-gray-200 rounded" />
10
- </div>
11
- <div className="ml-auto mx-4 w-12 h-2 bg-gray-200 rounded" />
12
- </div>
13
- </li>
14
- );
@@ -1,15 +0,0 @@
1
- .animate-skeleton-pulse {
2
- animation: pulse 2s linear infinite;
3
-
4
- @keyframes pulse {
5
- 0% {
6
- opacity: 1;
7
- }
8
- 50% {
9
- opacity: 0.45;
10
- }
11
- 100% {
12
- opacity: 1;
13
- }
14
- }
15
- }
@@ -1,18 +0,0 @@
1
- import React from 'react';
2
- import { screen, render } from '@testing-library/react';
3
-
4
- import Spinner from './Spinner';
5
-
6
- describe('Spinner', () => {
7
- it('Should render the spinner', async () => {
8
- render(<Spinner />);
9
-
10
- expect(screen.getByLabelText('Loading')).toBeInTheDocument();
11
- });
12
-
13
- it('Should render the loading spinner with the custom aria label', async () => {
14
- render(<Spinner label="Loading sources" />);
15
-
16
- expect(screen.getByLabelText('Loading sources')).toBeInTheDocument();
17
- });
18
- });
@@ -1,26 +0,0 @@
1
- import React from 'react';
2
- import { StoryFn, Meta } from '@storybook/react';
3
-
4
- import Spinner, { SpinnerProps } from './Spinner';
5
-
6
- export default {
7
- title: 'Global/Spinner',
8
- component: Spinner,
9
- } as Meta<typeof Spinner>;
10
-
11
- const Template: StoryFn<SpinnerProps> = (args: SpinnerProps) => <Spinner {...args} />;
12
-
13
- export const Default = Template.bind({});
14
- Default.args = {};
15
-
16
- export const Large = Template.bind({});
17
- Large.args = {
18
- ...Default.args,
19
- size: 'md',
20
- };
21
-
22
- export const Custom = Template.bind({});
23
- Custom.args = {
24
- ...Default.args,
25
- className: 'text-blue-300 m-3',
26
- };
@@ -1,18 +0,0 @@
1
- import React, { ReactElement } from 'react';
2
- import clsx from 'clsx';
3
-
4
- export type SpinnerProps = {
5
- size?: 'sm' | 'md';
6
- className?: string;
7
- label?: string;
8
- };
9
-
10
- const Spinner = ({ size = 'sm', className, label = 'Loading' }: SpinnerProps): ReactElement => {
11
- return (
12
- <div className="spinner__wrapper text-gray-600" aria-label={label}>
13
- <div className={clsx('spinner', size && `spinner--${size}`, className)} role="status" />
14
- </div>
15
- );
16
- };
17
-
18
- export default Spinner;
@@ -1,14 +0,0 @@
1
- .spinner {
2
- @apply inline-block rounded-full;
3
- @apply border-2 border-solid border-current border-r-transparent;
4
- @apply animate-spin align-[-0.125em] motion-reduce:animate-[spin_1.5s_linear_infinite];
5
- height: 20px;
6
- width: 20px;
7
- &__wrapper {
8
- @apply flex items-center justify-center;
9
- }
10
- &--md {
11
- height: 32px;
12
- width: 32px;
13
- }
14
- }