Skip to content

Commit 0e9273a

Browse files
committed
rename AgendaEvent
1 parent 8ee9a03 commit 0e9273a

File tree

6 files changed

+60
-52
lines changed

6 files changed

+60
-52
lines changed

packages/x-scheduler/src/agenda-view/AgendaView.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { selectors } from '@mui/x-scheduler-headless/use-event-calendar';
1111
import { useEventOccurrencesGroupedByDay } from '@mui/x-scheduler-headless/use-event-occurrences-grouped-by-day';
1212
import { AgendaViewProps } from './AgendaView.types';
1313
import { EventPopoverProvider, EventPopoverTrigger } from '../internals/components/event-popover';
14-
import { AgendaEvent } from '../internals/components/event/agenda-event/AgendaEvent';
14+
import { EventItem } from '../internals/components/event/event-item/EventItem';
1515
import './AgendaView.css';
1616

1717
// TODO: Create a prop to allow users to customize the number of days in agenda view
@@ -85,7 +85,7 @@ export const AgendaView = React.memo(
8585
<EventPopoverTrigger
8686
occurrence={occurrence}
8787
render={
88-
<AgendaEvent
88+
<EventItem
8989
occurrence={occurrence}
9090
ariaLabelledBy={`DayHeaderCell-${day.key}`}
9191
/>

packages/x-scheduler/src/internals/components/event/agenda-event/AgendaEvent.types.ts

Lines changed: 0 additions & 17 deletions
This file was deleted.
Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
@import '../../../../styles/colors.css';
22

3-
.AgendaEventTitle {
3+
.EventItemTitle {
44
margin: 0;
55
color: var(--event-primary-text);
66
font-weight: var(--font-weight-2);
77
font-size: var(--font-size-1);
88
line-height: var(--line-height-1);
99
}
1010

11-
.AgendaEventTime {
11+
.EventItemTime {
1212
display: inline-block;
1313
color: var(--event-secondary-text);
1414
font-weight: var(--font-weight-1);
@@ -18,7 +18,7 @@
1818
width: 150px;
1919
}
2020

21-
.AgendaEventTime--compact {
21+
.EventItemTime--compact {
2222
width: fit-content;
2323
margin-inline-end: var(--space-1);
2424
}
@@ -31,45 +31,45 @@
3131
height: fit-content;
3232
}
3333

34-
.AgendaEventCardContent {
34+
.EventItemCardContent {
3535
margin: 0;
3636
height: var(--line-height-1);
3737
line-height: var(--line-height-1);
3838
}
3939

40-
.AgendaEventCardWrapper {
40+
.EventItemCardWrapper {
4141
display: flex;
4242
align-items: center;
4343
gap: var(--space-2);
4444
padding: var(--space-1) var(--space-2);
4545
}
46-
.AgendaEventCardWrapper--compact,
47-
.AgendaEventCardWrapper--allDay {
46+
.EventItemCardWrapper--compact,
47+
.EventItemCardWrapper--allDay {
4848
padding: 0 var(--space-1);
4949
}
5050

51-
.AgendaEventCard.EventCard {
51+
.EventItemCard.EventCard {
5252
padding: 0;
5353
border-radius: var(--radius-3);
5454
}
5555

56-
.AgendaEventCard--compact,
57-
.AgendaEventCard--allDay {
56+
.EventItemCard--compact,
57+
.EventItemCard--allDay {
5858
padding: 0;
5959
border-radius: var(--radius-3);
6060
}
6161

62-
.AgendaEventCard--compact:active,
63-
.AgendaEventCard--regular:active {
62+
.EventItemCard--compact:active,
63+
.EventItemCard--regular:active {
6464
background-color: var(--interactive-active-bg);
6565
}
6666

67-
.AgendaEventCard--compact:hover,
68-
.AgendaEventCard--regular:hover {
67+
.EventItemCard--compact:hover,
68+
.EventItemCard--regular:hover {
6969
background-color: var(--interactive-hover-bg);
7070
}
7171

72-
.AgendaEventCard--allDay {
72+
.EventItemCard--allDay {
7373
--event-background: var(--allDay-accepted-bg);
7474
color: var(--allDay-accepted-primary-text);
7575
}

packages/x-scheduler/src/internals/components/event/agenda-event/AgendaEvent.tsx renamed to packages/x-scheduler/src/internals/components/event/event-item/EventItem.tsx

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,20 @@ import { Repeat } from 'lucide-react';
77
import { useAdapter } from '@mui/x-scheduler-headless/use-adapter';
88
import { selectors } from '@mui/x-scheduler-headless/use-event-calendar';
99
import { useEventCalendarStoreContext } from '@mui/x-scheduler-headless/use-event-calendar-store-context';
10-
import { AgendaEventProps } from './AgendaEvent.types';
10+
import { EventItemProps } from './EventItem.types';
1111
import { getColorClassName } from '../../../utils/color-utils';
1212
import { useTranslations } from '../../../utils/TranslationsContext';
13-
import './AgendaEvent.css';
13+
import './EventItem.css';
1414
// TODO: Create a standalone component for the resource color pin instead of re-using another component's CSS classes
1515
import '../../resource-legend/ResourceLegend.css';
1616
import '../index.css';
1717

18-
export const AgendaEvent = React.forwardRef(function AgendaEvent(
19-
props: AgendaEventProps,
18+
/**
19+
* Component used to display an event occurrence, without any positioning capabilities
20+
* Used in <AgendaView /> and in the event popover of <MonthView /> to display the list of events for a specific day.
21+
*/
22+
export const EventItem = React.forwardRef(function EventItem(
23+
props: EventItemProps,
2024
forwardedRef: React.ForwardedRef<HTMLDivElement>,
2125
) {
2226
const {
@@ -54,16 +58,16 @@ export const AgendaEvent = React.forwardRef(function AgendaEvent(
5458
}
5559
/>
5660
<p
57-
className={clsx('AgendaEventCardContent', 'LinesClamp')}
61+
className={clsx('EventItemCardContent', 'LinesClamp')}
5862
style={{ '--number-of-lines': 1 } as React.CSSProperties}
5963
>
60-
<time className="AgendaEventTime AgendaEventTime--compact">
64+
<time className="EventItemTime EventItemTime--compact">
6165
<span>
6266
{adapter.format(occurrence.start, ampm ? 'hoursMinutes12h' : 'hoursMinutes24h')}
6367
</span>
6468
</time>
6569

66-
<span className="AgendaEventTitle">{occurrence.title}</span>
70+
<span className="EventItemTitle">{occurrence.title}</span>
6771
</p>
6872
{isRecurring && (
6973
<Repeat
@@ -80,7 +84,7 @@ export const AgendaEvent = React.forwardRef(function AgendaEvent(
8084
return (
8185
<React.Fragment>
8286
<p
83-
className={clsx('AgendaEventTitle', 'LinesClamp')}
87+
className={clsx('EventItemTitle', 'LinesClamp')}
8488
style={{ '--number-of-lines': 1 } as React.CSSProperties}
8589
>
8690
{occurrence.title}
@@ -98,7 +102,7 @@ export const AgendaEvent = React.forwardRef(function AgendaEvent(
98102
case 'regular':
99103
default:
100104
return (
101-
<div className="AgendaEventCardWrapper">
105+
<div className="EventItemCardWrapper">
102106
<span
103107
className="ResourceLegendColor"
104108
role="img"
@@ -109,13 +113,13 @@ export const AgendaEvent = React.forwardRef(function AgendaEvent(
109113
}
110114
/>
111115
<p
112-
className={clsx('AgendaEventCardContent', 'LinesClamp')}
116+
className={clsx('EventItemCardContent', 'LinesClamp')}
113117
style={{ '--number-of-lines': 1 } as React.CSSProperties}
114118
>
115119
{occurrence?.allDay ? (
116-
<span className="AgendaEventTime">{translations.allDay}</span>
120+
<span className="EventItemTime">{translations.allDay}</span>
117121
) : (
118-
<time className="AgendaEventTime">
122+
<time className="EventItemTime">
119123
<span>
120124
{adapter.format(occurrence.start, ampm ? 'hoursMinutes12h' : 'hoursMinutes24h')}
121125
</span>
@@ -126,7 +130,7 @@ export const AgendaEvent = React.forwardRef(function AgendaEvent(
126130
</time>
127131
)}
128132

129-
<span className="AgendaEventTitle">{occurrence.title}</span>
133+
<span className="EventItemTitle">{occurrence.title}</span>
130134
</p>
131135
{isRecurring && (
132136
<Repeat
@@ -161,14 +165,14 @@ export const AgendaEvent = React.forwardRef(function AgendaEvent(
161165
className,
162166
'EventContainer',
163167
'EventCard',
164-
'AgendaEventCard',
165-
`AgendaEventCard--${variant}`,
168+
'EventItemCard',
169+
`EventItemCard--${variant}`,
166170
getColorClassName(color),
167171
)}
168172
aria-labelledby={`${ariaLabelledBy} ${id}`}
169173
{...other}
170174
>
171-
<div className={clsx('AgendaEventCardWrapper', `AgendaEventCardWrapper--${variant}`)}>
175+
<div className={clsx('EventItemCardWrapper', `EventItemCardWrapper--${variant}`)}>
172176
{content}
173177
</div>
174178
</div>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { CalendarEventOccurrence } from '@mui/x-scheduler-headless/models';
2+
import { EventProps } from '../Event.types';
3+
4+
export interface EventItemProps extends EventProps {
5+
/**
6+
* The event occurrence to render.
7+
*/
8+
occurrence: CalendarEventOccurrence;
9+
/**
10+
* The event variant.
11+
* 'regular' does not make the styling distinction between all day events and timed events, expect for the time display. Used in <AgendaView />.
12+
* 'allDay' is styled to fit in smaller spaces. Displays the event title only on a solid background. Used in <MoreEventsPopover /> for all-day events.
13+
* 'compact' is styled to fit in smaller spaces. Displays the resource legend, event title alongside the event time on a neutral background. Used in <MoreEventsPopover /> for timed events.
14+
* @default 'regular'
15+
*/
16+
variant?: 'regular' | 'allDay' | 'compact';
17+
/**
18+
* ID of the header this event is associated with (for aria-labelledby).
19+
*/
20+
ariaLabelledBy: string;
21+
}

packages/x-scheduler/src/internals/components/more-events-popover/MoreEventsPopover.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { useAdapter } from '@mui/x-scheduler-headless/use-adapter';
66
import { useEventOccurrencesWithDayGridPosition } from '@mui/x-scheduler-headless/use-event-occurrences-with-day-grid-position';
77
import { MoreEventsPopoverProps, MoreEventsPopoverProviderProps } from './MoreEventsPopover.types';
88
import { useTranslations } from '../../utils/TranslationsContext';
9-
import { AgendaEvent } from '../event/agenda-event/AgendaEvent';
9+
import { EventItem } from '../event/event-item/EventItem';
1010
import { createPopover } from '../popover';
1111
import { ArrowSvg } from './arrow/ArrowSvg';
1212
import './MoreEventsPopover.css';
@@ -59,7 +59,7 @@ export default function MoreEventsPopoverContent(props: MoreEventsPopoverProps)
5959
</div>
6060
<div className="MoreEventsPopoverContent">
6161
{occurrences.map((occurrence) => (
62-
<AgendaEvent
62+
<EventItem
6363
variant={occurrence.allDay ? 'allDay' : 'compact'}
6464
key={occurrence.key}
6565
occurrence={occurrence}

0 commit comments

Comments
 (0)