Skip to content
Open
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
11 changes: 9 additions & 2 deletions src/components/modal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,15 @@ function getModalStyle(width: number, height: number) {
if (!width || !height) {
return {};
}
const topOffset = window.innerHeight / 2 - height / 2;
const leftOffset = window.innerWidth / 2 - width / 2;
const viewportPadding = 2;
const topOffset = Math.max(
viewportPadding,
window.innerHeight / 2 - height / 2
);
const leftOffset = Math.max(
viewportPadding,
window.innerWidth / 2 - width / 2
);

return {
top: `${topOffset}px`,
Expand Down
27 changes: 21 additions & 6 deletions src/components/modal/styles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,32 @@ import { shadow, _scrollbars } from "@styles/_common";
export const content = (theme: Theme): SerializedStyles => css`
position: absolute;
outline: none;
max-width: calc(100vw - 6px);
max-height: calc(100vh - 6px);
& > div {
max-height: 80vh;
overflow-y: scroll;
max-height: calc(100vh - 6px);
overflow-y: auto;
overflow-x: hidden;
color: ${theme.textColor};
position: relative;
border: 2px solid ${theme.line};
border-radius: 6px;
border: 0;
border-radius: 8px;
background-color: ${theme.background};
${shadow}
box-sizing: content-box;
padding: 16px 32px 24px;
box-sizing: border-box;
padding: 20px 28px 24px;
-webkit-overflow-scrolling: touch;
${_scrollbars(theme)}
}

@media (max-width: 760px) {
max-width: calc(100vw - 4px);
max-height: calc(100vh - 4px);

& > div {
max-height: calc(100vh - 4px);
border-radius: 12px;
padding: 18px 16px 20px;
}
}
`;
166 changes: 142 additions & 24 deletions src/components/profile/profile-lists.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import React from "react";
import React, { useState } from "react";
import { Link } from "react-router";
import { useDispatch, useSelector } from "@root/store";
import { List, ListItem, ListItemText } from "@mui/material";
import useMediaQuery from "@mui/material/useMediaQuery";
import LockIcon from "@mui/icons-material/Lock";
import PublicIcon from "@mui/icons-material/Public";
import {
selectFollowingLoading,
selectFollowersLoading,
Expand All @@ -15,7 +18,10 @@ import SettingsIcon from "@mui/icons-material/Settings";
import DeleteIcon from "@mui/icons-material/DeleteOutline";
import VisibilityIcon from "@mui/icons-material/Visibility";
import VisibilityOffIcon from "@mui/icons-material/VisibilityOff";
import MoreVertIcon from "@mui/icons-material/MoreVert";
import Tooltip from "@mui/material/Tooltip";
import Menu from "@mui/material/Menu";
import MenuItem from "@mui/material/MenuItem";
import {
StyledListItemContainer,
StyledListItemTopRowText,
Expand All @@ -39,14 +45,89 @@ const ProjectListItem = ({
}) => {
const dispatch = useDispatch();
const { isPublic, projectUid, name, description, tags } = project;
const isMobileLayout = useMediaQuery("(max-width: 760px)");
const [menuAnchor, setMenuAnchor] = useState<HTMLElement | null>(null);

const closeMenu = () => {
setMenuAnchor(null);
};

const openMenu = (event: React.MouseEvent<HTMLElement>) => {
event.preventDefault();
event.stopPropagation();
setMenuAnchor(event.currentTarget);
};

const onEditProject = (event: React.MouseEvent<HTMLElement>) => {
dispatch(editProject(project));
event.preventDefault();
event.stopPropagation();
closeMenu();
};

const onDeleteProject = (event: React.MouseEvent<HTMLElement>) => {
dispatch(deleteProject(project));
event.preventDefault();
event.stopPropagation();
closeMenu();
};

const onTogglePublic = (event: React.MouseEvent<HTMLElement>) => {
dispatch(markProjectPublic(projectUid, !isPublic));
event.preventDefault();
event.stopPropagation();
closeMenu();
};

return (
<div style={{ position: "relative" }}>
<Link to={"/editor/" + projectUid}>
<ListItem alignItems="flex-start">
<StyledListItemContainer isProfileOwner={isProfileOwner}>
<StyledListItemTopRowText>
<ListItemText
primary={name}
primary={
<span
style={{
display: "flex",
alignItems: "center",
gap: 8
}}
>
<span>{name}</span>
<span
style={{
display: "inline-flex",
alignItems: "center",
gap: 4,
fontSize: 12,
lineHeight: 1,
border: "1px solid currentColor",
borderRadius: 12,
padding: "3px 8px",
opacity: isPublic ? 0.75 : 1,
fontWeight: 600
}}
aria-label={
isPublic
? "Project is public"
: "Project is private"
}
title={
isPublic
? "Project is public"
: "Project is private"
}
>
{isPublic ? (
<PublicIcon fontSize="inherit" />
) : (
<LockIcon fontSize="inherit" />
)}
{isPublic ? "Public" : "Private"}
</span>
</span>
}
secondary={description}
/>
</StyledListItemTopRowText>
Expand All @@ -69,7 +150,9 @@ const ProjectListItem = ({
</StyledListItemChipsRow>
</StyledListItemContainer>
</ListItem>
{isProfileOwner && <StyledListButtonsContainer />}
{isProfileOwner && !isMobileLayout && (
<StyledListButtonsContainer />
)}
</Link>
<StyledListPlayButtonContainer>
<ListPlayButton
Expand All @@ -79,33 +162,74 @@ const ProjectListItem = ({
iconForegroundColor={project.iconForegroundColor}
/>
</StyledListPlayButtonContainer>
{isProfileOwner && (
{isProfileOwner && isMobileLayout && (
<>
<Tooltip title="Project actions" followCursor>
<div css={SS.mobileActionsContainer}>
<div
css={SS.mobileActionsButton}
onClick={openMenu}
>
<MoreVertIcon />
</div>
</div>
</Tooltip>
<Menu
anchorEl={menuAnchor}
open={Boolean(menuAnchor)}
onClose={closeMenu}
anchorOrigin={{
vertical: "bottom",
horizontal: "right"
}}
transformOrigin={{
vertical: "top",
horizontal: "right"
}}
>
<MenuItem onClick={onTogglePublic}>
{isPublic ? (
<VisibilityOffIcon />
) : (
<VisibilityIcon />
)}
<span style={{ marginLeft: 8 }}>
{isPublic
? "Make project private"
: "Make project public"}
</span>
</MenuItem>
<MenuItem onClick={onEditProject}>
<SettingsIcon />
<span style={{ marginLeft: 8 }}>
Rename/Edit project
</span>
</MenuItem>
<MenuItem onClick={onDeleteProject}>
<DeleteIcon />
<span
style={{ marginLeft: 8 }}
>{`Delete ${name}`}</span>
</MenuItem>
</Menu>
</>
)}
{isProfileOwner && !isMobileLayout && (
<>
<Tooltip title="Toggle project settings" followCursor>
<div css={SS.settingsIconContainer}>
<div
css={SS.settingsIcon}
key={projectUid}
onClick={(event) => {
dispatch(editProject(project));
event.preventDefault();
event.stopPropagation();
}}
onClick={onEditProject}
>
<SettingsIcon />
</div>
</div>
</Tooltip>
<Tooltip title={`Delete ${name}`} followCursor>
<div css={SS.deleteIconContainer}>
<div
css={SS.deleteIcon}
onClick={(event) => {
dispatch(deleteProject(project));
event.preventDefault();
event.stopPropagation();
}}
>
<div css={SS.deleteIcon} onClick={onDeleteProject}>
<DeleteIcon />
</div>
</div>
Expand All @@ -122,13 +246,7 @@ const ProjectListItem = ({
<div
css={SS.publicIcon}
style={{ opacity: isPublic ? 1 : 0.6 }}
onClick={(event) => {
dispatch(
markProjectPublic(projectUid, !isPublic)
);
event.preventDefault();
event.stopPropagation();
}}
onClick={onTogglePublic}
>
{isPublic ? (
<VisibilityIcon />
Expand Down
30 changes: 28 additions & 2 deletions src/components/profile/profile-ui.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ import { css } from "@emotion/react";

export const ProfileContainer = styled.div`
${isMobile()
? `padding: 12.5vw;`
? `padding: 16px;
box-sizing: border-box;`
: `display: grid;
grid-template-columns: 24px 250px 800px;
grid-template-rows: 50px 175px 1fr 70px;
grid-auto-rows: minmax(90px, auto);`}
width: 100%;
overflow-x: hidden;
`;
export const IDContainer = styled(Card)`
grid-row-start: 2;
Expand Down Expand Up @@ -117,7 +119,7 @@ export const NameSectionWrapper = styled.div`
display: grid;
grid-template-rows: 1fr auto;
grid-template-columns: 1fr;
min-width: 680px;
min-width: ${isMobile() ? "0" : "680px"};
`;
export const NameSection = styled.div`
grid-row: 2;
Expand All @@ -135,6 +137,8 @@ export const ContentSection = styled.div<any>`
border-radius: 4px;
box-shadow: 0px 0px 4px rgba(0, 0, 0, 0.8);
width: 100%;
max-width: 100%;
overflow-x: hidden;
`;
export const ContentTabsContainer = styled.div`
background-color: rgba(0, 0, 0, 0.2);
Expand All @@ -155,8 +159,12 @@ export const ListContainer = styled.div`
padding-top: 10px;
grid-row: 3;
grid-column: 1;
width: 100%;
box-sizing: border-box;
& > ul {
padding: 0 !important;
width: 100%;
box-sizing: border-box;
}
.MuiListItem-button {
padding: 8px 24px !important;
Expand Down Expand Up @@ -263,3 +271,21 @@ export const fabButton = css`
align-items: center;
justify-content: space-between;
`;

export const mobileNavigationContainer = (theme: any) => css`
background-color: ${theme.headerBackground};
position: fixed;
width: 100%;
bottom: 0;
left: 0;
z-index: 10;
border-top: 1px solid;
`;

export const mobileNavigationButton = (theme: any) => css`
color: ${theme.headerTextColor};
`;

export const profileMobileBottomSpacer = css`
height: 72px;
`;
Loading
Loading