0
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-08-15 17:24:47 +08:00
discourse/plugins/discourse-calendar/assets/stylesheets/common/discourse-calendar.scss
Régis HANOL 40ea3cfe1a
FEATURE: Show event description in calendar popup (#39076)
When clicking an event in the calendar (upcoming events or category
calendar), the popup showed event details like dates, recurrence, and
invitees — but not the description. Users had to click through to the
topic to see it, which was a common customer complaint.

This enables the description in the calendar popup by flipping
`@withDescription` to `true` in the `PostEventMenu` component and
introducing a `@clampDescription` arg that controls whether the
description is truncated.

In the popup, descriptions are clamped to 3 lines using the existing
`line-clamp` mixin with a "Show more"/"Show less" toggle. A
`ResizeObserver` detects whether the text actually overflows, so the
toggle only appears when needed. In the topic view, the full description
is shown without clamping.

The description is stored as plain text (the event parser extracts it
via `doc.text.strip` from the cooked HTML), so it's rendered as a plain
`<p>` element rather than through `CookText`. This also makes overflow
detection straightforward since there's no async rendering.

Other changes:
- Added a `file-lines` icon and grid layout to the description section
to match the visual pattern of other event sections (dates, location,
recurrence)
- Increased the event loader `min-height` from 100px to 200px to reduce
layout shift while the event widget loads
- Removed the pre-existing assertion that descriptions auto-link URLs,
since descriptions are plain text

**Calendar popup**
<img width="543" height="383" alt="2026-04-02 @ 14 40 48"
src="https://github.com/user-attachments/assets/b73e01b5-ab67-455d-a4d6-d74a66373c31"
/>
<img width="540" height="535" alt="2026-04-02 @ 14 40 53"
src="https://github.com/user-attachments/assets/d63ad3ad-acf1-4aa0-b14d-00149243de51"
/>

**Topic**
<img width="712" height="466" alt="2026-04-02 @ 14 41 01"
src="https://github.com/user-attachments/assets/164591fe-6684-4632-938d-d17d32357675"
/>

Ref - t/180829
2026-04-08 16:50:36 +02:00

291 lines
5.1 KiB
SCSS
Vendored

@use "lib/viewport";
.before-topic-list-body-outlet.category-calendar {
display: table-caption;
}
a.holiday {
cursor: default;
}
.combo-box.user-timezone {
min-width: 15em;
}
.grouped-event {
--fc-event-bg-color: var(--primary-low);
--fc-event-border-color: var(--primary-low-mid);
--fc-event-text-color: var(--primary);
background-color: var(--fc-event-bg-color);
border: 1px solid var(--fc-event-border-color);
}
.group-timezones {
display: grid;
width: 100%;
box-sizing: border-box;
margin-bottom: 1rem;
&[data-size="auto"],
&.auto {
height: auto;
}
&[data-size="small"],
&.small {
height: 175px;
}
&[data-size="medium"],
&.medium {
height: 300px;
}
&[data-size="large"],
&.large {
height: 600px;
}
}
.group-timezones-header {
display: flex;
width: 100%;
align-items: center;
justify-content: space-between;
margin-bottom: 0.5em;
box-sizing: border-box;
.title {
font-weight: bold;
text-transform: capitalize;
}
}
.group-timezones-time-traveler {
display: flex;
align-items: center;
.time {
font-weight: 700;
margin-right: 0.5em;
min-width: 45px;
}
}
.mobile-view .group-timezones-time-traveler,
.mobile-view .group-timezones-filter {
display: none;
}
.discourse-group-timezones-slider-wrapper {
// we need the wrapper because Firefox doesn't allow pseudo selectors on inputs
position: relative;
margin: 0.25em 0;
margin-right: 0.5em;
&::before {
display: block;
content: "";
position: absolute;
margin-top: -1px;
background: var(--tertiary);
height: 2px;
top: 50%;
width: 100%;
}
}
.group-timezones-slider {
position: relative;
z-index: 1; // need a positive z-index to appear above the ::before
display: flex;
width: 120px;
padding: 0.25em;
appearance: none;
cursor: pointer;
font: inherit;
outline: none;
box-sizing: border-box;
background-color: transparent;
}
.group-timezones-body {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
grid-template-rows: auto;
gap: 0.25em;
box-sizing: border-box;
overflow-y: auto;
.group-timezones-header {
.title {
font-weight: 700;
}
}
.group-timezone,
.group-timezone-new-day {
box-sizing: border-box;
display: flex;
flex-direction: column;
padding: 0.25em;
}
.group-timezone-new-day {
align-items: center;
justify-content: space-between;
color: inherit;
font-size: var(--font-down-1);
.before {
margin-right: auto;
text-transform: capitalize;
}
.after {
margin-left: auto;
text-transform: capitalize;
}
}
.group-timezone {
color: var(--primary);
background-color: var(--calendar-normal);
transition: opacity 0.4s;
opacity: 0.5;
&:first-child {
margin-left: 0;
}
&:last-child {
margin-right: 0;
}
&.close-to-working-hours {
background-color: var(--calendar-close-to-working-hours);
opacity: 0.7;
}
&.in-working-hours {
background-color: var(--calendar-in-working-hours);
opacity: 1;
}
&:hover {
opacity: 1;
}
.info {
display: flex;
flex-direction: row;
align-items: center;
.time {
font-weight: 700;
}
.offset {
font-size: var(--font-down-2);
margin-left: 0.5em;
}
}
.group-timezones-members {
padding: 0;
margin: 0.1em 0;
.group-timezones-member {
margin: 0.1em;
list-style: none;
display: inline-block;
&.on-holiday {
opacity: 0.7;
position: relative;
}
&.on-holiday::after {
content: "📅";
position: absolute;
bottom: -0.15em;
left: 1em;
font-size: var(--font-down-2);
}
}
}
}
}
.group-timezones-reset {
display: flex;
margin-left: 0.5em;
}
.group-timezones-filter[type="text"] {
margin: 0;
width: 120px;
}
.emoji.on-holiday {
width: 15px;
height: 15px;
}
.discourse-post-event-upcoming-events {
height: calc(
var(--composer-vh, 1dvh) *
100 - var(--main-outlet-offset, 0px) - var(
--main-outlet-padding-top
) - var(--main-outlet-padding-bottom) - var(
--powered-by-height,
0px
) - var(--below-topic-margin)
);
}
.discourse-calendar-wrap {
border: 0;
margin-inline: 3px;
box-shadow:
0 0 0 1px var(--primary-300),
0 0 0 3px var(--primary-100);
// Makes the outer drop shadow radius equal to --d-border-radius
border-radius: calc(var(--d-border-radius) - (3px / 2));
.fc th {
font-weight: normal;
text-align: center;
}
tr.fc-list-event td {
padding: 0.25rem !important;
}
.fc td,
.fc th {
padding: 0 !important;
}
.post-calendar {
.fc .fc-toolbar.fc-header-toolbar {
margin: 0;
padding: 0.25rem;
}
}
}
.fk-d-menu.discourse-post-event-more-menu-content {
.mobile-view & {
z-index: z("modal", "dropdown");
}
}
.discourse-post-event-loader {
width: 100%;
min-height: 200px;
display: flex;
align-items: center;
justify-content: center;
}