eventlist cleanup

This commit is contained in:
cv
2021-03-22 22:08:41 +01:00
parent 5cea1fb140
commit 1a2e5e19b9
5 changed files with 98 additions and 69 deletions
+32 -12
View File
@@ -1,16 +1,36 @@
const dummy = new Date(); const dummy = new Date();
export const sampleData = { export const sampleData = {
id: '1', events: [
title: 'Is the internet a fad?', {
subtitle: 'Carlos Valente', id: '1',
timeStart: '10:00', title: 'Is the internet a fad?',
timeEnd: '11:30', subtitle: 'It is',
clockStarted: dummy, presenter: 'Carlos Valente',
timerDuration: 10, timeStart: '10:00',
message: { timeEnd: '11:30',
text: 'Hurry Up!', clockStarted: dummy,
color: '#F00', timerDuration: 10,
active: false, message: {
}, text: 'Hurry Up!',
color: '#F00',
active: false,
},
},
{
id: '2',
title: 'Is reddit a dictatorship?',
subtitle: 'It is',
presenter: 'Carlos Valente',
timeStart: '11:40',
timeEnd: '13:00',
clockStarted: dummy,
timerDuration: 10,
message: {
text: 'Hurry Up!',
color: '#F00',
active: false,
},
},
],
}; };
+8 -2
View File
@@ -1,7 +1,8 @@
import { Flex, Text } from '@chakra-ui/layout'; import { Button } from '@chakra-ui/button';
import { Heading } from '@chakra-ui/layout'; import { Heading } from '@chakra-ui/layout';
import { SimpleGrid } from '@chakra-ui/layout'; import { SimpleGrid } from '@chakra-ui/layout';
import { Box } from '@chakra-ui/layout'; import { Box } from '@chakra-ui/layout';
import { useState } from 'react';
import NumberedText from '../../common/components/text/NumberedText'; import NumberedText from '../../common/components/text/NumberedText';
import EventForm from '../form/EventForm'; import EventForm from '../form/EventForm';
import PreviewContainer from '../viewers/PreviewContainer'; import PreviewContainer from '../viewers/PreviewContainer';
@@ -9,6 +10,8 @@ import styles from './Editor.module.css';
import EventList from './list/EventList'; import EventList from './list/EventList';
export default function Editor() { export default function Editor() {
const [selectedEvent, setSelectedEvent] = useState(null);
return ( return (
<SimpleGrid <SimpleGrid
minChildWidth='120px' minChildWidth='120px'
@@ -19,7 +22,10 @@ export default function Editor() {
<Heading>List Events</Heading> <Heading>List Events</Heading>
<NumberedText number={1} text={'Select Event'} /> <NumberedText number={1} text={'Select Event'} />
<div className={styles.content}> <div className={styles.content}>
<EventList /> <EventList selected={selectedEvent} setSelected={setSelectedEvent} />
<div className={styles.buttons}>
<Button colorScheme='teal'>Add Event</Button>
</div>
</div> </div>
</Box> </Box>
+3 -3
View File
@@ -6,8 +6,8 @@
.editor { .editor {
height: 100%; height: 100%;
margin-top: 1em; margin-top: 2.5vh;
background-color: white; background-color: #fcfcfa;
padding: 2em; padding: 2em;
display: flex; display: flex;
@@ -16,4 +16,4 @@
.content { .content {
padding-top: 2em; padding-top: 2em;
} }
+28 -52
View File
@@ -1,56 +1,32 @@
import { import { Table, Thead, Tbody, Tr, Th } from '@chakra-ui/react';
Table, import { useState } from 'react';
Thead, import { sampleData } from '../../../app/sampleData';
Tbody, import EventListItem from './EventListItem';
Tr,
Th, export default function EventList(props) {
Td, const [data, setData] = useState(sampleData);
TableCaption,
Button,
} from '@chakra-ui/react';
export default function EventList() {
return ( return (
<div className> <Table variant='simple' size='sm'>
<Table variant='simple' size='sm'> <Thead>
<TableCaption>Todays event list</TableCaption> <Tr>
<Th>Event Title</Th>
<Thead> <Th>Presenter Name</Th>
<Tr> <Th>Time Start</Th>
<Th>Event Title</Th> <Th>Time End</Th>
<Th>Event Subtitle</Th> <Th></Th>
<Th>Presenter Name</Th> </Tr>
<Th>Time Start</Th> </Thead>
<Th>Time End</Th> <Tbody>
<Th>Timer</Th> {data.events.map((e) => (
<Th></Th> <EventListItem
</Tr> key={e.id}
</Thead> data={e}
<Tbody> isSelected={props.selected === e.id}
<Tr> setSelected={props.setSelected}
<Td>Title</Td> />
<Td>Subtitle</Td> ))}
<Td>Presenter</Td> </Tbody>
<Td>10:00</Td> </Table>
<Td>11:00</Td>
<Td>60.00</Td>
<Td>
<Button colorScheme='teal'></Button>
</Td>
</Tr>
<Tr>
<Td>Title</Td>
<Td>Subtitle</Td>
<Td>Presenter</Td>
<Td>10:00</Td>
<Td>11:00</Td>
<Td>60.00</Td>
<Td>
<Button colorScheme='teal'></Button>
</Td>
</Tr>
</Tbody>
</Table>
</div>
); );
} }
@@ -0,0 +1,27 @@
import { Button } from '@chakra-ui/button';
import { Td, Tr } from '@chakra-ui/table';
export default function EventListItem(props) {
return (
<Tr
style={
props.isSelected
? { backgroundColor: '#b2f5ea' }
: { backgroundColor: 'white' }
}
>
<Td>{props.data.title}</Td>
<Td>{props.data.presenter}</Td>
<Td>{props.data.timeStart}</Td>
<Td>{props.data.timeEnd}</Td>
<Td>
<Button
colorScheme='teal'
onClick={() => props.setSelected(props.data.id)}
>
</Button>
</Td>
</Tr>
);
}