|
1 | | -import md from 'markdown-it' |
2 | | -import clsx from 'clsx' |
| 1 | +import React, { useState } from 'react'; |
| 2 | +import md from 'markdown-it'; |
| 3 | +import clsx from 'clsx'; |
| 4 | +import Link from 'next/link'; |
3 | 5 |
|
4 | | -import Link from 'next/link' |
5 | | - |
6 | | -import ButtonLink from '../button-link/ButtonLink' |
7 | | - |
8 | | -import { getLiteral } from '../../common/i18n' |
9 | | -import * as ROUTES from '../../common/routes' |
10 | | - |
11 | | -import DateTimeChip from '../date-time-chip/DateTimeChip' |
12 | | -import EventTypeChip from '../event-type-chip/EventTypeChip' |
13 | | -import PlayLink from '../play-link/PlayLink' |
14 | | -import Chip from '../chip/Chip' |
| 6 | +import ButtonLink from '../button-link/ButtonLink'; |
| 7 | +import EventFilter from '../event-filter/EventFilter'; |
| 8 | +import eventTypes from '../event-filter/eventTypes'; |
| 9 | +import { getLiteral } from '../../common/i18n'; |
| 10 | +import DateTimeChip from '../date-time-chip/DateTimeChip'; |
| 11 | +import EventTypeChip from '../event-type-chip/EventTypeChip'; |
| 12 | +import Chip from '../chip/Chip'; |
15 | 13 |
|
16 | 14 | const EventsList = ({ events }) => { |
| 15 | + const [selectedType, setSelectedType] = useState('all'); |
| 16 | + const filteredEvents = selectedType === 'all' |
| 17 | + ? events |
| 18 | + : events.filter((event) => event.type === selectedType); |
| 19 | + |
17 | 20 | return ( |
18 | 21 | <section className="events-list"> |
19 | 22 | <div className="events-list__header"> |
20 | 23 | <div className="events-list__header-content"> |
21 | 24 | <h1 className="events-list__title">{getLiteral('schedule:title')}</h1> |
22 | 25 | <p className="events-list__subtitle">{getLiteral('schedule:description')}</p> |
23 | | - <ButtonLink |
24 | | - href="https://github.com/github/maintainermonth/issues/new?template=add-to-calendar.yml" |
25 | | - isExternal={true} |
26 | | - className="events-list__add-button" |
27 | | - > |
28 | | - {getLiteral('schedule:add-event')} |
29 | | - </ButtonLink> |
| 26 | + <div className="events-list__controls"> |
| 27 | + <ButtonLink |
| 28 | + href="https://github.com/github/maintainermonth/issues/new?template=add-to-calendar.yml" |
| 29 | + isExternal={true} |
| 30 | + className="events-list__add-button" |
| 31 | + > |
| 32 | + {getLiteral('schedule:add-event')} |
| 33 | + </ButtonLink> |
| 34 | + <EventFilter |
| 35 | + selectedType={selectedType} |
| 36 | + setSelectedType={setSelectedType} |
| 37 | + eventTypes={eventTypes} |
| 38 | + /> |
| 39 | + </div> |
30 | 40 | </div> |
31 | 41 | </div> |
32 | 42 |
|
33 | 43 | <div className="events-list__grid"> |
34 | | - {events.map((event, index) => ( |
| 44 | + {filteredEvents.map((event, index) => ( |
35 | 45 | <div |
36 | 46 | key={event.slug} |
37 | 47 | className={clsx('events-list__card', { |
@@ -68,7 +78,7 @@ const EventsList = ({ events }) => { |
68 | 78 | </div> |
69 | 79 |
|
70 | 80 | <div className="events-list__info"> |
71 | | - <p |
| 81 | + <p |
72 | 82 | className="events-list__text" |
73 | 83 | dangerouslySetInnerHTML={{ |
74 | 84 | __html: md().render(event.description || ''), |
|
0 commit comments