Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add tutorial footer menu item #546

Merged
merged 3 commits into from
Feb 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"@graasp/query-client": "0.1.3",
"@graasp/sdk": "0.3.0",
"@graasp/translations": "1.3.0",
"@graasp/ui": "0.8.0",
"@graasp/ui": "0.9.0",
"@mui/icons-material": "5.11.0",
"@mui/lab": "5.0.0-alpha.117",
"@mui/material": "5.11.6",
Expand Down
41 changes: 39 additions & 2 deletions src/components/main/MainMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import AutoStoriesIcon from '@mui/icons-material/AutoStories';
import DeleteIcon from '@mui/icons-material/Delete';
import FavoriteIcon from '@mui/icons-material/Favorite';
import FolderIcon from '@mui/icons-material/Folder';
import FolderSharedIcon from '@mui/icons-material/FolderShared';
import { styled } from '@mui/material';
import ListItemIcon from '@mui/material/ListItemIcon';

import { FC, useContext } from 'react';
import { useLocation, useNavigate } from 'react-router';

import { BUILDER } from '@graasp/translations';
import { MainMenu as GraaspMainMenu, MenuItem } from '@graasp/ui';

import { TUTORIALS_LINK } from '../../config/constants';
import { useBuilderTranslation } from '../../config/i18n';
import {
FAVORITE_ITEMS_PATH,
Expand All @@ -18,20 +22,50 @@ import {
} from '../../config/paths';
import { CurrentUserContext } from '../context/CurrentUserContext';

const StyledLink = styled('a')(({ theme }) => ({
position: 'absolute',
bottom: 0,
width: '100%',
display: 'flex',
alignItems: 'center',
padding: theme.spacing(2),
boxSizing: 'border-box',
color: 'grey',
textDecoration: 'none',
'&:hover': {
color: theme.palette.primary.main,
},
}));
const StyledMenuItem = styled(MenuItem)(({ theme }) => ({
'&:hover': {
color: theme.palette.primary.main,
},
}));

const MainMenu: FC = () => {
const { t: translateBuilder } = useBuilderTranslation();
const navigate = useNavigate();
const { pathname } = useLocation();
const { t } = useBuilderTranslation();
const { data: member } = useContext(CurrentUserContext);

const goTo = (path: string) => {
navigate(path);
};

const resourcesLink = (
<StyledLink href={TUTORIALS_LINK} target="_blank">
<ListItemIcon>
<AutoStoriesIcon />
</ListItemIcon>
{t('Tutorials')}
</StyledLink>
);

const renderAuthenticatedMemberMenuItems = () => {
if (!member || !member.id) {
return (
<MenuItem
<StyledMenuItem
disabled
text={translateBuilder(BUILDER.HOME_TITLE)}
icon={<FolderIcon />}
Expand Down Expand Up @@ -70,7 +104,10 @@ const MainMenu: FC = () => {
};

return (
<GraaspMainMenu>{renderAuthenticatedMemberMenuItems()}</GraaspMainMenu>
<GraaspMainMenu fullHeight>
{renderAuthenticatedMemberMenuItems()}
{resourcesLink}
</GraaspMainMenu>
);
};

Expand Down
4 changes: 4 additions & 0 deletions src/config/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,3 +268,7 @@ export const DEFAULT_LINK_SHOW_IFRAME = false;
export const DEFAULT_LINK_SHOW_BUTTON = true;

export const GRAASP_ASSETS_URL = process.env.REACT_APP_GRAASP_ASSETS_URL;

// TODO: refer from specific endpoint /tutorials?
export const TUTORIALS_LINK =
'https://player.graasp.org/9d80d81f-ec9d-4bfb-836a-1c6b125aef2f';
pyphilia marked this conversation as resolved.
Show resolved Hide resolved
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2563,9 +2563,9 @@ __metadata:
languageName: node
linkType: hard

"@graasp/ui@npm:0.8.0":
version: 0.8.0
resolution: "@graasp/ui@npm:0.8.0"
"@graasp/ui@npm:0.9.0":
version: 0.9.0
resolution: "@graasp/ui@npm:0.9.0"
dependencies:
"@graasp/sdk": 0.2.0
clsx: 1.1.1
Expand Down Expand Up @@ -2598,7 +2598,7 @@ __metadata:
optional: true
ag-grid-react:
optional: true
checksum: 800d6b8d6d444c24594685acc0b7d82b5331bdf8be18676e8f26308b45c8ec131531f4953b11b19882d25c0c4dbd2052d5bf3af0236bbf83fe4bf227909609ae
checksum: 2e2df0cea62e62c189f7c9a69281a67451423b8cb630f282f34a5ca79987805f03e7bea564eb5f70a0037f55d5493f7c53478cd452d8f692aa617fd346c95ab6
languageName: node
linkType: hard

Expand Down Expand Up @@ -10142,7 +10142,7 @@ __metadata:
"@graasp/query-client": 0.1.3
"@graasp/sdk": 0.3.0
"@graasp/translations": 1.3.0
"@graasp/ui": 0.8.0
"@graasp/ui": 0.9.0
"@graasp/websockets": "github:graasp/graasp-websockets.git"
"@mui/icons-material": 5.11.0
"@mui/lab": 5.0.0-alpha.117
Expand Down