responsive two-column layout

This commit is contained in:
Michael Fatemi 2021-08-11 19:02:00 -04:00
parent 3241a1591f
commit 99ed5fe2b9
10 changed files with 74 additions and 47 deletions

View File

@ -1,17 +1,15 @@
import { useEffect } from 'react'; import { useEffect, useState } from 'react';
import { useState } from 'react';
import { getActiveCarpools } from '../api'; import { getActiveCarpools } from '../api';
import { ICarpool } from '../types'; import { ICarpool } from '../types';
import UILink from '../UI/UILink';
import UISecondaryBox from '../UI/UISecondaryBox'; import UISecondaryBox from '../UI/UISecondaryBox';
import UISecondaryHeader from '../UI/UISecondaryHeader';
function ActiveCarpoolListItem({ carpool }: { carpool: ICarpool }) { function ActiveCarpoolListItem({ carpool }: { carpool: ICarpool }) {
return ( return (
<UISecondaryBox> <div>
<UISecondaryHeader> <h2>{carpool.name}</h2>
<a href={'/carpools/' + carpool.id}>{carpool.name}</a> <UILink href={`/carpools/${carpool.id}`}>View carpool</UILink>
</UISecondaryHeader> </div>
</UISecondaryBox>
); );
} }
@ -23,13 +21,18 @@ export default function ActiveCarpools() {
}, []); }, []);
return ( return (
<> <div
<h1>Carpools</h1> style={{
<div style={{ display: 'flex', flexDirection: 'column', width: '100%' }}> display: 'flex',
flexDirection: 'column',
}}
>
<h1 style={{ textAlign: 'center' }}>Carpools</h1>
<UISecondaryBox style={{ width: '100%', boxSizing: 'border-box' }}>
{activeCarpools.map((carpool) => ( {activeCarpools.map((carpool) => (
<ActiveCarpoolListItem carpool={carpool} key={carpool.id} /> <ActiveCarpoolListItem carpool={carpool} key={carpool.id} />
))} ))}
</div> </UISecondaryBox>
</> </div>
); );
} }

View File

@ -16,9 +16,9 @@ export default function ActiveEvents() {
}, [hasEvents, setEvents]); }, [hasEvents, setEvents]);
return ( return (
<> <div style={{ display: 'flex', flexDirection: 'column' }}>
<h1>Events</h1> <h1 style={{ textAlign: 'center' }}>Events</h1>
<EventStream events={events} /> <EventStream events={events} />
</> </div>
); );
} }

View File

@ -20,7 +20,7 @@ const style: CSSProperties = {
display: 'flex', display: 'flex',
flexDirection: 'column', flexDirection: 'column',
alignItems: 'center', alignItems: 'center',
width: '30rem', // width: '30rem',
maxWidth: '100%', maxWidth: '100%',
marginLeft: 'auto', marginLeft: 'auto',
marginRight: 'auto', marginRight: 'auto',

View File

@ -53,7 +53,7 @@ export default function Event({
tentativeInvites, tentativeInvites,
}} }}
> >
<UISecondaryBox> <UISecondaryBox style={{}}>
<div style={{ textAlign: 'center' }}> <div style={{ textAlign: 'center' }}>
<UISecondaryHeader>{name}</UISecondaryHeader> <UISecondaryHeader>{name}</UISecondaryHeader>
{group && <GroupName group={group} />} {group && <GroupName group={group} />}

View File

@ -3,7 +3,13 @@ import { IEvent } from './types';
export default function EventStream({ events }: { events: IEvent[] }) { export default function EventStream({ events }: { events: IEvent[] }) {
return ( return (
<div style={{ display: 'flex', flexDirection: 'column', width: '100%' }}> <div
style={{
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
}}
>
{events.map((event) => ( {events.map((event) => (
<Event id={event.id} initial={event} key={event.name} /> <Event id={event.id} initial={event} key={event.name} />
))} ))}

View File

@ -70,7 +70,7 @@ export default function GroupJoinerLink() {
const [open, toggle] = useToggle(false); const [open, toggle] = useToggle(false);
return ( return (
<> <div style={{ width: '100%', textAlign: 'center' }}>
<UIPressable onClick={toggle}>Join Group</UIPressable> <UIPressable onClick={toggle}>Join Group</UIPressable>
{open && ( {open && (
<> <>
@ -78,6 +78,6 @@ export default function GroupJoinerLink() {
<GroupJoiner /> <GroupJoiner />
</> </>
)} )}
</> </div>
); );
} }

View File

@ -4,19 +4,8 @@ import UISecondaryBox from '../UI/UISecondaryBox';
function GroupListItem({ group }: { group: IGroup }) { function GroupListItem({ group }: { group: IGroup }) {
return ( return (
<div style={{ display: 'flex', alignItems: 'center' }}> <div>
<span <h2>{group.name}</h2>
style={{
fontSize: '1.5rem',
fontWeight: 'bold',
display: 'block',
marginTop: '1rem',
marginBottom: '1rem',
marginRight: '2rem',
}}
>
{group.name}
</span>
<UILink href={`/groups/${group.id}`}>View group</UILink> <UILink href={`/groups/${group.id}`}>View group</UILink>
</div> </div>
); );
@ -24,13 +13,7 @@ function GroupListItem({ group }: { group: IGroup }) {
export default function GroupList({ groups }: { groups: IGroup[] }) { export default function GroupList({ groups }: { groups: IGroup[] }) {
return ( return (
<UISecondaryBox <UISecondaryBox style={{ width: '100%' }}>
style={{
width: '100%',
boxSizing: 'border-box',
alignItems: 'center',
}}
>
{groups.map((group) => ( {groups.map((group) => (
<GroupListItem group={group} key={group.id} /> <GroupListItem group={group} key={group.id} />
))} ))}

View File

@ -13,8 +13,13 @@ export default function Groups() {
}, []); }, []);
return ( return (
<> <div
<h1>Groups</h1> style={{
display: 'flex',
flexDirection: 'column',
}}
>
<h1 style={{ textAlign: 'center' }}>Groups</h1>
<GroupJoinerLink /> <GroupJoinerLink />
<br /> <br />
<GroupCreatorLink /> <GroupCreatorLink />
@ -28,6 +33,6 @@ export default function Groups() {
an invite link. an invite link.
</span> </span>
)} )}
</> </div>
); );
} }

View File

@ -7,6 +7,7 @@ const baseStyle: CSSProperties = {
borderRadius: '0.5rem', borderRadius: '0.5rem',
padding: '1rem', padding: '1rem',
marginBottom: '1em', marginBottom: '1em',
boxSizing: 'border-box',
}; };
export default function UISecondaryBox({ export default function UISecondaryBox({

View File

@ -5,9 +5,38 @@ import Groups from './Groups/Groups';
export default function WheelShare() { export default function WheelShare() {
return ( return (
<> <>
<Groups /> <div
<ActiveCarpools /> style={{
<ActiveEvents /> display: 'flex',
width: '60rem',
maxWidth: '100vw',
flexWrap: 'wrap',
}}
>
<div
style={{
display: 'flex',
flexDirection: 'column',
flex: 1,
padding: '1rem',
minWidth: '20rem',
}}
>
<ActiveCarpools />
<Groups />
</div>
<div
style={{
display: 'flex',
flexDirection: 'column',
flex: 1,
padding: '1rem',
minWidth: '20rem',
}}
>
<ActiveEvents />
</div>
</div>
</> </>
); );
} }