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

EventsListing responsiveness #189

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
82 changes: 81 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"react-helmet": "^6.1.0",
"react-highlight-words": "^0.17.0",
"react-redux": "^7.2.2",
"react-responsive": "^9.0.0-beta.4",
"react-router-dom": "^5.2.0",
"react-scripts": "^3.4.3",
"redux": "^4.0.5",
Expand Down
106 changes: 74 additions & 32 deletions src/components/event-listing/EventListing.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
import { Card, Divider, Tag, Typography } from 'antd';
import { useMediaQuery } from 'react-responsive';
import { useHistory } from 'react-router-dom';
import dateFormat from 'dateformat';
import React from 'react';
import styled from 'styled-components';
import { Routes } from '../../App';
import { LinkButton } from '../../components/LinkButton';
import { EventInformation } from '../../containers/upcoming-events/ducks/types';
import { DEFAULT_IMAGE } from '../../utils/copy';
import { PRIMARY_BREAKPOINT } from '../../utils/breakpoints';

const { Title, Text, Paragraph } = Typography;

const StyledCard = styled(Card)`
margin-bottom: 32px;
height: 314px;
.ant-card-body {
padding: 0px;
}
`;
const { Text, Paragraph } = Typography;

const CardContent = styled.div`
display: flex;
Expand All @@ -26,6 +21,10 @@ const ThinDivider = styled(Divider)`
margin-top: 12px;
margin-bottom: 12px;
width: 100%;

@media screen and (max-width: ${PRIMARY_BREAKPOINT}) {
display: none;
}
`;

const StyledButton = styled(LinkButton)`
Expand Down Expand Up @@ -62,15 +61,26 @@ const Thumbnail = styled.img`
width: 33%;
object-fit: cover;
height: 312px;

@media screen and (max-width: ${PRIMARY_BREAKPOINT}) {
width: 45%;
height: 214px;
}
`;

const Info = styled.div`
padding: 24px;
width: 67%;
`;

const InlineTitle = styled(Title)`
const InlineTitle = styled(Text)`
font-size: 24px;
display: inline;

@media screen and (max-width: ${PRIMARY_BREAKPOINT}) {
font-size: 32px;
font-weight: bold;
}
`;

const EventTag = styled(Tag)`
Expand All @@ -81,6 +91,18 @@ const AdminButtonWrapper = styled.div`
display: flex;
`;

const BottomHalfWrapper = styled.div`
@media screen and (max-width: ${PRIMARY_BREAKPOINT}) {
display: none;
}
`;

const DateText = styled(Text)`
@media screen and (max-width: ${PRIMARY_BREAKPOINT}) {
font-size: 16px;
}
`;

interface EventListingProps extends EventInformation {
admin?: boolean;
}
Expand All @@ -93,12 +115,30 @@ const EventListing: React.FC<EventListingProps> = ({
ticketCount,
admin,
}) => {
const history = useHistory();
const onMobile = useMediaQuery({
query: '(max-width: ' + PRIMARY_BREAKPOINT + ')',
});

const handleMobileOnClick = () => {
return onMobile && history.push(Routes.EVENT_BASE_ROUTE + id);
};

const StyledCard = styled(Card)`
margin-bottom: 32px;
height: ${onMobile ? '216px' : '314px'};
.ant-card-body {
padding: 0px;
}
cursor: ${onMobile && `pointer`};
`;

return (
<StyledCard>
<StyledCard onClick={handleMobileOnClick}>
<CardContent>
<Thumbnail src={thumbnail || DEFAULT_IMAGE} />
<Info>
<InlineTitle level={3}>{title}</InlineTitle>
<InlineTitle>{title}</InlineTitle>
{ticketCount && (
<>
<EventTag color="green">
Expand All @@ -107,31 +147,33 @@ const EventListing: React.FC<EventListingProps> = ({
</>
)}
<br />
<Text strong>{dateFormat(details.start, 'longDate')}</Text>
<DateText strong>{dateFormat(details.start, 'longDate')}</DateText>
<br />
<Text strong>{dateFormat(details.start, 'shortTime')}</Text>
<DateText strong>{dateFormat(details.start, 'shortTime')}</DateText>
<ThinDivider />
<Paragraph ellipsis={{ rows: 5 }}>{details.description}</Paragraph>
{admin ? (
<AdminButtonWrapper>
<BottomHalfWrapper>
<Paragraph ellipsis={{ rows: 5 }}>{details.description}</Paragraph>
{admin ? (
<AdminButtonWrapper>
<GreenButton to={Routes.EVENT_BASE_ROUTE + id}>
Learn More
</GreenButton>
<GreenButton to={Routes.EDIT_EVENT_BASE_ROUTE + id}>
Edit
</GreenButton>
<GreenButton to={`/create-announcements/${id}`}>
Make Announcement
</GreenButton>
<GrayButton to={`${Routes.EVENT_BASE_ROUTE}${id}/rsvp`}>
View RSVP
</GrayButton>
</AdminButtonWrapper>
) : (
<GreenButton to={Routes.EVENT_BASE_ROUTE + id}>
Learn More
</GreenButton>
<GreenButton to={Routes.EDIT_EVENT_BASE_ROUTE + id}>
Edit
</GreenButton>
<GreenButton to={`/create-announcements/${id}`}>
Make Announcement
</GreenButton>
<GrayButton to={`${Routes.EVENT_BASE_ROUTE}${id}/rsvp`}>
View RSVP
</GrayButton>
</AdminButtonWrapper>
) : (
<GreenButton to={Routes.EVENT_BASE_ROUTE + id}>
Learn More
</GreenButton>
)}
)}
</BottomHalfWrapper>
</Info>
</CardContent>
</StyledCard>
Expand Down