Skip to content

Commit

Permalink
add mobile nav in project
Browse files Browse the repository at this point in the history
  • Loading branch information
lachlanglen committed Nov 7, 2023
1 parent 8555c6a commit 4f193bf
Show file tree
Hide file tree
Showing 4 changed files with 154 additions and 0 deletions.
10 changes: 10 additions & 0 deletions apps/potlock/widget/Project/Body.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ const BodyContainer = styled.div`
align-items: flex-start;
justify-content: flex-start;
gap: 48px;
@media screen and (max-width: 768px) {
max-width: 90vw;
}
`;

const NameContainer = styled.div`
Expand Down Expand Up @@ -143,6 +147,12 @@ return (
/>
</div>
<Actions />
<Widget
src={`${ownerId}/widget/Project.NavOptionsMobile`}
props={{
...props,
}}
/>
<div style={{ width: "100%" }}>
<Widget
src={props.navOptions.find((option) => option.id == props.nav).source}
Expand Down
67 changes: 67 additions & 0 deletions apps/potlock/widget/Project/NavOptionsMobile.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
const { navOptions } = props;

const getSelectedNavOption = () => {
const navOption = navOptions.find((option) => option.id == props.nav);
return navOption ?? navOptions[0];
};

const NavOptionsContainer = styled.div`
align-items: center;
justify-content: flex-start;
display: none;
overflow-x: auto;
white-space: nowrap;
-webkit-overflow-scrolling: touch; // For momentum scroll on iOS devices
@media screen and (max-width: 768px) {
display: flex;
max-width: 95vw;
flex-shrink: 0; // Prevent the container from shrinking
}
`;

const NavOption = styled.a`
position: relative;
font-size: 14px;
padding: 8px 16px;
font-weight: ${(props) => (props.selected ? 600 : 400)};
color: ${(props) => (props.selected ? "#DD3345" : props.disabled ? "lightgray" : "#7B7B7B")};
&:focus,
&:active {
text-decoration: none; /* This removes the underline */
}
&::after {
content: "";
display: ${(props) => (props.selected ? "block" : "none")};
position: absolute;
bottom: 0;
left: 50%; // Center the underline
transform: translateX(-50%); // Center the underline
width: 16px; // Width of the underline
height: 2px; // Thickness of the underline
background-color: #dd3345;
}
`;

return (
<NavOptionsContainer>
{navOptions.map((option) => {
const selected = option.id == getSelectedNavOption().id;
return option.disabled ? (
<NavOption selected={selected} disabled={option.disabled}>
{option.label}
</NavOption>
) : (
<NavOption
selected={selected}
disabled={option.disabled}
href={`?tab=project&projectId=${props.projectId}&nav=${option.id}`}
>
{option.label}
</NavOption>
);
})}
</NavOptionsContainer>
);
10 changes: 10 additions & 0 deletions build/potlock/src/Project/Body.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ const BodyContainer = styled.div`
align-items: flex-start;
justify-content: flex-start;
gap: 48px;
@media screen and (max-width: 768px) {
max-width: 90vw;
}
`;

const NameContainer = styled.div`
Expand Down Expand Up @@ -143,6 +147,12 @@ return (
/>
</div>
<Actions />
<Widget
src={`${ownerId}/widget/Project.NavOptionsMobile`}
props={{
...props,
}}
/>
<div style={{ width: "100%" }}>
<Widget
src={props.navOptions.find((option) => option.id == props.nav).source}
Expand Down
67 changes: 67 additions & 0 deletions build/potlock/src/Project/NavOptionsMobile.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
const { navOptions } = props;

const getSelectedNavOption = () => {
const navOption = navOptions.find((option) => option.id == props.nav);
return navOption ?? navOptions[0];
};

const NavOptionsContainer = styled.div`
align-items: center;
justify-content: flex-start;
display: none;
overflow-x: auto;
white-space: nowrap;
-webkit-overflow-scrolling: touch; // For momentum scroll on iOS devices
@media screen and (max-width: 768px) {
display: flex;
max-width: 95vw;
flex-shrink: 0; // Prevent the container from shrinking
}
`;

const NavOption = styled.a`
position: relative;
font-size: 14px;
padding: 8px 16px;
font-weight: ${(props) => (props.selected ? 600 : 400)};
color: ${(props) => (props.selected ? "#DD3345" : props.disabled ? "lightgray" : "#7B7B7B")};
&:focus,
&:active {
text-decoration: none; /* This removes the underline */
}
&::after {
content: "";
display: ${(props) => (props.selected ? "block" : "none")};
position: absolute;
bottom: 0;
left: 50%; // Center the underline
transform: translateX(-50%); // Center the underline
width: 16px; // Width of the underline
height: 2px; // Thickness of the underline
background-color: #dd3345;
}
`;

return (
<NavOptionsContainer>
{navOptions.map((option) => {
const selected = option.id == getSelectedNavOption().id;
return option.disabled ? (
<NavOption selected={selected} disabled={option.disabled}>
{option.label}
</NavOption>
) : (
<NavOption
selected={selected}
disabled={option.disabled}
href={`?tab=project&projectId=${props.projectId}&nav=${option.id}`}
>
{option.label}
</NavOption>
);
})}
</NavOptionsContainer>
);

0 comments on commit 4f193bf

Please sign in to comment.