@lnco-ai/ui 1.0.0
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/CHANGELOG.md +1323 -0
- package/LICENSE +661 -0
- package/README.md +60 -0
- package/dist/Authorization/PreventGuestWrapper.d.ts +19 -0
- package/dist/Authorization/PreventGuestWrapper.js +15 -0
- package/dist/Authorization/RedirectionContent.d.ts +9 -0
- package/dist/Authorization/RedirectionContent.js +24 -0
- package/dist/Authorization/SignedInWrapper.d.ts +10 -0
- package/dist/Authorization/SignedInWrapper.js +21 -0
- package/dist/Avatar/Avatar.d.ts +24 -0
- package/dist/Avatar/Avatar.js +22 -0
- package/dist/Avatar/stringToColor.d.ts +12 -0
- package/dist/Avatar/stringToColor.js +31 -0
- package/dist/Avatar/stringToColor.test.d.ts +1 -0
- package/dist/Avatar/stringToColor.test.js +8 -0
- package/dist/Card/Card.d.ts +39 -0
- package/dist/Card/Card.js +76 -0
- package/dist/Card/CardHeader.d.ts +12 -0
- package/dist/Card/CardHeader.js +8 -0
- package/dist/Card/CardThumbnail.d.ts +10 -0
- package/dist/Card/CardThumbnail.js +14 -0
- package/dist/Card/FolderCard.d.ts +14 -0
- package/dist/Card/FolderCard.js +44 -0
- package/dist/Card/LinkCard.d.ts +11 -0
- package/dist/Card/LinkCard.js +41 -0
- package/dist/Card/components/CardThumbnail.d.ts +8 -0
- package/dist/Card/components/CardThumbnail.js +15 -0
- package/dist/Card/constants.d.ts +1 -0
- package/dist/Card/constants.js +1 -0
- package/dist/Collapse/Collapse.d.ts +10 -0
- package/dist/Collapse/Collapse.js +48 -0
- package/dist/Collapse/withCollapse.d.ts +7 -0
- package/dist/Collapse/withCollapse.js +8 -0
- package/dist/CookiesBanner/CookiesBanner.d.ts +10 -0
- package/dist/CookiesBanner/CookiesBanner.js +60 -0
- package/dist/CreativeCommons/CreativeCommons.d.ts +14 -0
- package/dist/CreativeCommons/CreativeCommons.js +75 -0
- package/dist/CreativeCommons/icons/By.d.ts +3 -0
- package/dist/CreativeCommons/icons/By.js +3 -0
- package/dist/CreativeCommons/icons/CCIconsProps.d.ts +3 -0
- package/dist/CreativeCommons/icons/CCIconsProps.js +1 -0
- package/dist/CreativeCommons/icons/Cc.d.ts +3 -0
- package/dist/CreativeCommons/icons/Cc.js +3 -0
- package/dist/CreativeCommons/icons/Cc0.d.ts +3 -0
- package/dist/CreativeCommons/icons/Cc0.js +3 -0
- package/dist/CreativeCommons/icons/Nc.d.ts +3 -0
- package/dist/CreativeCommons/icons/Nc.js +3 -0
- package/dist/CreativeCommons/icons/Nd.d.ts +3 -0
- package/dist/CreativeCommons/icons/Nd.js +3 -0
- package/dist/CreativeCommons/icons/Sa.d.ts +3 -0
- package/dist/CreativeCommons/icons/Sa.js +3 -0
- package/dist/CustomInitialLoader/CustomInitialLoader.d.ts +5 -0
- package/dist/CustomInitialLoader/CustomInitialLoader.js +25 -0
- package/dist/DrawerHeader/DrawerHeader.d.ts +7 -0
- package/dist/DrawerHeader/DrawerHeader.js +16 -0
- package/dist/GraaspLogo/EpflLogo.d.ts +5 -0
- package/dist/GraaspLogo/EpflLogo.js +3 -0
- package/dist/GraaspLogo/GraaspLogo.d.ts +8 -0
- package/dist/GraaspLogo/GraaspLogo.js +5 -0
- package/dist/Header/Header.d.ts +21 -0
- package/dist/Header/Header.js +33 -0
- package/dist/HeaderUserInformation/HeaderUserInformation.d.ts +22 -0
- package/dist/HeaderUserInformation/HeaderUserInformation.js +23 -0
- package/dist/ItemBadges/ItemBadges.d.ts +17 -0
- package/dist/ItemBadges/ItemBadges.js +10 -0
- package/dist/ItemFlag/ItemFlagButton.d.ts +9 -0
- package/dist/ItemFlag/ItemFlagButton.js +11 -0
- package/dist/ItemFlag/ItemFlagDialog.d.ts +14 -0
- package/dist/ItemFlag/ItemFlagDialog.js +25 -0
- package/dist/Loader/Loader.d.ts +7 -0
- package/dist/Loader/Loader.js +4 -0
- package/dist/Main/LogoHeader.d.ts +2 -0
- package/dist/Main/LogoHeader.js +5 -0
- package/dist/Main/Main.d.ts +59 -0
- package/dist/Main/Main.js +82 -0
- package/dist/MainMenu/MainMenu.d.ts +10 -0
- package/dist/MainMenu/MainMenu.js +6 -0
- package/dist/MainMenu/MenuItem/MenuItem.d.ts +16 -0
- package/dist/MainMenu/MenuItem/MenuItem.js +16 -0
- package/dist/MainMenu/hooks.d.ts +10 -0
- package/dist/MainMenu/hooks.js +21 -0
- package/dist/Navigation/CurrentItemNavigation.d.ts +15 -0
- package/dist/Navigation/CurrentItemNavigation.js +12 -0
- package/dist/Navigation/ExtraItemsMenu.d.ts +10 -0
- package/dist/Navigation/ExtraItemsMenu.js +24 -0
- package/dist/Navigation/ExtraItemsNavigation.d.ts +11 -0
- package/dist/Navigation/ExtraItemsNavigation.js +11 -0
- package/dist/Navigation/HomeMenu.d.ts +17 -0
- package/dist/Navigation/HomeMenu.js +28 -0
- package/dist/Navigation/ItemMenu.d.ts +16 -0
- package/dist/Navigation/ItemMenu.js +32 -0
- package/dist/Navigation/Navigation.d.ts +26 -0
- package/dist/Navigation/Navigation.js +15 -0
- package/dist/Navigation/ParentsNavigation.d.ts +10 -0
- package/dist/Navigation/ParentsNavigation.js +8 -0
- package/dist/Navigation/common/CenterAlignWrapper.d.ts +3 -0
- package/dist/Navigation/common/CenterAlignWrapper.js +7 -0
- package/dist/Navigation/common/NavigationLink.d.ts +8 -0
- package/dist/Navigation/common/NavigationLink.js +7 -0
- package/dist/Navigation/common/constants.d.ts +1 -0
- package/dist/Navigation/common/constants.js +1 -0
- package/dist/PlatformSwitch/PlatformSwitch.d.ts +57 -0
- package/dist/PlatformSwitch/PlatformSwitch.js +66 -0
- package/dist/PlatformSwitch/hooks.d.ts +30 -0
- package/dist/PlatformSwitch/hooks.js +49 -0
- package/dist/SearchInput/SearchInput.d.ts +20 -0
- package/dist/SearchInput/SearchInput.js +14 -0
- package/dist/Select/Select.d.ts +24 -0
- package/dist/Select/Select.js +7 -0
- package/dist/Sidebar/Sidebar.d.ts +11 -0
- package/dist/Sidebar/Sidebar.js +25 -0
- package/dist/StyledComponents/StyledBaseComponents.d.ts +11 -0
- package/dist/StyledComponents/StyledBaseComponents.js +11 -0
- package/dist/TextDisplay/TextDisplay.d.ts +5 -0
- package/dist/TextDisplay/TextDisplay.js +24 -0
- package/dist/TextDisplay/fixtures.d.ts +3 -0
- package/dist/TextDisplay/fixtures.js +84 -0
- package/dist/TextDisplay/withFlavor.d.ts +8 -0
- package/dist/TextDisplay/withFlavor.js +25 -0
- package/dist/TextEditor/TextEditor.d.ts +16 -0
- package/dist/TextEditor/TextEditor.js +74 -0
- package/dist/ThemeContext/LanguageSelect.d.ts +15 -0
- package/dist/ThemeContext/LanguageSelect.js +19 -0
- package/dist/ThemeContext/ThemeContext.d.ts +22 -0
- package/dist/ThemeContext/ThemeContext.js +31 -0
- package/dist/Thumbnail/Thumbnail.d.ts +28 -0
- package/dist/Thumbnail/Thumbnail.js +27 -0
- package/dist/Tree/Breadcrumbs.d.ts +14 -0
- package/dist/Tree/Breadcrumbs.js +30 -0
- package/dist/Tree/RowMenu.d.ts +12 -0
- package/dist/Tree/RowMenu.js +37 -0
- package/dist/Tree/RowMenus.d.ts +18 -0
- package/dist/Tree/RowMenus.js +7 -0
- package/dist/Tree/types.d.ts +6 -0
- package/dist/Tree/types.js +1 -0
- package/dist/UserSwitch/UserSwitch.d.ts +17 -0
- package/dist/UserSwitch/UserSwitch.js +46 -0
- package/dist/UserSwitch/UserSwitchWrapper.d.ts +37 -0
- package/dist/UserSwitch/UserSwitchWrapper.js +74 -0
- package/dist/appComponents/ErrorFallback.d.ts +57 -0
- package/dist/appComponents/ErrorFallback.js +72 -0
- package/dist/appComponents/QuestionLabel.d.ts +9 -0
- package/dist/appComponents/QuestionLabel.js +4 -0
- package/dist/appComponents/index.d.ts +6 -0
- package/dist/appComponents/index.js +5 -0
- package/dist/appComponents/statusChips/RequiredChip.d.ts +3 -0
- package/dist/appComponents/statusChips/RequiredChip.js +5 -0
- package/dist/appComponents/statusChips/SavedChip.d.ts +3 -0
- package/dist/appComponents/statusChips/SavedChip.js +5 -0
- package/dist/appComponents/statusChips/SubmittedChip.d.ts +3 -0
- package/dist/appComponents/statusChips/SubmittedChip.js +5 -0
- package/dist/appComponents/statusChips/types.d.ts +5 -0
- package/dist/appComponents/statusChips/types.js +1 -0
- package/dist/appComponents/types.d.ts +8 -0
- package/dist/appComponents/types.js +1 -0
- package/dist/apps.d.ts +1 -0
- package/dist/apps.js +1 -0
- package/dist/buttons/BookmarkButton/BookmarkButton.d.ts +24 -0
- package/dist/buttons/BookmarkButton/BookmarkButton.js +24 -0
- package/dist/buttons/Button/Button.d.ts +37 -0
- package/dist/buttons/Button/Button.js +4 -0
- package/dist/buttons/ChatboxButton/ChatboxButton.d.ts +15 -0
- package/dist/buttons/ChatboxButton/ChatboxButton.js +21 -0
- package/dist/buttons/CopyButton/CopyButton.d.ts +13 -0
- package/dist/buttons/CopyButton/CopyButton.js +14 -0
- package/dist/buttons/DeleteButton/DeleteButton.d.ts +12 -0
- package/dist/buttons/DeleteButton/DeleteButton.js +17 -0
- package/dist/buttons/DownloadButton/DownloadButton.d.ts +30 -0
- package/dist/buttons/DownloadButton/DownloadButton.js +20 -0
- package/dist/buttons/EditButton/EditButton.d.ts +13 -0
- package/dist/buttons/EditButton/EditButton.js +17 -0
- package/dist/buttons/LikeButton/LikeButton.d.ts +28 -0
- package/dist/buttons/LikeButton/LikeButton.js +10 -0
- package/dist/buttons/MenuItemButton.d.ts +11 -0
- package/dist/buttons/MenuItemButton.js +12 -0
- package/dist/buttons/MoveButton/MoveButton.d.ts +13 -0
- package/dist/buttons/MoveButton/MoveButton.js +19 -0
- package/dist/buttons/PinButton/PinButton.d.ts +15 -0
- package/dist/buttons/PinButton/PinButton.js +21 -0
- package/dist/buttons/SaveButton/SaveButton.d.ts +24 -0
- package/dist/buttons/SaveButton/SaveButton.js +4 -0
- package/dist/buttons/ShareButton/ShareButton.d.ts +14 -0
- package/dist/buttons/ShareButton/ShareButton.js +17 -0
- package/dist/buttons/hooks.d.ts +5 -0
- package/dist/buttons/hooks.js +14 -0
- package/dist/buttons/index.d.ts +12 -0
- package/dist/buttons/index.js +12 -0
- package/dist/constants.d.ts +11 -0
- package/dist/constants.js +12 -0
- package/dist/draggable/DraggableElement.d.ts +11 -0
- package/dist/draggable/DraggableElement.js +42 -0
- package/dist/draggable/DraggingWrapper.d.ts +23 -0
- package/dist/draggable/DraggingWrapper.js +20 -0
- package/dist/draggable/InBetween.d.ts +10 -0
- package/dist/draggable/InBetween.js +34 -0
- package/dist/draggable/types.d.ts +10 -0
- package/dist/draggable/types.js +1 -0
- package/dist/enums/errors.d.ts +3 -0
- package/dist/enums/errors.js +3 -0
- package/dist/hooks/useFullscreen.d.ts +5 -0
- package/dist/hooks/useFullscreen.js +37 -0
- package/dist/hooks/useMobileView.d.ts +4 -0
- package/dist/hooks/useMobileView.js +6 -0
- package/dist/icons/AnalyticsIcon.d.ts +15 -0
- package/dist/icons/AnalyticsIcon.js +7 -0
- package/dist/icons/BuildIcon.d.ts +15 -0
- package/dist/icons/BuildIcon.js +7 -0
- package/dist/icons/EtherpadIcon.d.ts +7 -0
- package/dist/icons/EtherpadIcon.js +7 -0
- package/dist/icons/H5PIcon.d.ts +6 -0
- package/dist/icons/H5PIcon.js +6 -0
- package/dist/icons/ItemIcon.d.ts +23 -0
- package/dist/icons/ItemIcon.js +75 -0
- package/dist/icons/LibraryIcon.d.ts +16 -0
- package/dist/icons/LibraryIcon.js +7 -0
- package/dist/icons/PlayIcon.d.ts +15 -0
- package/dist/icons/PlayIcon.js +7 -0
- package/dist/icons/ResizingIcon.d.ts +2 -0
- package/dist/icons/ResizingIcon.js +21 -0
- package/dist/icons/StyledSVGComponents.d.ts +35 -0
- package/dist/icons/StyledSVGComponents.js +53 -0
- package/dist/icons/index.d.ts +6 -0
- package/dist/icons/index.js +6 -0
- package/dist/index.d.ts +61 -0
- package/dist/index.js +60 -0
- package/dist/itemLogin/ForbiddenContent.d.ts +20 -0
- package/dist/itemLogin/ForbiddenContent.js +4 -0
- package/dist/itemLogin/ForbiddenText.d.ts +8 -0
- package/dist/itemLogin/ForbiddenText.js +6 -0
- package/dist/itemLogin/ItemLoginScreen.d.ts +26 -0
- package/dist/itemLogin/ItemLoginScreen.js +72 -0
- package/dist/itemLogin/ItemLoginWrapper.d.ts +23 -0
- package/dist/itemLogin/ItemLoginWrapper.js +43 -0
- package/dist/itemLogin/constants.d.ts +1 -0
- package/dist/itemLogin/constants.js +1 -0
- package/dist/items/AppItem.d.ts +60 -0
- package/dist/items/AppItem.js +69 -0
- package/dist/items/DocumentItem.d.ts +19 -0
- package/dist/items/DocumentItem.js +25 -0
- package/dist/items/DownloadButtonFileItem.d.ts +9 -0
- package/dist/items/DownloadButtonFileItem.js +10 -0
- package/dist/items/EtherpadItem.d.ts +26 -0
- package/dist/items/EtherpadItem.js +15 -0
- package/dist/items/FileAudio.d.ts +9 -0
- package/dist/items/FileAudio.js +10 -0
- package/dist/items/FileImage.d.ts +7 -0
- package/dist/items/FileImage.js +10 -0
- package/dist/items/FileItem.d.ts +25 -0
- package/dist/items/FileItem.js +81 -0
- package/dist/items/FilePdf.d.ts +14 -0
- package/dist/items/FilePdf.js +29 -0
- package/dist/items/FileVideo.d.ts +8 -0
- package/dist/items/FileVideo.js +9 -0
- package/dist/items/H5PItem.d.ts +20 -0
- package/dist/items/H5PItem.js +80 -0
- package/dist/items/ItemSkeleton/ItemSkeleton.d.ts +12 -0
- package/dist/items/ItemSkeleton/ItemSkeleton.js +35 -0
- package/dist/items/LinkItem.d.ts +43 -0
- package/dist/items/LinkItem.js +97 -0
- package/dist/items/SizingWrapper.d.ts +6 -0
- package/dist/items/SizingWrapper.js +23 -0
- package/dist/items/appItemHooks.d.ts +27 -0
- package/dist/items/appItemHooks.js +124 -0
- package/dist/items/constants.d.ts +1 -0
- package/dist/items/constants.js +1 -0
- package/dist/items/iframeStyles.d.ts +4 -0
- package/dist/items/iframeStyles.js +5 -0
- package/dist/items/index.d.ts +5 -0
- package/dist/items/index.js +5 -0
- package/dist/items/withCaption.d.ts +19 -0
- package/dist/items/withCaption.js +58 -0
- package/dist/items/withResizing.d.ts +9 -0
- package/dist/items/withResizing.js +42 -0
- package/dist/text-editor.d.ts +2 -0
- package/dist/text-editor.js +2 -0
- package/dist/theme.d.ts +108 -0
- package/dist/theme.js +214 -0
- package/dist/types.d.ts +43 -0
- package/dist/types.js +32 -0
- package/dist/upload/FileDropper/FileDropper.d.ts +50 -0
- package/dist/upload/FileDropper/FileDropper.js +43 -0
- package/dist/upload/UploadFileButton/UploadFileButton.d.ts +35 -0
- package/dist/upload/UploadFileButton/UploadFileButton.js +17 -0
- package/dist/utils/fixtures.d.ts +3 -0
- package/dist/utils/fixtures.js +7 -0
- package/dist/utils/storybook.d.ts +5 -0
- package/dist/utils/storybook.js +5 -0
- package/package.json +172 -0
package/README.md
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Graasp UI
|
|
2
|
+
|
|
3
|
+
> React components for the Graasp ecosystem.
|
|
4
|
+
|
|
5
|
+
[](https://github.com/graasp/graasp-ui/releases)
|
|
6
|
+
[](https://www.npmjs.com/package/@graasp/ui)
|
|
7
|
+

|
|
8
|
+
[](https://graasp.github.io/graasp-ui/)
|
|
9
|
+
|
|
10
|
+
Packages
|
|
11
|
+
)
|
|
12
|
+
)
|
|
13
|
+

|
|
14
|
+
[](https://mui.com/material-ui/getting-started/overview/)
|
|
15
|
+
|
|
16
|
+
## Adding the library to your project
|
|
17
|
+
|
|
18
|
+
You will have to add the library and its peer dependencies:
|
|
19
|
+
|
|
20
|
+
```sh
|
|
21
|
+
yarn add @graasp/ui @graasp/stylis-plugin-rtl date-fns lucide-react
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Usage
|
|
25
|
+
|
|
26
|
+
```tsx
|
|
27
|
+
import { MyComponent } from '@graasp/ui'
|
|
28
|
+
|
|
29
|
+
const Example = () => {
|
|
30
|
+
return <MyComponent />
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Sub packages
|
|
35
|
+
|
|
36
|
+
#### Components for Graasp Apps
|
|
37
|
+
|
|
38
|
+
Graasp apps can use specific components to share style without needing to import the full bundle: use import from `@graasp/ui/apps`
|
|
39
|
+
|
|
40
|
+
#### Text Editor
|
|
41
|
+
|
|
42
|
+
Since Quill does not play nicely with SSR frameworks (access to the document property is not gated), it is exposed in its own sub-package: `@graasp/ui/text-editor`
|
|
43
|
+
|
|
44
|
+
##  Storybook
|
|
45
|
+
|
|
46
|
+
Storybook provides a nice display of defined UI components. To open the framework, run
|
|
47
|
+
|
|
48
|
+
```sh
|
|
49
|
+
yarn storybook
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
To explore the UI components and play with their props click the link bellow:
|
|
53
|
+
|
|
54
|
+
<a href="https://graasp.github.io/graasp-ui/" >
|
|
55
|
+
<img style="background: white; padding: 8px; border-radius: 2px; border: 1px solid lightgray" src="https://api.iconify.design/logos/storybook.svg"/>
|
|
56
|
+
</a>
|
|
57
|
+
|
|
58
|
+
## License
|
|
59
|
+
|
|
60
|
+
AGPL-3.0 © [Graasp Association](https://graasp.org)
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { CurrentAccount } from '@lnco-ai/sdk';
|
|
3
|
+
type Props = {
|
|
4
|
+
buttonText: string;
|
|
5
|
+
children?: ReactNode;
|
|
6
|
+
currentAccount?: CurrentAccount | null;
|
|
7
|
+
/**
|
|
8
|
+
* Component to display on error.
|
|
9
|
+
* Overrides errorText
|
|
10
|
+
*/
|
|
11
|
+
error?: JSX.Element;
|
|
12
|
+
errorText: string;
|
|
13
|
+
id?: string;
|
|
14
|
+
onButtonClick?: () => void;
|
|
15
|
+
startIcon?: JSX.Element;
|
|
16
|
+
text: string | JSX.Element;
|
|
17
|
+
};
|
|
18
|
+
declare const PreventGuestWrapper: ({ buttonText, children, currentAccount, error, id, onButtonClick, startIcon, errorText, text, }: Props) => ReactNode;
|
|
19
|
+
export default PreventGuestWrapper;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { ClipboardPen } from 'lucide-react';
|
|
3
|
+
import { Alert, Box, Container, Button as MuiButton, Stack, Typography, } from '@mui/material';
|
|
4
|
+
import { AccountType } from '@lnco-ai/sdk';
|
|
5
|
+
const PreventGuestWrapper = ({ buttonText, children, currentAccount, error, id, onButtonClick, startIcon = _jsx(ClipboardPen, {}), errorText, text, }) => {
|
|
6
|
+
if (currentAccount) {
|
|
7
|
+
// guest - should not have access to children
|
|
8
|
+
if (currentAccount.type === AccountType.Guest) {
|
|
9
|
+
return (_jsx(Stack, { height: '100%', justifyContent: 'center', alignItems: 'center', children: _jsx(Container, { maxWidth: 'md', children: _jsxs(Alert, { severity: 'info', id: id, children: [_jsx(Typography, { children: text }), _jsx(Box, { mt: 2, textAlign: 'center', children: _jsx(MuiButton, { startIcon: startIcon, variant: 'contained', sx: { textTransform: 'none' }, onClick: onButtonClick, children: buttonText }) })] }) }) }));
|
|
10
|
+
}
|
|
11
|
+
return children;
|
|
12
|
+
}
|
|
13
|
+
return error ?? _jsx(Alert, { severity: 'error', children: errorText });
|
|
14
|
+
};
|
|
15
|
+
export default PreventGuestWrapper;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { LinkProps } from 'react-router-dom';
|
|
2
|
+
type Props = {
|
|
3
|
+
link: LinkProps['to'];
|
|
4
|
+
id?: string;
|
|
5
|
+
redirectionLinkText?: string;
|
|
6
|
+
redirectionText?: string;
|
|
7
|
+
};
|
|
8
|
+
declare const RedirectionContent: ({ link, redirectionText, redirectionLinkText, id, }: Props) => JSX.Element;
|
|
9
|
+
export default RedirectionContent;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Container, Typography, styled } from '@mui/material';
|
|
3
|
+
import { Link } from 'react-router-dom';
|
|
4
|
+
import GraaspLogo from '../GraaspLogo/GraaspLogo.js';
|
|
5
|
+
const StyledContainer = styled(Container)(() => ({
|
|
6
|
+
height: '100vh',
|
|
7
|
+
display: 'flex',
|
|
8
|
+
justifyContent: 'center',
|
|
9
|
+
alignItems: 'center',
|
|
10
|
+
}));
|
|
11
|
+
const StyledTypography = styled(Typography)(({ theme }) => ({
|
|
12
|
+
marginLeft: theme.spacing(2),
|
|
13
|
+
color: theme.palette.primary.main,
|
|
14
|
+
}));
|
|
15
|
+
const StyledLink = styled(Link)(() => ({
|
|
16
|
+
textDecoration: 'none',
|
|
17
|
+
fontStyle: 'italic',
|
|
18
|
+
color: 'black',
|
|
19
|
+
}));
|
|
20
|
+
const RedirectionContent = ({ link, redirectionText, redirectionLinkText, id, }) => {
|
|
21
|
+
return (_jsxs(StyledContainer, { id: id, children: [_jsx(GraaspLogo, { height: 100 }), _jsxs("div", { children: [_jsx(StyledTypography, { variant: 'h4', align: 'center', children: redirectionText ?? 'You are being redirected…' }), _jsx(StyledLink, { to: link, children: _jsx(Typography, { align: 'center', children: redirectionLinkText ??
|
|
22
|
+
'Click here if you are not automatically redirected' }) })] })] }));
|
|
23
|
+
};
|
|
24
|
+
export default RedirectionContent;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { CurrentAccount } from '@lnco-ai/sdk';
|
|
3
|
+
export type SignedInWrapperProps = {
|
|
4
|
+
redirectionLink: string;
|
|
5
|
+
currentAccount?: CurrentAccount | null;
|
|
6
|
+
onRedirect?: () => void;
|
|
7
|
+
children?: ReactNode;
|
|
8
|
+
};
|
|
9
|
+
declare const SignedInWrapper: ({ currentAccount, redirectionLink, onRedirect, children, }: SignedInWrapperProps) => SignedInWrapperProps["children"];
|
|
10
|
+
export default SignedInWrapper;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { redirect } from '@lnco-ai/sdk';
|
|
3
|
+
import RedirectionContent from './RedirectionContent.js';
|
|
4
|
+
const SignedInWrapper = ({ currentAccount, redirectionLink, onRedirect, children, }) => {
|
|
5
|
+
const redirectToSignIn = () => {
|
|
6
|
+
if (!redirectionLink) {
|
|
7
|
+
console.debug('No link has been set for redirection');
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
redirect(window, redirectionLink);
|
|
11
|
+
};
|
|
12
|
+
// check authorization: user shouldn't be empty
|
|
13
|
+
if (currentAccount?.id) {
|
|
14
|
+
return children;
|
|
15
|
+
}
|
|
16
|
+
onRedirect?.();
|
|
17
|
+
redirectToSignIn();
|
|
18
|
+
// redirect page if redirection is not working
|
|
19
|
+
return _jsx(RedirectionContent, { link: redirectionLink });
|
|
20
|
+
};
|
|
21
|
+
export default SignedInWrapper;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { SkeletonProps, SxProps } from '@mui/material';
|
|
2
|
+
type AvatarProps = {
|
|
3
|
+
alt: string;
|
|
4
|
+
/**
|
|
5
|
+
* component used to display the avatar (img or avatar)
|
|
6
|
+
*/
|
|
7
|
+
component?: 'img' | 'avatar';
|
|
8
|
+
id?: string;
|
|
9
|
+
isLoading?: boolean;
|
|
10
|
+
maxHeight?: string | number;
|
|
11
|
+
maxWidth?: string | number;
|
|
12
|
+
/**
|
|
13
|
+
* thumbnail size to fetch
|
|
14
|
+
*/
|
|
15
|
+
size?: string;
|
|
16
|
+
sx?: SxProps;
|
|
17
|
+
url?: string;
|
|
18
|
+
/**
|
|
19
|
+
* skeleton variant
|
|
20
|
+
*/
|
|
21
|
+
variant?: SkeletonProps['variant'];
|
|
22
|
+
};
|
|
23
|
+
declare const Avatar: ({ sx, id, alt, maxWidth, maxHeight, variant, component, isLoading, url, }: AvatarProps) => JSX.Element | null;
|
|
24
|
+
export default Avatar;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Avatar as AvatarComponent, Skeleton, } from '@mui/material';
|
|
3
|
+
import Thumbnail from '../Thumbnail/Thumbnail.js';
|
|
4
|
+
const Avatar = ({ sx, id, alt = 'avatar', maxWidth = '100%', maxHeight = '100%', variant = 'circular', component = 'avatar', isLoading, url, }) => {
|
|
5
|
+
if (component === 'avatar') {
|
|
6
|
+
if (url) {
|
|
7
|
+
return (_jsx(AvatarComponent, { id: id, alt: alt, src: url, sx: {
|
|
8
|
+
width: maxWidth,
|
|
9
|
+
height: maxHeight,
|
|
10
|
+
...sx,
|
|
11
|
+
}, title: alt }));
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
if (isLoading) {
|
|
15
|
+
return (_jsx(Skeleton, { variant: variant, sx: sx, width: maxWidth, height: maxHeight }));
|
|
16
|
+
}
|
|
17
|
+
return _jsx(AvatarComponent, { id: id, alt: alt, sx: { ...sx }, title: alt });
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return (_jsx(Thumbnail, { sx: sx, alt: alt, id: id, url: url, maxWidth: maxWidth, maxHeight: maxHeight, variant: variant, isLoading: isLoading }));
|
|
21
|
+
};
|
|
22
|
+
export default Avatar;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compute the member unique color based on their id
|
|
3
|
+
* @param id memberId
|
|
4
|
+
* @returns a CSS color string that can be used to set for example the background of an avatar
|
|
5
|
+
*/
|
|
6
|
+
export declare const getColorFromId: (id: string) => string;
|
|
7
|
+
/**
|
|
8
|
+
* Generate an HTML color from a string.
|
|
9
|
+
* This can be used to generate stable avatar colors
|
|
10
|
+
*
|
|
11
|
+
*/
|
|
12
|
+
export declare const stringToColor: (name: string) => string;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { hslToRgb } from '@mui/material';
|
|
2
|
+
/**
|
|
3
|
+
* Compute the member unique color based on their id
|
|
4
|
+
* @param id memberId
|
|
5
|
+
* @returns a CSS color string that can be used to set for example the background of an avatar
|
|
6
|
+
*/
|
|
7
|
+
export const getColorFromId = (id) => {
|
|
8
|
+
const rawHue = id.slice(0, 2);
|
|
9
|
+
const hue = (parseInt(rawHue, 16) / 256) * 360;
|
|
10
|
+
const rawSaturation = id[2];
|
|
11
|
+
const saturation = 65 + (16 - parseInt(rawSaturation, 16));
|
|
12
|
+
const newRgb = hslToRgb(`hsl(${hue}, ${saturation}, ${60})`);
|
|
13
|
+
return newRgb;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Generate an HTML color from a string.
|
|
17
|
+
* This can be used to generate stable avatar colors
|
|
18
|
+
*
|
|
19
|
+
*/
|
|
20
|
+
export const stringToColor = (name) => {
|
|
21
|
+
let hash = 0;
|
|
22
|
+
for (const char of name) {
|
|
23
|
+
hash = char.charCodeAt(0) + ((hash << 5) - hash);
|
|
24
|
+
}
|
|
25
|
+
let color = '#';
|
|
26
|
+
for (let i = 0; i < 3; i += 1) {
|
|
27
|
+
const value = (hash >> (i * 8)) & 0xff;
|
|
28
|
+
color += `00${value.toString(16)}`.slice(-2);
|
|
29
|
+
}
|
|
30
|
+
return color;
|
|
31
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { stringToColor } from './stringToColor.js';
|
|
3
|
+
describe('stringToColor', () => {
|
|
4
|
+
it('Generates a color from a string', () => {
|
|
5
|
+
expect(stringToColor('abcd')).toEqual('#42942d');
|
|
6
|
+
expect(stringToColor('toto')).toEqual('#366a36');
|
|
7
|
+
});
|
|
8
|
+
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { SxProps } from '@mui/material';
|
|
2
|
+
import { ReactElement } from 'react';
|
|
3
|
+
import type { DraggableAndDroppableProps } from '../draggable/types.js';
|
|
4
|
+
import { CardThumbnailProps } from './CardThumbnail.js';
|
|
5
|
+
type CardProps = {
|
|
6
|
+
name: string | JSX.Element;
|
|
7
|
+
alt: string;
|
|
8
|
+
id?: string;
|
|
9
|
+
/**
|
|
10
|
+
* Classname for the element.
|
|
11
|
+
* Useful for selecting many cards at the same time (eg. drag targets).
|
|
12
|
+
*/
|
|
13
|
+
className?: string;
|
|
14
|
+
/**
|
|
15
|
+
* creator name
|
|
16
|
+
*/
|
|
17
|
+
creator?: string;
|
|
18
|
+
height?: number;
|
|
19
|
+
/**
|
|
20
|
+
* image link to display as thumbnail
|
|
21
|
+
*/
|
|
22
|
+
thumbnail?: string;
|
|
23
|
+
footer?: string | ReactElement;
|
|
24
|
+
sx?: SxProps;
|
|
25
|
+
/**
|
|
26
|
+
* Whether the card should expand to take all available space
|
|
27
|
+
*/
|
|
28
|
+
fullWidth?: boolean;
|
|
29
|
+
isSelected?: boolean;
|
|
30
|
+
dense?: boolean;
|
|
31
|
+
elevation?: boolean;
|
|
32
|
+
menu?: JSX.Element;
|
|
33
|
+
content?: string | JSX.Element | JSX.Element[];
|
|
34
|
+
to?: string;
|
|
35
|
+
type?: CardThumbnailProps['type'];
|
|
36
|
+
onThumbnailClick?: () => void;
|
|
37
|
+
} & Partial<DraggableAndDroppableProps>;
|
|
38
|
+
declare const Card: ({ footer, id, creator, height: heightProp, name, sx, dense, thumbnail, menu, fullWidth, elevation, content, alt, to, type, isOver, isDragging, isSelected, className, onThumbnailClick, }: CardProps) => JSX.Element;
|
|
39
|
+
export default Card;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Box, CardActions, Grid2 as Grid, Card as MuiCard, Stack, Typography, styled, } from '@mui/material';
|
|
3
|
+
import { Link } from 'react-router-dom';
|
|
4
|
+
import { PRIMARY_COLOR } from '../theme.js';
|
|
5
|
+
import CardThumbnail from './CardThumbnail.js';
|
|
6
|
+
const DEFAULT_CARD_HEIGHT = 130;
|
|
7
|
+
const PROPS_TO_FORWARD = ['elevation', 'fullWidth', 'isSelected', 'isOver'];
|
|
8
|
+
const StyledCard = styled(MuiCard, {
|
|
9
|
+
shouldForwardProp: (prop) => !PROPS_TO_FORWARD.includes(prop),
|
|
10
|
+
})(({ theme, elevation, fullWidth, isOver, isSelected }) => ({
|
|
11
|
+
borderRadius: theme.spacing(1),
|
|
12
|
+
boxShadow: elevation ? theme.shadows[2] : '0px 2px 2px #eeeeee',
|
|
13
|
+
width: fullWidth ? '100%' : 'max-content',
|
|
14
|
+
maxWidth: '100%',
|
|
15
|
+
outline: isOver || isSelected ? `2px solid ${PRIMARY_COLOR}` : 'none',
|
|
16
|
+
}));
|
|
17
|
+
const Wrapper = ({ children, to, }) => {
|
|
18
|
+
if (!to) {
|
|
19
|
+
return _jsx(_Fragment, { children: children });
|
|
20
|
+
}
|
|
21
|
+
return (_jsx(Link, { to: to, style: { textDecoration: 'none', color: 'unset' }, children: children }));
|
|
22
|
+
};
|
|
23
|
+
const Card = ({ footer, id, creator, height: heightProp, name, sx, dense, thumbnail, menu, fullWidth = false, elevation = true, content, alt, to, type, isOver = false, isDragging = false, isSelected = false, className, onThumbnailClick, }) => {
|
|
24
|
+
let height = heightProp;
|
|
25
|
+
if (!height) {
|
|
26
|
+
height = dense ? 60 : DEFAULT_CARD_HEIGHT;
|
|
27
|
+
}
|
|
28
|
+
if (dense) {
|
|
29
|
+
return (_jsx(StyledCard
|
|
30
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
31
|
+
// @ts-ignore
|
|
32
|
+
, {
|
|
33
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
34
|
+
// @ts-ignore
|
|
35
|
+
elevation: elevation && !isDragging, id: id, className: className, sx: sx, fullWidth: fullWidth, isOver: isOver, isSelected: isSelected, children: _jsxs(Stack, { sx: { height, boxSizing: 'border-box' }, direction: 'row', gap: 1, alignItems: 'center', mr: 1, children: [_jsx(Box, { onClick: onThumbnailClick, height: '100%', children: _jsx(CardThumbnail, { width: height, minHeight: height, thumbnail: thumbnail, alt: alt, type: type }) }), _jsxs(Grid, { container: true,
|
|
36
|
+
// necessary to respect flex layout, otherwise it does not compress
|
|
37
|
+
minWidth: 0, width: '100%', sx: { mt: 0 },
|
|
38
|
+
// ensure that if there is no description the element still goes edge to edge
|
|
39
|
+
boxSizing: 'border-box', marginTop: 1, justifyContent: 'space-between', alignItems: 'center', children: [_jsx(Grid, { size: {
|
|
40
|
+
xs: 9,
|
|
41
|
+
sm: 5,
|
|
42
|
+
md: 5,
|
|
43
|
+
}, justifyContent: 'space-between',
|
|
44
|
+
// align to the top so the button does not move when there is no creator
|
|
45
|
+
alignItems: 'start', boxSizing: 'border-box', children: _jsx(Wrapper, { to: to, children: _jsxs(Stack, { minWidth: 0, children: [_jsx(Typography, { noWrap: true, variant: dense ? 'h5' : 'h3', children: name }), creator && (_jsx(Typography, { noWrap: true, variant: dense ? 'caption' : 'body1', color: 'text.secondary', children: creator }))] }) }) }), _jsx(Grid, { size: { sm: 4, xs: 0, md: 5 }, display: { xs: 'none', sm: 'block' }, children: _jsx(Wrapper, { to: to, children: content }) }), _jsx(Grid, { size: { xs: 3, sm: 3, md: 2 }, justifyContent: 'flex-end', children: _jsxs(CardActions, { sx: { p: 0, justifyContent: 'flex-end' }, children: [_jsx(Stack, { width: '100%', alignItems: 'end', direction: 'row', justifyContent: 'flex-end', alignContent: 'center', display: { xs: 'none', sm: 'block' }, children: footer }), menu] }) })] })] }) }));
|
|
46
|
+
}
|
|
47
|
+
return (_jsx(StyledCard, { isOver: isOver, id: id, sx: sx, fullWidth: fullWidth, className: className, children: _jsxs(Stack, { sx: { height, boxSizing: 'border-box' }, direction: 'row', gap: 2, children: [_jsx(CardThumbnail, { width: height, minHeight: height, thumbnail: thumbnail, alt: alt }), _jsxs(Stack, { direction: 'column',
|
|
48
|
+
// necessary to respect flex layout, otherwise it does not compress
|
|
49
|
+
minWidth: 0,
|
|
50
|
+
// ensure that if there is no description the element still goes edge to edge
|
|
51
|
+
width: '100%', boxSizing: 'border-box', marginTop: 1, children: [_jsxs(Stack, { direction: 'row', justifyContent: 'space-between',
|
|
52
|
+
// align to the top so the button does not move when there is no creator
|
|
53
|
+
alignItems: 'start', boxSizing: 'border-box', children: [_jsx(Wrapper, { to: to, children: _jsxs(Stack, { minWidth: 0, direction: 'column', children: [_jsx(Typography, { noWrap: true, variant: dense ? 'h5' : 'h3', children: name }), creator && (_jsx(Typography, { noWrap: true, variant: dense ? 'caption' : 'body1', color: 'text.secondary', children: creator }))] }) }), menu] }), _jsx(Typography, { justifySelf: 'start',
|
|
54
|
+
// necessary for the `position: absolute` on the :before to work
|
|
55
|
+
position: 'relative',
|
|
56
|
+
// allow compression in flex layout
|
|
57
|
+
minHeight: 0, flexShrink: 1,
|
|
58
|
+
// this element will take all available space
|
|
59
|
+
flexGrow: 1, variant: 'caption', color: 'textSecondary', sx: {
|
|
60
|
+
// margin to the right
|
|
61
|
+
mr: 1,
|
|
62
|
+
// hide overflowing text
|
|
63
|
+
overflow: 'hidden',
|
|
64
|
+
// use a before element to create a gradient to suggest there is more text
|
|
65
|
+
'&:before': {
|
|
66
|
+
content: '""',
|
|
67
|
+
width: '100%',
|
|
68
|
+
height: '30px',
|
|
69
|
+
position: 'absolute',
|
|
70
|
+
left: '0px',
|
|
71
|
+
bottom: '0px',
|
|
72
|
+
background: (theme) => `linear-gradient(transparent 10px, ${theme.palette.background.paper})`,
|
|
73
|
+
},
|
|
74
|
+
}, children: content }), footer] })] }) }));
|
|
75
|
+
};
|
|
76
|
+
export default Card;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
type CardHeaderProps = {
|
|
3
|
+
name: string;
|
|
4
|
+
creator?: string;
|
|
5
|
+
ItemMenu?: ReactElement;
|
|
6
|
+
NameWrapper?: ({ children }: {
|
|
7
|
+
children: JSX.Element;
|
|
8
|
+
}) => JSX.Element;
|
|
9
|
+
dense?: boolean;
|
|
10
|
+
};
|
|
11
|
+
declare const CustomCardHeader: ({ name, creator, ItemMenu, dense, NameWrapper, }: CardHeaderProps) => JSX.Element;
|
|
12
|
+
export default CustomCardHeader;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Stack, Typography } from '@mui/material';
|
|
3
|
+
const CustomCardHeader = ({ name, creator, ItemMenu, dense, NameWrapper = ({ children }) => children, }) => {
|
|
4
|
+
return (_jsxs(Stack, { direction: 'row', justifyContent: 'space-between',
|
|
5
|
+
// align to the top so the button does not move when there is no creator
|
|
6
|
+
alignItems: 'start', boxSizing: 'border-box', children: [_jsxs(Stack, { minWidth: 0, direction: 'column', children: [_jsx(NameWrapper, { children: _jsx(Typography, { noWrap: true, variant: dense ? 'h5' : 'h3', children: name }) }), creator && (_jsx(Typography, { noWrap: true, variant: dense ? 'caption' : 'body1', color: 'text.secondary', children: creator }))] }), ItemMenu] }));
|
|
7
|
+
};
|
|
8
|
+
export default CustomCardHeader;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { DiscriminatedItem } from '@lnco-ai/sdk';
|
|
2
|
+
export type CardThumbnailProps = {
|
|
3
|
+
thumbnail?: string;
|
|
4
|
+
alt: string;
|
|
5
|
+
width?: number;
|
|
6
|
+
minHeight: number;
|
|
7
|
+
type?: DiscriminatedItem['type'];
|
|
8
|
+
};
|
|
9
|
+
declare const CardThumbnail: ({ thumbnail, alt, width, minHeight, type, }: CardThumbnailProps) => JSX.Element;
|
|
10
|
+
export default CardThumbnail;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Box, useTheme } from '@mui/material';
|
|
3
|
+
import { ItemType } from '@lnco-ai/sdk';
|
|
4
|
+
import Thumbnail from '../Thumbnail/Thumbnail.js';
|
|
5
|
+
import ItemIcon from '../icons/ItemIcon.js';
|
|
6
|
+
import { DEFAULT_LIGHT_PRIMARY_COLOR } from '../theme.js';
|
|
7
|
+
const CardThumbnail = ({ thumbnail, alt, width, minHeight, type = ItemType.FOLDER, }) => {
|
|
8
|
+
const theme = useTheme();
|
|
9
|
+
if (thumbnail) {
|
|
10
|
+
return (_jsx(Thumbnail, { url: thumbnail, alt: alt, maxHeight: '100%', maxWidth: width }));
|
|
11
|
+
}
|
|
12
|
+
return (_jsx(Box, { display: 'flex', alignItems: 'center', justifyContent: 'center', bgcolor: DEFAULT_LIGHT_PRIMARY_COLOR.main, width: width, height: '100%', flexShrink: 0, minHeight: minHeight, minWidth: 0, children: _jsx(ItemIcon, { type: type, alt: alt, color: theme.palette.primary.main }) }));
|
|
13
|
+
};
|
|
14
|
+
export default CardThumbnail;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { LinkProps } from 'react-router-dom';
|
|
2
|
+
export declare const CARD_HEIGHT = 76;
|
|
3
|
+
type Props = {
|
|
4
|
+
id?: string;
|
|
5
|
+
name: string;
|
|
6
|
+
description?: string | null | JSX.Element;
|
|
7
|
+
thumbnail?: string;
|
|
8
|
+
/**
|
|
9
|
+
* React Router Link target
|
|
10
|
+
*/
|
|
11
|
+
to: LinkProps['to'];
|
|
12
|
+
};
|
|
13
|
+
declare const FolderCard: ({ id, name, description, thumbnail, to, }: Props) => JSX.Element;
|
|
14
|
+
export default FolderCard;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { ChevronRight } from 'lucide-react';
|
|
3
|
+
import { Card, CardActionArea, CardHeader, Stack, useTheme, } from '@mui/material';
|
|
4
|
+
import { Link } from 'react-router-dom';
|
|
5
|
+
import { ItemType } from '@lnco-ai/sdk';
|
|
6
|
+
import CardThumbnail from './CardThumbnail.js';
|
|
7
|
+
// FIX: use the same constant
|
|
8
|
+
export const CARD_HEIGHT = 76;
|
|
9
|
+
const FolderCard = ({ id, name, description, thumbnail, to, }) => {
|
|
10
|
+
const theme = useTheme();
|
|
11
|
+
return (_jsx(Card, { id: id, sx: {
|
|
12
|
+
// card should not be longer than the content
|
|
13
|
+
width: 'max-content',
|
|
14
|
+
// but should not overflow the parent
|
|
15
|
+
maxWidth: '100%',
|
|
16
|
+
// set the height of the card to be fixed
|
|
17
|
+
height: CARD_HEIGHT,
|
|
18
|
+
}, children: _jsx(CardActionArea, { component: Link, to: to, sx: { height: '100%' }, children: _jsxs(Stack, { direction: 'row', alignItems: 'center', height: '100%', minWidth: 0, children: [_jsx(CardThumbnail, { width: CARD_HEIGHT, minHeight: CARD_HEIGHT, thumbnail: thumbnail, alt: name, type: ItemType.FOLDER }), _jsx(CardHeader, { sx: {
|
|
19
|
+
// needed to make container not overflow parent
|
|
20
|
+
minWidth: '0px',
|
|
21
|
+
'& .MuiCardHeader-content': {
|
|
22
|
+
// needed to make container not overflow parent
|
|
23
|
+
minWidth: '0px',
|
|
24
|
+
},
|
|
25
|
+
}, title: name, subheader: description, titleTypographyProps: {
|
|
26
|
+
color: 'primary',
|
|
27
|
+
minWidth: '0px',
|
|
28
|
+
// needed to force long title into ellipsis
|
|
29
|
+
noWrap: true,
|
|
30
|
+
width: '100%',
|
|
31
|
+
}, subheaderTypographyProps: {
|
|
32
|
+
overflow: 'hidden',
|
|
33
|
+
height: description ? '1lh' : 'unset',
|
|
34
|
+
textOverflow: 'ellipsis',
|
|
35
|
+
minWidth: 0,
|
|
36
|
+
sx: {
|
|
37
|
+
'& p': {
|
|
38
|
+
margin: 0,
|
|
39
|
+
marginBlocStart: 0,
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
} }), _jsx(ChevronRight, { size: 35, color: theme.palette.primary.main, style: { flexShrink: 0, margin: theme.spacing(2, 2, 2, 0) } })] }) }) }));
|
|
43
|
+
};
|
|
44
|
+
export default FolderCard;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
type FancyLinkProps = {
|
|
2
|
+
id?: string;
|
|
3
|
+
title: string;
|
|
4
|
+
url: string;
|
|
5
|
+
thumbnail?: string;
|
|
6
|
+
description: string;
|
|
7
|
+
isExternal?: boolean;
|
|
8
|
+
onClick?: () => void;
|
|
9
|
+
};
|
|
10
|
+
declare const FancyLink: ({ id, title, thumbnail, description, url, onClick, isExternal, }: FancyLinkProps) => JSX.Element;
|
|
11
|
+
export default FancyLink;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { ExternalLink } from 'lucide-react';
|
|
3
|
+
import { Card, CardActionArea, CardHeader, Stack, Typography, useTheme, } from '@mui/material';
|
|
4
|
+
import { ItemType } from '@lnco-ai/sdk';
|
|
5
|
+
import CardThumbnail from './components/CardThumbnail.js';
|
|
6
|
+
import { CARD_HEIGHT } from './constants.js';
|
|
7
|
+
const FANCY_LINK_CARD_TEST_ID = 'fancy-link-card';
|
|
8
|
+
const FancyLink = ({ id, title, thumbnail, description, url, onClick, isExternal = true, }) => {
|
|
9
|
+
const theme = useTheme();
|
|
10
|
+
return (_jsx(Card, { id: id, sx: {
|
|
11
|
+
// card should not be longer than the content
|
|
12
|
+
width: 'max-content',
|
|
13
|
+
// but should not overflow the parent
|
|
14
|
+
maxWidth: '100%',
|
|
15
|
+
// set the height of the card to be fixed
|
|
16
|
+
height: CARD_HEIGHT,
|
|
17
|
+
}, "data-testid": FANCY_LINK_CARD_TEST_ID, children: _jsx(CardActionArea, { href: url, sx: { height: '100%' }, onClick: onClick, children: _jsxs(Stack, { direction: 'row', alignItems: 'center', height: '100%', minWidth: 0, children: [_jsx(CardThumbnail, { thumbnail: thumbnail, alt: 'Link thumbnail', itemType: ItemType.LINK }), _jsx(CardHeader, { sx: {
|
|
18
|
+
// needed to make container not overflow parent
|
|
19
|
+
minWidth: '0px',
|
|
20
|
+
'& .MuiCardHeader-content': {
|
|
21
|
+
// needed to make container not overflow parent
|
|
22
|
+
minWidth: '0px',
|
|
23
|
+
},
|
|
24
|
+
}, title: _jsxs(Stack, { children: [_jsxs(Stack, { direction: 'row', gap: 1, alignItems: 'center', children: [_jsx(Typography, { variant: 'h5', noWrap: true, fontWeight: 'bold', color: 'primary', children: title }), isExternal && (_jsx(ExternalLink
|
|
25
|
+
// the icon should not get smaller
|
|
26
|
+
, {
|
|
27
|
+
// the icon should not get smaller
|
|
28
|
+
style: { flexShrink: 0 }, size: '1rem', color: theme.palette.primary.main }))] }), isExternal && (_jsxs(Typography, { color: 'text.secondary', noWrap: true, variant: 'caption', children: ["(", url, ")"] }))] }), subheader: description, subheaderTypographyProps: {
|
|
29
|
+
overflow: 'hidden',
|
|
30
|
+
height: description ? '1lh' : 'unset',
|
|
31
|
+
textOverflow: 'ellipsis',
|
|
32
|
+
minWidth: 0,
|
|
33
|
+
sx: {
|
|
34
|
+
'& p': {
|
|
35
|
+
margin: 0,
|
|
36
|
+
marginBlocStart: 0,
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
} })] }) }) }));
|
|
40
|
+
};
|
|
41
|
+
export default FancyLink;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ItemIconProps } from '../../icons/ItemIcon.js';
|
|
2
|
+
type CardThumbnailProps = {
|
|
3
|
+
itemType?: ItemIconProps['type'];
|
|
4
|
+
thumbnail?: string;
|
|
5
|
+
alt: string;
|
|
6
|
+
};
|
|
7
|
+
declare const CardThumbnail: ({ thumbnail, alt, itemType, }: CardThumbnailProps) => JSX.Element;
|
|
8
|
+
export default CardThumbnail;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Box, useTheme } from '@mui/material';
|
|
3
|
+
import { ItemType } from '@lnco-ai/sdk';
|
|
4
|
+
import Thumbnail from '../../Thumbnail/Thumbnail.js';
|
|
5
|
+
import ItemIcon from '../../icons/ItemIcon.js';
|
|
6
|
+
import { DEFAULT_LIGHT_PRIMARY_COLOR } from '../../theme.js';
|
|
7
|
+
import { CARD_HEIGHT } from '../constants.js';
|
|
8
|
+
const CardThumbnail = ({ thumbnail, alt, itemType = ItemType.FOLDER, }) => {
|
|
9
|
+
const theme = useTheme();
|
|
10
|
+
if (thumbnail) {
|
|
11
|
+
return (_jsx(Thumbnail, { maxWidth: CARD_HEIGHT, maxHeight: CARD_HEIGHT, url: thumbnail, alt: alt }));
|
|
12
|
+
}
|
|
13
|
+
return (_jsx(Box, { display: 'flex', alignItems: 'center', justifyContent: 'center', bgcolor: DEFAULT_LIGHT_PRIMARY_COLOR.main, width: CARD_HEIGHT, height: '100%', flexShrink: 0, minHeight: CARD_HEIGHT, minWidth: 0, children: _jsx(ItemIcon, { type: itemType, alt: alt, color: theme.palette.primary.main }) }));
|
|
14
|
+
};
|
|
15
|
+
export default CardThumbnail;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const CARD_HEIGHT = "76px";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const CARD_HEIGHT = '76px';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { SxProps } from '@mui/material';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
export type CollapseProps = {
|
|
4
|
+
children?: ReactNode;
|
|
5
|
+
title: string;
|
|
6
|
+
sx?: SxProps;
|
|
7
|
+
onCollapse?: (c: boolean) => void;
|
|
8
|
+
};
|
|
9
|
+
declare const Collapse: ({ title, sx, children, onCollapse, }: CollapseProps) => JSX.Element;
|
|
10
|
+
export default Collapse;
|