Skip to content
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

Update styling of organization cards #30

Merged
merged 4 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading