-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add tab bar to display winning props
- Loading branch information
1 parent
72ea617
commit 78bd44c
Showing
6 changed files
with
233 additions
and
100 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
packages/prop-house-webapp/src/components/HousePropCard/HousePropCard.module.css
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,47 @@ | ||
.propCard { | ||
height: 300px; | ||
cursor: pointer; | ||
border: 1px solid var(--border-med); | ||
} | ||
.propCardHeader { | ||
display: flex; | ||
align-items: center; | ||
font-weight: bold; | ||
font-size: 14px; | ||
color: var(--brand-gray); | ||
justify-content: space-between; | ||
} | ||
.voteDisplay { | ||
display: flex; | ||
align-items: center; | ||
} | ||
.voteDisplay svg { | ||
margin-right: 6px; | ||
} | ||
.proposer { | ||
display: flex; | ||
align-items: center; | ||
font-weight: bold; | ||
font-size: 16px; | ||
} | ||
.propTitle { | ||
margin: 12px 0 6px 0; | ||
display: -webkit-box; | ||
-webkit-line-clamp: 2; | ||
-webkit-box-orient: vertical; | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
} | ||
|
||
.propImgContainer { | ||
} | ||
.propImgContainer img { | ||
width: 100%; | ||
height: 100%; | ||
object-fit: cover; | ||
min-height: 120px; | ||
min-width: 120px; | ||
max-height: 140px; | ||
border-radius: 6px; | ||
outline: 1px solid var(--border-light); | ||
} |
55 changes: 55 additions & 0 deletions
55
packages/prop-house-webapp/src/components/HousePropCard/index.tsx
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,55 @@ | ||
import React, { useState, useEffect } from 'react'; | ||
import { useNavigate } from 'react-router-dom'; | ||
import { Proposal } from '@prophouse/sdk-react'; | ||
import Card, { CardBgColor, CardBorderRadius } from '../Card'; | ||
import EthAddress from '../EthAddress'; | ||
import classes from './HousePropCard.module.css'; | ||
import { replaceIpfsGateway } from '../../utils/ipfs'; | ||
import getFirstImageFromProp from '../../utils/getFirstImageFromProp'; | ||
import { MdHowToVote } from 'react-icons/md'; | ||
|
||
const HousePropCard: React.FC<{ proposal: Proposal }> = ({ proposal }) => { | ||
const navigate = useNavigate(); | ||
|
||
const [imgUrlFromProp, setImgUrlFromProp] = useState<string | undefined>(undefined); | ||
|
||
useEffect(() => { | ||
let imgUrl; | ||
const getImg = async () => { | ||
imgUrl = await getFirstImageFromProp(proposal); | ||
setImgUrlFromProp(imgUrl); | ||
}; | ||
getImg(); | ||
}, [proposal]); | ||
return ( | ||
<div onClick={() => navigate(`/${proposal.round}/${proposal.id}`)}> | ||
<Card | ||
bgColor={CardBgColor.White} | ||
borderRadius={CardBorderRadius.ten} | ||
classNames={classes.propCard} | ||
> | ||
<div className={classes.propCardHeader}> | ||
<EthAddress address={proposal.proposer} addAvatar className={classes.proposer} /> | ||
<div className={classes.voteDisplay}> | ||
<MdHowToVote /> | ||
{proposal.votingPower} | ||
</div> | ||
</div> | ||
<h5 className={classes.propTitle}>{proposal.title}</h5> | ||
|
||
{imgUrlFromProp ? ( | ||
<div className={classes.propImgContainer}> | ||
<img | ||
src={replaceIpfsGateway(imgUrlFromProp)} | ||
crossOrigin="anonymous" | ||
alt="propCardImage" | ||
/> | ||
</div> | ||
) : ( | ||
<p>{proposal.tldr}</p> | ||
)} | ||
</Card> | ||
</div> | ||
); | ||
}; | ||
export default HousePropCard; |
47 changes: 47 additions & 0 deletions
47
packages/prop-house-webapp/src/components/HouseTabBar/HouseTabBar.module.css
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,47 @@ | ||
.stickyContainer { | ||
background: white; | ||
top: 0; | ||
position: sticky !important; | ||
z-index: 1; | ||
border-bottom: 1px var(--border-light) solid; | ||
} | ||
|
||
.tabBarContainer { | ||
display: flex; | ||
} | ||
|
||
.tabOption { | ||
display: flex; | ||
gap: 10px; | ||
border-bottom: 2px solid transparent; | ||
padding-bottom: 12px; | ||
margin-right: 20px; | ||
} | ||
.tabOption.selected { | ||
border-bottom: 2px solid var(--border-dark); | ||
} | ||
.tabOption:hover { | ||
cursor: pointer; | ||
border-bottom: 2px solid var(--border-dark); | ||
} | ||
|
||
.tabOptionName { | ||
font-weight: 600; | ||
color: var(--brand-gray); | ||
} | ||
.tabOptionName.selected, | ||
.tabOptionName:hover { | ||
color: var(--brand-black) !important; | ||
} | ||
|
||
.tabOptionNumber { | ||
font-weight: 700; | ||
font-size: 14px; | ||
border-radius: 6px; | ||
padding: 0px 2px; | ||
align-self: center; | ||
background: var(--border-light); | ||
color: var(--brand-gray); | ||
min-width: 20px; | ||
text-align: center; | ||
} |
42 changes: 42 additions & 0 deletions
42
packages/prop-house-webapp/src/components/HouseTabBar/index.tsx
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,42 @@ | ||
import clsx from 'clsx'; | ||
import classes from './HouseTabBar.module.css'; | ||
import { Proposal, Round } from '@prophouse/sdk-react'; | ||
|
||
export enum SelectedTab { | ||
Rounds, | ||
Props, | ||
} | ||
|
||
const HouseTabBar: React.FC<{ | ||
rounds: Round[]; | ||
proposals: Proposal[]; | ||
selectedTab: SelectedTab; | ||
setSelectedTab: React.Dispatch<React.SetStateAction<SelectedTab>>; | ||
}> = ({ rounds, proposals, selectedTab, setSelectedTab }) => { | ||
const propsIsSelected = selectedTab === SelectedTab.Props; | ||
const roundsIsSelected = selectedTab === SelectedTab.Rounds; | ||
return ( | ||
<div className={classes.tabBarContainer}> | ||
<div | ||
className={clsx(classes.tabOption, roundsIsSelected && classes.selected)} | ||
onClick={() => setSelectedTab(SelectedTab.Rounds)} | ||
> | ||
<span className={clsx(classes.tabOptionName, roundsIsSelected && classes.selected)}> | ||
Rounds | ||
</span> | ||
<span className={classes.tabOptionNumber}>{rounds?.length}</span> | ||
</div> | ||
<div | ||
className={clsx(classes.tabOption, propsIsSelected && classes.selected)} | ||
onClick={() => setSelectedTab(SelectedTab.Props)} | ||
> | ||
<span className={clsx(classes.tabOptionName, propsIsSelected && classes.selected)}> | ||
Awarded Proposals | ||
</span> | ||
<span className={classes.tabOptionNumber}>{proposals?.length}</span> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default HouseTabBar; |
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
Oops, something went wrong.