mirror of
https://github.com/myfatemi04/wheelshare-frontend.git
synced 2025-04-21 11:20:17 -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[] }) {
|
||||
return (
|
||||
<div style={{ display: 'flex', flexDirection: 'column', width: '100%' }}>
|
||||
{events.map((event) => (
|
||||
<Event {...event} key={event.title} />
|
||||
))}
|
||||
{events && events.length > 0 ? (
|
||||
events.map((event) => <Event {...event} key={event.title} />)
|
||||
) : (
|
||||
<span>
|
||||
There are no events yet. Click 'create event' above to add one!
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -2,8 +2,9 @@ import { useEffect, useState } from 'react';
|
|||
import { useParams } from 'react-router';
|
||||
import { Link } from 'react-router-dom';
|
||||
import { IEvent } from './Event';
|
||||
import EventCreator from './EventCreator';
|
||||
import EventCreatorLink from './EventCreatorLink';
|
||||
import EventStream from './EventStream';
|
||||
import GroupSettingsLink from './GroupSettingsLink';
|
||||
|
||||
export type IGroup = {
|
||||
id: number;
|
||||
|
@ -44,6 +45,8 @@ export default function Group() {
|
|||
|
||||
const { name } = group;
|
||||
|
||||
console.log({ events });
|
||||
|
||||
return (
|
||||
<div
|
||||
style={{
|
||||
|
@ -54,7 +57,8 @@ export default function Group() {
|
|||
}}
|
||||
>
|
||||
<h1>{name}</h1>
|
||||
<EventCreator group={group} />
|
||||
<GroupSettingsLink group={group} />
|
||||
<EventCreatorLink group={group} />
|
||||
<EventStream events={events} />
|
||||
</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