Skip to content

Commit

Permalink
Feat: Adds scrolling and finishes grouping visus
Browse files Browse the repository at this point in the history
  • Loading branch information
RodrigoEC committed Oct 10, 2024
1 parent 772392c commit ae1c841
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 29 deletions.
4 changes: 2 additions & 2 deletions src/app/globalStyles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ export const GlobalStyles = createGlobalStyle`
::-webkit-scrollbar {
height: 0.5rem;
width: 0.5rem;
width: 0.25rem;
padding: 10px;
}
::-webkit-scrollbar-thumb {
background: ${({ theme }) => theme.colors.green}75;
scroll-padding: 1rem;
scroll-padding: 0.2rem;
background-clip: padding-box;
}
Expand Down
69 changes: 49 additions & 20 deletions src/components/MapsMenu/MapsMenu.styles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,17 @@ export const ContentWrapper = styled.div`
align-items: center;
`;

export const Title = styled.h3`
font-weight: bold;
font-size: 1.1rem;
&::before,
&::after {
content: " - ";
}
`;

export const Form = styled.form`
display: flex;
flex-flow: column;
gap: 0.5rem;
width: 100%;
padding: 1.5rem 0 1rem 0;
box-sizing: border-box;
width: 20rem;
height: 100vh;
padding-right: 0.3rem;
max-height: 24rem;
overflow-y: scroll;
overflow-x: hidden;
`;

export const ItemWrapper = styled.div`
Expand All @@ -31,6 +26,10 @@ export const ItemWrapper = styled.div`
align-items: center;
`;

export const InfoContainer = styled.div`
margin-right: 0.45rem;
`;

export const QuestionMarkImg = styled(Icon)`
max-width: 1rem;
height: fit-content;
Expand Down Expand Up @@ -74,14 +73,40 @@ export const SubSectionWrapper = styled.div`
flex-flow: column;
gap: 0.5rem;
width: 100%;
padding: 1rem 0;
transition: 100ms;
margin-top: 0;
`;

export const IconWrapper = styled(Icon)`
color: ${({ theme }) => theme.colors.black};
transition: 100ms linear;
`;

export const FieldDetails = styled.details`
box-sizing: border-box;
display: flex;
gap: 0.5rem;
width: 100%;
padding: 0.5rem 0;
border-bottom: 1px solid ${({ theme }) => theme.colors.green}40;
color: ${({ theme }) => theme.colors.green};
&:not([open]) ${IconWrapper} {
transform: rotate(45deg);
}
&[open] ${SubSectionWrapper} {
margin-top: 1rem;
}
&:not([open]) ${SubSectionWrapper} {
margin-top: 0rem;
}
`;

export const Title = styled.h3`
font-weight: bold;
transition: 300ms;
`;

export const Summary = styled.summary`
Expand All @@ -91,13 +116,17 @@ export const Summary = styled.summary`
width: 100%;
font-weight: bold;
cursor: pointer;
color: ${({ theme }) => theme.colors["dark-gray"]};
`;
border-radius: 4px;
padding: 0.5rem;
box-sizing: border-box;
margin-left: 1px;
transition: 300ms;
export const IconWrapper = styled(Icon)`
color: ${({ theme }) => theme.colors.black};
&:hover {
background: #cdcdcd20;
}
&.spin {
animation: spin 1.5s linear infinite;
&:hover ${Title}, &:hover ${IconWrapper} {
color: ${({ theme }) => theme.colors.green};
}
`;
15 changes: 10 additions & 5 deletions src/components/MapsMenu/MapsMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import {
FieldDetails,
Summary,
IconWrapper,
InfoContainer,
Title,
} from "./MapsMenu.styles";

const MapsMenu = ({
Expand All @@ -38,6 +40,7 @@ const MapsMenu = ({
const [mapTypes, setMapTypes] = useState<{ [key: string]: IFormItem[] }>({});
const [currentImagedata, setcurrentImageData] = useState<IImageData>({});
const [currentName, setCurrentName] = useState<string>("");
const [currentCategory, setCurrentCategory] = useState<string>("");
const router = useRouter();
const pathname = usePathname();
const searchParams = useSearchParams();
Expand Down Expand Up @@ -65,6 +68,7 @@ const MapsMenu = ({
if (item.id === newValue) {
setCurrentName(item.id);
setcurrentImageData(item.imageData);
currentCategory === "" && setCurrentCategory(item.type);
}

return {
Expand Down Expand Up @@ -92,6 +96,7 @@ const MapsMenu = ({

useEffect(() => {
onItemChange(initialValues.name);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [initialValues]);

return (
Expand All @@ -108,10 +113,10 @@ const MapsMenu = ({
{Object.keys(mapTypes)
.sort((a, b) => b.localeCompare(a))
.map((type) => (
<FieldDetails key={type}>
<FieldDetails key={type} open={currentCategory === type}>
<Summary>
<h4>{type}</h4>
<IconWrapper id="close" size={16} stroke-width={3} />
<Title>{type}</Title>
<IconWrapper id="close" size={16} stroke-width={2} />
</Summary>
<SubSectionWrapper>
{mapTypes[type]
Expand All @@ -127,7 +132,7 @@ const MapsMenu = ({
onClick={onQuestionSelect}
onChange={onItemChange}
/>
<div
<InfoContainer
onClick={() => onQuestionSelect(item.id)}
title={`Sobre ${item.name}`}
>
Expand All @@ -136,7 +141,7 @@ const MapsMenu = ({
height={20}
width={20}
/>
</div>
</InfoContainer>
</ItemWrapper>
);
})}
Expand Down
2 changes: 0 additions & 2 deletions src/components/VisuItem/VisuItem.styles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ export const ItemWrapper = styled.div`
gap: 0.5rem;
width: 100%;
padding: 0.5rem 1rem 0.5rem 0.5rem;
background-color: ${({ theme }) => theme.colors.white};
box-shadow: 0px 0px 2px #e0e0e0;
border-radius: 4px;
`;

Expand Down

0 comments on commit ae1c841

Please sign in to comment.