-
Notifications
You must be signed in to change notification settings - Fork 1
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] Direct Search Item Component #62
Merged
Merged
Changes from 4 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
da6afec
Added Project Item component
jjstnlee b478288
meep
jjstnlee 3fcf0f0
fixed font issues kinda
jjstnlee e12a5bc
minor fixes
jjstnlee 02c04da
chore: styling fixes (#64)
itsliterallymonique 31d0654
[feat] Customized Icons for Renewable Energy Technology and Status (i…
nehaahussain 4c75f8f
Added Project Item component
jjstnlee 12a112e
meep
jjstnlee a291d8e
fixed font issues kinda
jjstnlee f6d50c5
minor fixes
jjstnlee d7e8a87
Used neha's energy type icons
jjstnlee 5ff09b3
Used neha's energy type icons
jjstnlee 43cdc0f
changed svg properties to camelCase
jjstnlee File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
'use client'; | ||
|
||
import { CSSProperties } from 'react'; | ||
import ProjectItem from '@/components/ProjectItem'; | ||
|
||
export default function Home() { | ||
return ( | ||
<main style={mainStyles}> | ||
<ProjectItem project_id={1}></ProjectItem> | ||
</main> | ||
); | ||
} | ||
|
||
// CSS styles | ||
|
||
const mainStyles: CSSProperties = { | ||
width: '100%', | ||
height: '100%', | ||
display: 'flex', | ||
flexDirection: 'column', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
}; |
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,175 @@ | ||
'use client'; | ||
|
||
import { useEffect, useState } from 'react'; | ||
import Image from 'next/image'; | ||
import { | ||
queryDefaultImages, | ||
queryProjectbyId, | ||
} from '@/api/supabase/queries/query'; | ||
import { | ||
InProgressIcon, | ||
OperationalIcon, | ||
SmallEnergyStorageIcon, | ||
SmallGeothermalIcon, | ||
SmallHydroelectricIcon, | ||
SmallLandBasedWindIcon, | ||
SmallOffshoreWindIcon, | ||
SmallPumpedStorage, | ||
SmallSizeIcon, | ||
SmallSolarPowerIcon, | ||
} from '@/assets/Icons/icons'; | ||
import { Heading2, TagText2 } from '@/styles/texts'; | ||
import { Project } from '@/types/schema'; | ||
import ProjectModal from '../ProjectModal'; | ||
import { | ||
projectImageStyles, | ||
ProjectInfo, | ||
ProjectName, | ||
ProjectSize, | ||
ProjectSizeAndType, | ||
ProjectStatus, | ||
ProjectType, | ||
StyledProjectItem, | ||
} from './styles'; | ||
|
||
export default function ProjectItem({ project_id }: { project_id: number }) { | ||
const [project, setProject] = useState<Project | null>(null); | ||
const [defaultImage, setDefaultImage] = useState<string | null>(null); | ||
const [modalOpen, setModalOpen] = useState(false); | ||
|
||
useEffect(() => { | ||
queryProjectbyId(project_id).then(data => { | ||
setProject(data); | ||
}); | ||
}, [project_id]); | ||
|
||
useEffect(() => { | ||
// Fetch default image when project data is available | ||
const fetchDefaultImage = async () => { | ||
if (!project?.project_image && project?.renewable_energy_technology) { | ||
try { | ||
const fetchedImage = await queryDefaultImages( | ||
project.renewable_energy_technology, | ||
); | ||
setDefaultImage(fetchedImage.default_image); | ||
} catch (error) { | ||
console.error('Error fetching default image:', error); | ||
} | ||
} | ||
}; | ||
fetchDefaultImage(); | ||
}, [project]); | ||
|
||
const { | ||
// id, | ||
project_name, | ||
renewable_energy_technology, | ||
size, | ||
// developer, | ||
// longitude, | ||
// latitude, | ||
project_status, | ||
// county, | ||
// town, | ||
// region, | ||
// state_senate_district, | ||
// assembly_district, | ||
project_image, | ||
// additional_information, | ||
// key_development_milestones, | ||
// proposed_cod, | ||
// approved | ||
} = project || {}; | ||
|
||
const getProjectImageSrc = () => { | ||
return project_image || defaultImage || ''; | ||
}; | ||
|
||
// Sets status label to "Operational" or "In Progress" | ||
let projectStatus = project_status; | ||
if (project_status !== 'Operational') { | ||
projectStatus = 'In Progress'; | ||
} | ||
|
||
// Sets status icon to OperationalIcon or InProgressIcon | ||
let statusIcon = <OperationalIcon />; | ||
if (project_status !== 'Operational') { | ||
statusIcon = <InProgressIcon />; | ||
} | ||
|
||
const projectImageAlt = project_image | ||
? `${project_name} project image` | ||
: defaultImage | ||
? `${renewable_energy_technology} default image` | ||
: 'No image available'; | ||
|
||
let projectTypeIcon = <></>; | ||
switch (renewable_energy_technology) { | ||
case 'Land-Based Wind': | ||
projectTypeIcon = <SmallLandBasedWindIcon />; | ||
break; | ||
case 'Solar PV': | ||
projectTypeIcon = <SmallSolarPowerIcon />; | ||
break; | ||
case 'Hydroelectric': | ||
projectTypeIcon = <SmallHydroelectricIcon />; | ||
break; | ||
case 'Offshore Wind': | ||
projectTypeIcon = <SmallOffshoreWindIcon />; | ||
break; | ||
case 'Geothermal': | ||
projectTypeIcon = <SmallGeothermalIcon />; | ||
break; | ||
case 'Energy Storage': | ||
projectTypeIcon = <SmallEnergyStorageIcon />; | ||
break; | ||
case 'Pumped Storage': | ||
projectTypeIcon = <SmallPumpedStorage />; | ||
break; | ||
} | ||
|
||
const handleProjectClick = () => { | ||
setModalOpen(true); | ||
}; | ||
|
||
if (modalOpen) { | ||
return ( | ||
<ProjectModal | ||
project_id={project_id} | ||
closeModal={() => setModalOpen(false)} | ||
openFirst={true} | ||
/> | ||
); | ||
} | ||
|
||
return ( | ||
<StyledProjectItem onClick={handleProjectClick}> | ||
<ProjectInfo> | ||
<Heading2> | ||
<ProjectName>{project_name?.toUpperCase()}</ProjectName> | ||
</Heading2> | ||
<ProjectStatus> | ||
{statusIcon} | ||
<TagText2>{projectStatus}</TagText2> | ||
</ProjectStatus> | ||
<ProjectSizeAndType> | ||
<ProjectSize> | ||
<SmallSizeIcon /> | ||
<TagText2>{size} MW</TagText2> | ||
</ProjectSize> | ||
<ProjectType> | ||
{projectTypeIcon} | ||
<TagText2>{renewable_energy_technology}</TagText2> | ||
</ProjectType> | ||
</ProjectSizeAndType> | ||
</ProjectInfo> | ||
<Image | ||
src={getProjectImageSrc()} | ||
alt={projectImageAlt} | ||
width={340} | ||
height={250} | ||
style={projectImageStyles} | ||
/> | ||
</StyledProjectItem> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import { CSSProperties } from 'react'; | ||
import styled from 'styled-components'; | ||
|
||
export const StyledProjectItem = styled.button` | ||
display: flex; | ||
align-items: center; | ||
width: 20rem; | ||
height: 7.625rem; | ||
flex-shrink: 0; | ||
border-radius: 18px; | ||
border-top: 1px solid rgba(46, 58, 89, 0.1); | ||
border-bottom: 1px solid rgba(46, 58, 89, 0.1); | ||
border-left: 0; | ||
border-right: 0; | ||
background: rgba(255, 255, 255, 0.9); | ||
padding-top: 0; | ||
padding-bottom: 0; | ||
`; | ||
|
||
export const projectImageStyles: CSSProperties = { | ||
width: '7.75rem', | ||
height: '6.75rem', | ||
borderRadius: '0px 12px 12px 0px', | ||
opacity: '0.9', | ||
background: 'url(<path-to-image>) lightgray 50% / cover no-repeat', | ||
marginLeft: '-0.9375rem', | ||
}; | ||
|
||
export const ProjectInfo = styled.div` | ||
width: 12.625rem; | ||
height: 6.75rem; | ||
border-radius: 0px 7.5px 7.5px 0px; | ||
border-right: 1px solid #eff0f3; | ||
background: rgba(255, 255, 255, 1); | ||
box-shadow: 1px 0px 4px 0px rgba(255, 255, 255, 0.25); | ||
padding-left: 0.875rem; | ||
z-index: 2; | ||
`; | ||
|
||
export const ProjectName = styled.div` | ||
margin-top: 1.5rem; | ||
text-align: left; | ||
`; | ||
|
||
export const ProjectStatus = styled.div` | ||
display: flex; | ||
justify-content: flex-start; | ||
align-items: center; | ||
gap: 0.3125rem; | ||
`; | ||
|
||
export const ProjectSizeAndType = styled.div` | ||
display: flex; | ||
gap: 0.5rem; | ||
margin-top: 1.5rem; | ||
`; | ||
|
||
export const ProjectSize = styled.div` | ||
display: flex; | ||
align-items: center; | ||
gap: 0.25rem; | ||
`; | ||
|
||
export const ProjectType = styled.div` | ||
display: flex; | ||
align-items: center; | ||
gap: 0.25rem; | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pull from main + rebase then use the icons that Neha has imported. Check her PR for how she added the colors for the renewable energy technology icons: #63
You can also use the new components she made for renewable energy technology and status (if it works for your sprint -- I am not sure if the fonts / text are the same)