mirror of
https://github.com/myfatemi04/wheelshare-frontend.git
synced 2025-04-21 19:29:51 -04:00
add clean group ui
This commit is contained in:
parent
8d668ea489
commit
3bd2435efb
26
src/components/NewUI/EventCreatorLink.tsx
Normal file
26
src/components/NewUI/EventCreatorLink.tsx
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
import { useCallback, useState } from 'react';
|
||||||
|
import EventCreator from './EventCreator';
|
||||||
|
import { IGroup } from './Group';
|
||||||
|
|
||||||
|
export default function EventCreatorLink({ group }: { group: IGroup }) {
|
||||||
|
const [open, setOpen] = useState(false);
|
||||||
|
const toggle = useCallback(() => {
|
||||||
|
setOpen((open) => !open);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
cursor: 'pointer',
|
||||||
|
userSelect: 'none',
|
||||||
|
marginBottom: '1rem',
|
||||||
|
}}
|
||||||
|
onClick={toggle}
|
||||||
|
>
|
||||||
|
Create Event
|
||||||
|
</div>
|
||||||
|
{open && <EventCreator group={group} />}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
|
@ -3,9 +3,13 @@ import Event, { IEvent } from './Event';
|
||||||
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', width: '100%' }}>
|
||||||
{events.map((event) => (
|
{events && events.length > 0 ? (
|
||||||
<Event {...event} key={event.title} />
|
events.map((event) => <Event {...event} key={event.title} />)
|
||||||
))}
|
) : (
|
||||||
|
<span>
|
||||||
|
There are no events yet. Click 'create event' above to add one!
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,9 @@ import { useEffect, useState } from 'react';
|
||||||
import { useParams } from 'react-router';
|
import { useParams } from 'react-router';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
import { IEvent } from './Event';
|
import { IEvent } from './Event';
|
||||||
import EventCreator from './EventCreator';
|
import EventCreatorLink from './EventCreatorLink';
|
||||||
import EventStream from './EventStream';
|
import EventStream from './EventStream';
|
||||||
|
import GroupSettingsLink from './GroupSettingsLink';
|
||||||
|
|
||||||
export type IGroup = {
|
export type IGroup = {
|
||||||
id: number;
|
id: number;
|
||||||
|
@ -44,6 +45,8 @@ export default function Group() {
|
||||||
|
|
||||||
const { name } = group;
|
const { name } = group;
|
||||||
|
|
||||||
|
console.log({ events });
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
|
@ -54,7 +57,8 @@ export default function Group() {
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<h1>{name}</h1>
|
<h1>{name}</h1>
|
||||||
<EventCreator group={group} />
|
<GroupSettingsLink group={group} />
|
||||||
|
<EventCreatorLink group={group} />
|
||||||
<EventStream events={events} />
|
<EventStream events={events} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
30
src/components/NewUI/GroupSettingsLink.tsx
Normal file
30
src/components/NewUI/GroupSettingsLink.tsx
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
import { useCallback, useState } from 'react';
|
||||||
|
import { IGroup } from './Group';
|
||||||
|
import UISecondaryBox from './UISecondaryBox';
|
||||||
|
|
||||||
|
export default function GroupSettingsLink({ group }: { group: IGroup }) {
|
||||||
|
const [open, setOpen] = useState(false);
|
||||||
|
const toggle = useCallback(() => {
|
||||||
|
setOpen((open) => !open);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
cursor: 'pointer',
|
||||||
|
userSelect: 'none',
|
||||||
|
marginBottom: '1rem',
|
||||||
|
}}
|
||||||
|
onClick={toggle}
|
||||||
|
>
|
||||||
|
Settings
|
||||||
|
</div>
|
||||||
|
{open && (
|
||||||
|
<UISecondaryBox>
|
||||||
|
<h1>Settings</h1>
|
||||||
|
</UISecondaryBox>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
28
src/components/NewUI/UILink.tsx
Normal file
28
src/components/NewUI/UILink.tsx
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
import { CSSProperties, ReactNode, useMemo } from 'react';
|
||||||
|
import { Link } from 'react-router-dom';
|
||||||
|
|
||||||
|
const baseStyle: CSSProperties = {
|
||||||
|
textDecoration: 'none',
|
||||||
|
cursor: 'pointer',
|
||||||
|
userSelect: 'none',
|
||||||
|
};
|
||||||
|
|
||||||
|
export default function UILink({
|
||||||
|
href,
|
||||||
|
style,
|
||||||
|
children,
|
||||||
|
}: {
|
||||||
|
href: string;
|
||||||
|
style?: CSSProperties;
|
||||||
|
children: ReactNode;
|
||||||
|
}) {
|
||||||
|
const computedStyle = useMemo(() => {
|
||||||
|
return !style ? baseStyle : { ...baseStyle, ...style };
|
||||||
|
}, [style]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Link to={href} style={computedStyle}>
|
||||||
|
{children}
|
||||||
|
</Link>
|
||||||
|
);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user