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

[chore] Styling of Project Modal (w/o KDMs) #45

Merged
merged 10 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from 7 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
88 changes: 54 additions & 34 deletions components/ProjectModal/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
'use client';

import React, { useEffect, useState } from 'react';
import Modal from 'react-modal';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our project modal component is built off of an already existing React Modal library that we are importing, so we shouldn't remove this.

import { FiX, FiZap } from 'react-icons/fi';
import { queryProjectbyId } from '../../api/supabase/queries/query';
import * as texts from '../../styles/texts';
import { Project } from '../../types/schema';
import * as styles from './styles';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If possible, I think we should import all of the styled components individually as their names instead of as styles so that we don't have to start everything with "styles.---". It looks kinda hard to read with all of the "styles.---".

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah I think in my previous project we also imported all styling individually instead of using styles. or texts. So I agree that we should change it to import individually. E.g. in texts.ts I imported all the fonts as: import { CoinbaseMono, CoinbaseSans, CoinbaseText } from './fonts'; instead of import * as fonts from ./fonts

I will also make this announcement on slack


Expand Down Expand Up @@ -46,39 +47,58 @@

return (
<div>
<Modal
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need this modal component.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just tested it out and I think that this is causing the issue. So instead of making a Modal styled component, revert to julee's previous code where he did:

<Modal isOpen={openFirst} style={{ overlay: styles.modalOverlayStyles, content: styles.modalContentStyles, }} >

You can keep everything else as a styled component though!

isOpen={openFirst}
style={{
overlay: styles.modalOverlayStyles,
content: styles.modalContentStyles,
}}
>
<div style={styles.projectContainerStyles}>
<img
src={project_image ? project_image : ''}
alt="Project Image"
style={styles.projectImageStyles}
/>
<div style={styles.searchBarStyles}>Search</div>
<div style={styles.projectNameStyles}>
<div style={styles.developerStyles}>
Developer - {developer}
<button onClick={closeModal} style={styles.closeButtonStyles}>
Close
</button>
</div>
<div>{project_name}</div>
<div>{project_status}</div>
<div>{renewable_energy_technology}</div>
</div>
</div>
<div>{size}</div>
<div style={styles.additionalInfoStyles}>
DETAILS
<br></br>
{additional_information}
</div>
</Modal>
<styles.ModalContent isOpen={openFirst}>
<styles.ModalOverlay>
<styles.SearchBar>Search</styles.SearchBar>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove the search bar (this will directly be on the home page)

<styles.ProjectDetailsBorder>
<styles.ProjectDetails>
<img

Check warning on line 55 in components/ProjectModal/index.tsx

View workflow job for this annotation

GitHub Actions / Run ESLint, Prettier, and TypeScript compiler

Using `<img>` could result in slower LCP and higher bandwidth. Consider using `<Image />` from `next/image` to automatically optimize images. This may incur additional usage or cost from your provider. See: https://nextjs.org/docs/messages/no-img-element

Check warning on line 55 in components/ProjectModal/index.tsx

View workflow job for this annotation

GitHub Actions / Run ESLint, Prettier, and TypeScript compiler

Using `<img>` could result in slower LCP and higher bandwidth. Consider using `<Image />` from `next/image` to automatically optimize images. This may incur additional usage or cost from your provider. See: https://nextjs.org/docs/messages/no-img-element
src={project_image ? project_image : ''}
alt="Project Image"
style={styles.projectImageStyles}
/>
<styles.ProjectOverview>
<styles.Developer>
<texts.BodyText1>Developer - {developer}</texts.BodyText1>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to change the dash ( - ) to an arrow like in Josh's figma design? If not, let Josh know and see what he decides.

<styles.CloseButton onClick={closeModal}>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you make the pointer arrow become the hand when it hovers on a button (like how it normally looks on other websites)? You can use this for help https://stackoverflow.com/questions/3087975/how-to-change-the-cursor-into-a-hand-when-a-user-hovers-over-a-list-item . You just need to add cursor: pointer; to the style.ts
Like this:
Screenshot 2024-10-28 at 12 57 41 PM

<FiX size={20} color="#000" />
</styles.CloseButton>
</styles.Developer>
<styles.ProjectName>
<texts.Heading1>{project_name?.toUpperCase()}</texts.Heading1>
</styles.ProjectName>
<styles.ProjectFilterWrapper>
<styles.ProjectFilter>
<texts.TagText1>{project_status}</texts.TagText1>
</styles.ProjectFilter>
<styles.ProjectFilter>
<texts.TagText1>
{renewable_energy_technology}
</texts.TagText1>
</styles.ProjectFilter>
</styles.ProjectFilterWrapper>
</styles.ProjectOverview>
<styles.ProjectSize>
<texts.AccentText1>
<FiZap size={42} />
{size}
</texts.AccentText1>
<texts.AccentText2>MW / Mo</texts.AccentText2>
</styles.ProjectSize>
<styles.Divider />
<styles.AdditionalInfo>
<styles.DetailsContainer>
<texts.BodyText1>DETAILS</texts.BodyText1>
<styles.Divider />
</styles.DetailsContainer>
<styles.AdditionalText>
<texts.BodyText1>{additional_information}</texts.BodyText1>
</styles.AdditionalText>
</styles.AdditionalInfo>
</styles.ProjectDetails>
</styles.ProjectDetailsBorder>
</styles.ModalOverlay>
</styles.ModalContent>
</div>
);
}
206 changes: 139 additions & 67 deletions components/ProjectModal/styles.ts
Original file line number Diff line number Diff line change
@@ -1,81 +1,153 @@
import { CSSProperties } from 'react';
import Modal from 'react-modal';
import styled from 'styled-components';
import COLORS from '../../styles/colors';

export const modalOverlayStyles: CSSProperties = {
width: '310px',
height: '100%',
};
export const ModalOverlay = styled.div`
width: 310px;
height: 100%;
`;

export const modalContentStyles: CSSProperties = {
display: 'flex',
width: '360px',
height: '100%',
top: '0',
bottom: '0',
left: '0',
right: '0',
flexShrink: 0,
flexDirection: 'column',
alignItems: 'center',
};
export const ModalContent = styled(Modal)`
display: flex;
width: 360px;
height: 100%;
flex-direction: column;
align-items: center;
`;

export const projectContainerStyles: CSSProperties = {
position: 'relative',
width: '360px',
height: '300px',
overflow: 'hidden',
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
};
export const SearchBar = styled.div`
width: 340px;
height: 50px;
display: flex;
flex-shrink: 0;
border-radius: 8px;
border: 1px solid rgba(46, 58, 89, 0.5);
background: ${COLORS.white};
box-shadow: 0px 4px 5px rgba(255, 255, 255, 0.25);
align-items: center;
justify-content: center;
z-index: 2;
position: relative;
margin-top: 1.25rem;
margin-bottom: 1.25rem;
`;

export const ProjectDetailsBorder = styled.div`
width: 356px;
height: 82%;
border-radius: var(--Spacing-Small, 16px);
border: 0.75px solid var(--WorldPeas-White, #fff);
background: linear-gradient(
180deg,
rgba(250, 250, 250, 0.32) 0%,
rgba(238, 238, 238, 0.65) 100%
);
backdrop-filter: blur(7.5px);
padding-top: 0.625rem;
padding-bottom: 0.625rem;
display: flex;
flex-direction: column;
align-items: center;
`;

export const ProjectDetails = styled.div`
display: flex;
flex-direction: column;
align-items: center;
border-radius: var(--Spacing-Small, 16px);
height: 100%;
background: ${COLORS.white};
width: 340px;
`;

export const projectImageStyles: CSSProperties = {
position: 'absolute',
width: '359px',
height: '269px',
width: '340px',
height: '250px',
objectFit: 'cover',
borderRadius: '8px 8px 0px 0px',
};

export const searchBarStyles: CSSProperties = {
width: '310px',
height: '50px',
display: 'flex',
flexShrink: '0',
borderRadius: '8px',
border: '1px solid rgba(46, 58, 89, 0.50)',
background: 'var(--WorldPeas-White, #FFF)',
boxShadow: '0px 4px 5px 0px rgba(255, 255, 255, 0.25)',
alignItems: 'center',
justifyContent: 'center',
zIndex: 2,
position: 'relative',
};
export const ProjectOverview = styled.div`
display: flex;
flex-direction: column;
width: 316px;
height: 129px;
margin-top: 9.5rem;
border-radius: 8px;
background: ${COLORS.white};
box-shadow:
0px 2px 6px rgba(77, 87, 114, 0.08),
0px -2px 5px rgba(255, 255, 255, 0.1);
position: relative;
box-sizing: border-box;
padding: 1rem;
`;

export const projectNameStyles: CSSProperties = {
width: '315px',
height: '135px',
marginTop: '152px',
flexShrink: '0',
borderRadius: '8px',
background: 'var(--WorldPeas-White, #FFF)',
boxShadow:
'0px 2px 6px 0px rgba(77, 87, 114, 0.08), 0px -2px 5px 0px rgba(255, 255, 255, 0.10)',
position: 'relative',
padding: '10px',
};
export const Developer = styled.div`
display: flex;
justify-content: space-between;
align-items: center;
`;

export const developerStyles: CSSProperties = {
display: 'flex',
justifyContent: 'space-between',
zIndex: 2,
};
export const ProjectName = styled.div`
overflow: hidden;
text-overflow: ellipsis;
padding-bottom: 0.75rem;
`;

export const closeButtonStyles: CSSProperties = {
position: 'absolute',
top: '10px',
right: '10px',
zIndex: 3,
};
export const ProjectFilterWrapper = styled.div`
display: flex;
align-items: center;
gap: 0.5rem;
`;

export const additionalInfoStyles: CSSProperties = {
width: '315px',
};
export const ProjectFilter = styled.div`
border-radius: 100px;
border: 0.5px solid rgba(46, 58, 89, 0.25);
display: inline-flex;
height: 22px;
padding: 0.1875rem 0.625rem;
flex-direction: column;
justify-content: center;
align-items: center;
`;

export const CloseButton = styled.button`
box-shadow: none;
background: none;
border: none;
`;

export const ProjectSize = styled.div`
display: flex;
align-items: baseline;
width: 260px;
padding-top: 1.2rem;
gap: 0.5rem;
`;

export const Divider = styled.hr`
width: 260px;
border: 0;
height: 1px;
margin: 0px 0;
background: rgba(46, 58, 89, 0.1);
`;

export const AdditionalInfo = styled.div`
width: 260px;
padding: 1.25rem;
`;

export const DetailsContainer = styled.div`
display: flex;
align-items: center;
width: 100%;
gap: 0.5rem;
`;

export const AdditionalText = styled.div`
padding-top: 1.25rem;
`;
21 changes: 11 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,29 @@
},
"dependencies": {
"@googlemaps/markerclusterer": "^2.5.3",
"@supabase/supabase-js": "^2.45.4",
"@supabase/supabase-js": "^2.45.6",
"@types/react-modal": "^3.16.3",
"@vis.gl/react-google-maps": "^1.3.0",
"dotenv": "^16.4.5",
"next": "^14.2.13",
"react": "^18",
"react-dom": "^18",
"next": "^14.2.16",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-icons": "^5.3.0",
"react-modal": "^3.16.1",
"styled-components": "^6.1.13"
},
"devDependencies": {
"@ianvs/prettier-plugin-sort-imports": "^4.3.1",
"@types/node": "^20.16.5",
"@types/react": "^18.3.5",
"@types/react-dom": "^18.3.0",
"@types/node": "^20.17.1",
"@types/react": "^18.3.12",
"@types/react-dom": "^18.3.1",
"@types/styled-components": "^5.1.34",
"eslint": "^8",
"eslint": "^8.57.1",
"eslint-config-next": "14.2.8",
"eslint-config-prettier": "^9.1.0",
"husky": "^9.1.5",
"husky": "^9.1.6",
"prettier": "^3.3.3",
"typescript": "^5",
"typescript": "^5.6.3",
"yarnhook": "^0.6.2"
}
}
Loading