Skip to content

Commit

Permalink
style: update styling of organization cards (#30)
Browse files Browse the repository at this point in the history
---------

Co-authored-by: Elara Liu <[email protected]>
  • Loading branch information
chipanyanwu and ZL-Asica authored Dec 6, 2024
1 parent d5c1b56 commit eda1489
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 32 deletions.
65 changes: 46 additions & 19 deletions src/components/Home/DonorDashboard/OrganizationCard.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
Box,
Card,
CardContent,
CardActions,
Expand All @@ -7,6 +8,7 @@ import {
Collapse,
Typography,
Divider,
Link,
} from '@mui/material';
import { ExpandMore, ExpandLess } from '@mui/icons-material';
import { lighten, useTheme } from '@mui/material/styles';
Expand Down Expand Up @@ -82,16 +84,30 @@ const OrganizationCard = ({ organization }: OrganizationCardProps) => {
[theme]
);

// Extracted component for header actions
const HeaderActions = () =>
user && (
<Button
color={isSaved ? 'secondary' : 'primary'}
onClick={() => handleAction('save')}
>
{isSaved ? 'Unsave' : 'Save'}
</Button>
);
const HeaderActions = () => (
<Box
sx={{
display: 'flex',
flexDirection: 'column',
alignItems: 'flex-end',
mt: 1,
}}
>
{user && (
<Button
size='small'
sx={{
width: 'fit-content',
backgroundColor: 'primary.light',
}}
color={isSaved ? 'secondary' : 'primary'}
onClick={() => handleAction('save')}
>
{isSaved ? 'Unsaved' : 'Save'}
</Button>
)}
</Box>
);

// Extracted component for needs section
const NeedsSection = () =>
Expand Down Expand Up @@ -127,7 +143,26 @@ const OrganizationCard = ({ organization }: OrganizationCardProps) => {
<Card sx={cardStyles}>
<CardHeader
title={organization.name}
subheader={organization.location}
subheader={
<>
{organization.location}
<br />
<Link
href={organization.website}
target='_blank'
rel='noopener noreferrer'
variant='button'
sx={{
mt: -1,
textDecoration: 'none',
width: 'fit-content',
textTransform: 'none',
}}
>
Visit Website
</Link>
</>
}
action={<HeaderActions />}
/>
<CardContent>
Expand All @@ -137,14 +172,6 @@ const OrganizationCard = ({ organization }: OrganizationCardProps) => {
>
{organization.description}
</Typography>
<Button
size='small'
href={organization.website}
target='_blank'
sx={{ mt: 1 }}
>
Visit Website
</Button>
</CardContent>
<CardActions>
{hasNeeds && (
Expand Down
39 changes: 26 additions & 13 deletions src/components/Saved/SavedCard.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
Box,
Card,
CardContent,
CardHeader,
Expand All @@ -25,13 +26,32 @@ const SavedOrganizationCard: React.FC<{
title={organization.name}
subheader={organization.location}
action={
<Button
variant='text'
color='error'
onClick={onRemove}
<Box
sx={{
display: 'flex',
flexDirection: 'column',
alignItems: 'flex-end',
gap: '0.25rem',
mt: 1,
}}
>
Remove
</Button>
<Button
size='small'
variant='text'
color='error'
onClick={onRemove}
>
Unsaved
</Button>
<Button
size='small'
sx={{ width: 'fit-content' }}
href={organization.website}
target='_blank'
>
Visit Website
</Button>
</Box>
}
/>
<CardContent>
Expand All @@ -41,13 +61,6 @@ const SavedOrganizationCard: React.FC<{
>
{organization.description}
</Typography>
<Button
size='small'
href={organization.website}
target='_blank'
>
Visit Website
</Button>
</CardContent>
</Card>
);
Expand Down

0 comments on commit eda1489

Please sign in to comment.