Skip to content

Commit

Permalink
add tab bar to display winning props
Browse files Browse the repository at this point in the history
  • Loading branch information
cryptoseneca committed Jan 24, 2024
1 parent 72ea617 commit 78bd44c
Show file tree
Hide file tree
Showing 6 changed files with 233 additions and 100 deletions.
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 packages/prop-house-webapp/src/components/HousePropCard/index.tsx
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;
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 packages/prop-house-webapp/src/components/HouseTabBar/index.tsx
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;
6 changes: 2 additions & 4 deletions packages/prop-house-webapp/src/pages/House/House.module.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
.houseContainer {
background: var(--bg-dark);

min-height: 350px;
padding: 1rem;
}
Expand All @@ -10,8 +9,7 @@
top: 0;
position: sticky !important;
z-index: 1;
padding-top: 12px;
border-bottom: 1px solid var(--border-light);
border-bottom: 1px var(--border-light) solid;
}

@media (max-width: 575px) {
Expand All @@ -20,6 +18,6 @@
padding-left: 0 !important;
}
.stickyContainer {
padding: 12px 0px 8px 0px;
padding: 12px 0px 0px 0px;
}
}
Loading

0 comments on commit 78bd44c

Please sign in to comment.