mirror of
https://github.com/myfatemi04/wheelshare-frontend.git
synced 2025-04-16 00:50:18 -04:00
wonderful two column layouts
This commit is contained in:
parent
99ed5fe2b9
commit
8ad8726780
|
@ -7,7 +7,7 @@ import UISecondaryBox from '../UI/UISecondaryBox';
|
||||||
function ActiveCarpoolListItem({ carpool }: { carpool: ICarpool }) {
|
function ActiveCarpoolListItem({ carpool }: { carpool: ICarpool }) {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<h2>{carpool.name}</h2>
|
<h4>{carpool.name}</h4>
|
||||||
<UILink href={`/carpools/${carpool.id}`}>View carpool</UILink>
|
<UILink href={`/carpools/${carpool.id}`}>View carpool</UILink>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
@ -25,6 +25,7 @@ export default function ActiveCarpools() {
|
||||||
style={{
|
style={{
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
flexDirection: 'column',
|
flexDirection: 'column',
|
||||||
|
width: '19rem',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<h1 style={{ textAlign: 'center' }}>Carpools</h1>
|
<h1 style={{ textAlign: 'center' }}>Carpools</h1>
|
||||||
|
|
|
@ -14,7 +14,7 @@ import WheelShareLoggedOut from './WheelShareLoggedOut';
|
||||||
const Authenticator = lazy(() => import('./Authentication/Authenticator'));
|
const Authenticator = lazy(() => import('./Authentication/Authenticator'));
|
||||||
const CarpoolPage = lazy(() => import('./Carpool/CarpoolPage'));
|
const CarpoolPage = lazy(() => import('./Carpool/CarpoolPage'));
|
||||||
const EventPage = lazy(() => import('./Event/EventPage'));
|
const EventPage = lazy(() => import('./Event/EventPage'));
|
||||||
const Group = lazy(() => import('./Group/GroupPage'));
|
const GroupPage = lazy(() => import('./Group/GroupPage'));
|
||||||
|
|
||||||
const style: CSSProperties = {
|
const style: CSSProperties = {
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
|
@ -53,7 +53,7 @@ export default function App() {
|
||||||
<Route path="/" exact component={WheelShare} />
|
<Route path="/" exact component={WheelShare} />
|
||||||
<Route path="/carpools/:id" component={CarpoolPage} />
|
<Route path="/carpools/:id" component={CarpoolPage} />
|
||||||
<Route path="/events/:id" component={EventPage} />
|
<Route path="/events/:id" component={EventPage} />
|
||||||
<Route path="/groups/:id" component={Group} />
|
<Route path="/groups/:id" component={GroupPage} />
|
||||||
</NotificationsProvider>
|
</NotificationsProvider>
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
|
|
|
@ -53,7 +53,7 @@ export default function Event({
|
||||||
tentativeInvites,
|
tentativeInvites,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<UISecondaryBox style={{}}>
|
<UISecondaryBox style={{ minWidth: '15rem' }}>
|
||||||
<div style={{ textAlign: 'center' }}>
|
<div style={{ textAlign: 'center' }}>
|
||||||
<UISecondaryHeader>{name}</UISecondaryHeader>
|
<UISecondaryHeader>{name}</UISecondaryHeader>
|
||||||
{group && <GroupName group={group} />}
|
{group && <GroupName group={group} />}
|
||||||
|
|
|
@ -2,6 +2,8 @@ import UISecondaryBox from '../UI/UISecondaryBox';
|
||||||
|
|
||||||
export default function EventPlaceholder() {
|
export default function EventPlaceholder() {
|
||||||
return (
|
return (
|
||||||
<UISecondaryBox style={{ height: '10rem' }}>Loading...</UISecondaryBox>
|
<UISecondaryBox style={{ height: '10rem', width: '15rem' }}>
|
||||||
|
Loading...
|
||||||
|
</UISecondaryBox>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,7 +84,7 @@ export default function EventCreator({ group }: { group: IGroup }) {
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<UISecondaryBox style={{ width: '100%', textAlign: 'center' }}>
|
<UISecondaryBox style={{ textAlign: 'center' }}>
|
||||||
<h1 style={{ textAlign: 'center', marginBottom: '0.5rem' }}>
|
<h1 style={{ textAlign: 'center', marginBottom: '0.5rem' }}>
|
||||||
Create Event
|
Create Event
|
||||||
</h1>
|
</h1>
|
||||||
|
|
|
@ -6,6 +6,7 @@ import EventStream from '../EventStream';
|
||||||
import { useMe } from '../hooks';
|
import { useMe } from '../hooks';
|
||||||
import { IGroup } from '../types';
|
import { IGroup } from '../types';
|
||||||
import UILink from '../UI/UILink';
|
import UILink from '../UI/UILink';
|
||||||
|
import UITwoColumns from '../UI/UITwoColumns';
|
||||||
import useImmutable from '../useImmutable';
|
import useImmutable from '../useImmutable';
|
||||||
import GroupMembersLink from './GroupMembersLink';
|
import GroupMembersLink from './GroupMembersLink';
|
||||||
import GroupSettingsLink from './GroupSettingsLink';
|
import GroupSettingsLink from './GroupSettingsLink';
|
||||||
|
@ -47,36 +48,41 @@ export default function Group({ id }: { id: number }) {
|
||||||
|
|
||||||
return group ? (
|
return group ? (
|
||||||
<GroupContext.Provider value={{ group }}>
|
<GroupContext.Provider value={{ group }}>
|
||||||
<h1>{group.name}</h1>
|
<UITwoColumns
|
||||||
<div
|
first={
|
||||||
style={{
|
<div
|
||||||
display: 'flex',
|
style={{
|
||||||
flexDirection: 'column',
|
display: 'flex',
|
||||||
width: '100%',
|
flexDirection: 'column',
|
||||||
alignItems: 'center',
|
minWidth: '10rem',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<UILink href="/">Home</UILink>
|
<h1>{group.name}</h1>
|
||||||
<br />
|
<UILink href="/">Home</UILink>
|
||||||
<GroupMembersLink />
|
|
||||||
<br />
|
|
||||||
{isAdmin && (
|
|
||||||
<>
|
|
||||||
<GroupSettingsLink />
|
|
||||||
<br />
|
<br />
|
||||||
</>
|
<GroupMembersLink />
|
||||||
)}
|
<br />
|
||||||
<EventCreatorLink />
|
{isAdmin && (
|
||||||
</div>
|
<>
|
||||||
<br />
|
<GroupSettingsLink />
|
||||||
|
<br />
|
||||||
{group.events?.length > 0 ? (
|
</>
|
||||||
<EventStream events={group.events} />
|
)}
|
||||||
) : (
|
<EventCreatorLink />
|
||||||
<span>
|
</div>
|
||||||
There are no events yet. Click 'create event' above to add one!
|
}
|
||||||
</span>
|
firstFlex={1}
|
||||||
)}
|
second={
|
||||||
|
group.events?.length > 0 ? (
|
||||||
|
<EventStream events={group.events} />
|
||||||
|
) : (
|
||||||
|
<span>
|
||||||
|
There are no events yet. Click 'create event' above to add one!
|
||||||
|
</span>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
secondFlex={2}
|
||||||
|
/>
|
||||||
</GroupContext.Provider>
|
</GroupContext.Provider>
|
||||||
) : (
|
) : (
|
||||||
<h1>Group not found</h1>
|
<h1>Group not found</h1>
|
||||||
|
|
|
@ -50,7 +50,7 @@ export default function GroupMembersLink() {
|
||||||
<>
|
<>
|
||||||
<br />
|
<br />
|
||||||
<UISecondaryBox style={{ width: '100%', textAlign: 'center' }}>
|
<UISecondaryBox style={{ width: '100%', textAlign: 'center' }}>
|
||||||
<h1>Members</h1>
|
<h3>Members</h3>
|
||||||
|
|
||||||
{group.users.map(({ name, id }) => (
|
{group.users.map(({ name, id }) => (
|
||||||
<span key={id}>
|
<span key={id}>
|
||||||
|
|
|
@ -29,7 +29,7 @@ export default function GroupCreator() {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<UISecondaryBox style={{ width: '100%', boxSizing: 'border-box' }}>
|
<UISecondaryBox style={{ width: '100%', boxSizing: 'border-box' }}>
|
||||||
<h1 style={{ textAlign: 'center' }}>Create Group</h1>
|
<h3 style={{ textAlign: 'center' }}>Create Group</h3>
|
||||||
Name
|
Name
|
||||||
<UITextInput onChangeText={setName} value={name} />
|
<UITextInput onChangeText={setName} value={name} />
|
||||||
<UIButton
|
<UIButton
|
||||||
|
|
|
@ -45,7 +45,7 @@ function GroupJoiner() {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<UISecondaryBox style={{ width: '100%', textAlign: 'center' }}>
|
<UISecondaryBox style={{ width: '100%', textAlign: 'center' }}>
|
||||||
<h1>Join Group</h1>
|
<h3>Join Group</h3>
|
||||||
Code
|
Code
|
||||||
<UITextInput value={code} onChangeText={setCode} />
|
<UITextInput value={code} onChangeText={setCode} />
|
||||||
{group && (
|
{group && (
|
||||||
|
|
|
@ -5,7 +5,7 @@ import UISecondaryBox from '../UI/UISecondaryBox';
|
||||||
function GroupListItem({ group }: { group: IGroup }) {
|
function GroupListItem({ group }: { group: IGroup }) {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<h2>{group.name}</h2>
|
<h4>{group.name}</h4>
|
||||||
<UILink href={`/groups/${group.id}`}>View group</UILink>
|
<UILink href={`/groups/${group.id}`}>View group</UILink>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
|
@ -17,6 +17,7 @@ export default function Groups() {
|
||||||
style={{
|
style={{
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
flexDirection: 'column',
|
flexDirection: 'column',
|
||||||
|
width: '19rem',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<h1 style={{ textAlign: 'center' }}>Groups</h1>
|
<h1 style={{ textAlign: 'center' }}>Groups</h1>
|
||||||
|
|
47
src/components/UI/UITwoColumns.tsx
Normal file
47
src/components/UI/UITwoColumns.tsx
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
import { ReactNode } from 'react';
|
||||||
|
|
||||||
|
export default function UITwoColumns({
|
||||||
|
first,
|
||||||
|
second,
|
||||||
|
firstFlex,
|
||||||
|
secondFlex,
|
||||||
|
}: {
|
||||||
|
first: ReactNode;
|
||||||
|
second: ReactNode;
|
||||||
|
firstFlex: number;
|
||||||
|
secondFlex: number;
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
display: 'flex',
|
||||||
|
width: '60rem',
|
||||||
|
maxWidth: '100vw',
|
||||||
|
flexWrap: 'wrap',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'column',
|
||||||
|
flex: firstFlex,
|
||||||
|
padding: '1rem',
|
||||||
|
alignItems: 'center',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{first}
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'column',
|
||||||
|
flex: secondFlex,
|
||||||
|
padding: '1rem',
|
||||||
|
alignItems: 'center',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{second}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
|
@ -1,42 +1,20 @@
|
||||||
import ActiveCarpools from './ActiveCarpools/ActiveCarpools';
|
import ActiveCarpools from './ActiveCarpools/ActiveCarpools';
|
||||||
import ActiveEvents from './ActiveEvents/Events';
|
import ActiveEvents from './ActiveEvents/Events';
|
||||||
import Groups from './Groups/Groups';
|
import Groups from './Groups/Groups';
|
||||||
|
import UITwoColumns from './UI/UITwoColumns';
|
||||||
|
|
||||||
export default function WheelShare() {
|
export default function WheelShare() {
|
||||||
return (
|
return (
|
||||||
<>
|
<UITwoColumns
|
||||||
<div
|
firstFlex={1}
|
||||||
style={{
|
first={
|
||||||
display: 'flex',
|
<>
|
||||||
width: '60rem',
|
|
||||||
maxWidth: '100vw',
|
|
||||||
flexWrap: 'wrap',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
display: 'flex',
|
|
||||||
flexDirection: 'column',
|
|
||||||
flex: 1,
|
|
||||||
padding: '1rem',
|
|
||||||
minWidth: '20rem',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<ActiveCarpools />
|
<ActiveCarpools />
|
||||||
<Groups />
|
<Groups />
|
||||||
</div>
|
</>
|
||||||
<div
|
}
|
||||||
style={{
|
secondFlex={2}
|
||||||
display: 'flex',
|
second={<ActiveEvents />}
|
||||||
flexDirection: 'column',
|
/>
|
||||||
flex: 1,
|
|
||||||
padding: '1rem',
|
|
||||||
minWidth: '20rem',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<ActiveEvents />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user