Skip to content

Commit

Permalink
refactored colors and text components, added scrollbar to card column
Browse files Browse the repository at this point in the history
  • Loading branch information
jinkang-0 committed Oct 12, 2023
1 parent 8044091 commit 50210f2
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 28 deletions.
12 changes: 4 additions & 8 deletions src/app/cases/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import { UUID } from 'crypto';
import { CaseListing } from '../../types/schemaTypes';
import { getNCases } from '../../api/supabase/queries/cases';
import ListingCard from '../../components/ListingCard/ListingCard';
import { CardColumn, MainDisplay, PageContainer, PageTitle } from './styles';
import { CardColumn, MainDisplay, PageContainer } from './styles';
import { H1 } from '../../styles/text';

export default function Page() {
const [caseData, setCaseData] = useState<CaseListing[]>([]);
Expand All @@ -18,23 +19,18 @@ export default function Page() {
});
}, []);

// onclicks
function onCardClick(id: UUID) {
setSelectedCard(id);
}

// page structure
return (
<PageContainer>
<PageTitle>Browse Available Cases</PageTitle>
<H1>Browse Available Cases</H1>
<MainDisplay>
<CardColumn>
{caseData.map(c => (
<ListingCard
key={c.id}
caseData={c}
isSelected={c.id === selectedCard}
onClick={() => onCardClick(c.id)}
onClick={() => setSelectedCard(c.id)}
/>
))}
</CardColumn>
Expand Down
10 changes: 3 additions & 7 deletions src/app/cases/styles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,6 @@ export const PageContainer = styled.div`
padding: 2rem;
`;

export const PageTitle = styled.h1`
font-size: 2rem;
text-align: left;
margin: 0;
margin-right: auto;
`;

export const MainDisplay = styled.main`
display: grid;
grid-template-columns: 5fr 10fr;
Expand All @@ -26,5 +19,8 @@ export const CardColumn = styled.div`
flex-direction: column;
gap: 2rem;
border-right: 1px solid black;
padding-top: 0.5rem;
padding-right: 2rem;
overflow-y: scroll;
max-height: 80vh;
`;
16 changes: 9 additions & 7 deletions src/components/ListingCard/ListingCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import React from 'react';
import { UUID } from 'crypto';
import { CaseListing } from '../../types/schemaTypes';
import timestampStringToDate from '../../utils/helpers';
import { CardBody, CardTitle, TagRow, CardTag } from './styles';
import { CardBody, TagRow, CardTag } from './styles';
import { H2 } from '../../styles/text';
import COLORS from '../../styles/colors';

export default function ListingCard({
caseData,
Expand All @@ -22,17 +24,13 @@ export default function ListingCard({
const parseDate = (d: Date): string =>
`${d.getMonth() + 1}/${d.getDate()}/${d.getFullYear()}`;

// temporary solution
const attorneyColor = '#85b4d2';
const interpreterColor = '#8dd89f';

return (
<CardBody
$selected={isSelected}
onClick={onClick ? () => onClick(caseData.id) : undefined}
>
{/* hard-coded for now */}
<CardTitle>Case title.</CardTitle>
<H2>Case title.</H2>
<p>
<strong>Languages: </strong>
{caseData.languages.join(', ')}
Expand All @@ -45,7 +43,11 @@ export default function ListingCard({
{rolesNeeded.map(r => (
<CardTag
key={r}
color={r === 'Interpreter' ? interpreterColor : attorneyColor}
color={
r === 'Interpreter'
? COLORS.interpreterColor
: COLORS.attorneyColor
}
>
{r}
</CardTag>
Expand Down
7 changes: 1 addition & 6 deletions src/components/ListingCard/styles.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import styled from 'styled-components';

// styled components
// the card itself
export const CardBody = styled.div<{ $selected?: boolean }>`
display: flex;
flex-direction: column;
Expand All @@ -19,11 +19,6 @@ export const CardBody = styled.div<{ $selected?: boolean }>`
}
`;

export const CardTitle = styled.h2`
font-size: 1.5rem;
margin: 0;
`;

export const TagRow = styled.div`
display: flex;
gap: 1rem;
Expand Down
6 changes: 6 additions & 0 deletions src/styles/colors.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const COLORS = {
attorneyColor: '#85b4d2',
interpreterColor: '#8dd89f',
};

export default COLORS;
13 changes: 13 additions & 0 deletions src/styles/text.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import styled from 'styled-components';

export const H1 = styled.h1`
display: block;
font-size: 2rem;
margin: 0;
margin-right: auto;
`;

export const H2 = styled.h2`
font-size: 1.5rem;
margin: 0;
`;

0 comments on commit 50210f2

Please sign in to comment.