Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
0c7e698
[TASK] Add action to only allow PRs for main branch from dev branch
FamousWolf Jun 27, 2024
2192392
Merge pull request #87 from FamousWolf/dev
FamousWolf Jun 27, 2024
449b1f7
Merge pull request #90 from FamousWolf/dev
FamousWolf Jun 28, 2024
d9654ec
Merge pull request #104 from FamousWolf/dev
FamousWolf Jul 10, 2024
b7db639
[FEATURE] Add data attributes for date parts
FamousWolf Sep 1, 2024
99ba825
[FEATURE] Add event filter
Sep 1, 2024
1d780e8
[FEATURE] Add option to add or subtract days from the starting date
FamousWolf Sep 2, 2024
2c279b2
[FEATURE] Add option to show legend
Sep 2, 2024
38babe7
[FEATURE] Make sure events with the same starting date are sorted by …
Sep 2, 2024
07ee0a0
[TASK] Increase version to 1.7.0
Sep 2, 2024
2517b1a
Merge pull request #125 from FamousWolf/dev
FamousWolf Sep 2, 2024
e930a59
[BUGFIX] Fix legend styling bug
Sep 4, 2024
457a51b
Merge pull request #133 from FamousWolf/dev
FamousWolf Sep 4, 2024
395343f
Merge pull request #171 from FamousWolf/dev
FamousWolf Oct 28, 2024
40e4a2e
Merge pull request #181 from FamousWolf/dev
FamousWolf Nov 14, 2024
4481805
Merge pull request #185 from FamousWolf/dev
FamousWolf Nov 15, 2024
6b60b12
Merge pull request #195 from FamousWolf/dev
FamousWolf Nov 20, 2024
aef1328
Merge pull request #199 from FamousWolf/dev
FamousWolf Nov 21, 2024
168b528
Merge pull request #212 from FamousWolf/dev
FamousWolf Dec 3, 2024
ef3ed10
Merge pull request #227 from FamousWolf/dev
FamousWolf Dec 24, 2024
0128158
Merge pull request #239 from FamousWolf/dev
FamousWolf Jan 4, 2025
88e247a
Merge pull request #244 from FamousWolf/dev
FamousWolf Jan 6, 2025
4609bf2
Merge pull request #266 from FamousWolf/dev
FamousWolf Mar 6, 2025
43eae41
Merge pull request #289 from FamousWolf/dev
FamousWolf May 25, 2025
817ca66
updated to support custom navigation label
BigMes Oct 30, 2025
b001ebb
Consolidate navigationLabelFormat and navigationLabelTemplate
imc-kstewart Oct 30, 2025
8b99a25
adjust navigationLabelFormat for handling start and end dates of the …
BigMes Oct 31, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ Custom Home Assistant card displaying a responsive overview of multiple days wit
| `legendToggle` | boolean | false | `false` \| `true` | Toggle calendars by clicking on the legend | 1.11.0 |
| `columns` | object | optional | See [Columns](#columns) | Configuration to override the number of columns | 1.11.0 |
| `showNavigation` | boolean | false | `false` \| `true` | Show navigational arrows to traverse additional dates on calendar. | 1.12.0 |
| `showNavigationLabel` | boolean | true | `false` \| `true` | Show or hide the navigation label | 1.14.0 |
| `navigationLabelFormat` | string | `MMMM` | See [Luxon format](https://moment.github.io/luxon/#/formatting?id=table-of-tokens) | Format of the navigation label. Supports range templates using `{start: ...}` and `{end: ...}`. When these tokens are present, the left token formats the start date and the right token formats the inclusive end date. If omitted, the value is applied to the start date only. Example: `{start: MMM, dd} - {end: MMM, dd yyyy}` → `OCT, 27 - NOV, 09 2025`. | 1.14.0 |

### Calendars

Expand Down Expand Up @@ -317,3 +319,25 @@ calendars:
- calendar.my_calendar_1
dayFormat: '''<span class="number">''d''</span> <span class="month">''MMMM''</span>'''
```

### Navigation label single-date formatting

```yaml
type: custom:week-planner-card
calendars:
- entity: calendar.my_calendar_1
showNavigation: true
showNavigationLabel: true
navigationLabelFormat: 'MMM, dd yyyy'
```

### Navigation label range formatting

```yaml
type: custom:week-planner-card
calendars:
- entity: calendar.my_calendar_1
showNavigation: true
showNavigationLabel: true
navigationLabelFormat: '{start: MMM, dd} - {end: MMM, dd yyyy}'
```
45 changes: 44 additions & 1 deletion src/card.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export class WeekPlannerCard extends LitElement {
_showNavigation;
_navigationOffset = 0;
_updateEventsTimeouts = [];
_showNavigationLabel;

/**
* Get config element
Expand Down Expand Up @@ -174,6 +175,8 @@ export class WeekPlannerCard extends LitElement {
this._dayFormat = config.dayFormat ?? null;
this._dateFormat = config.dateFormat ?? 'cccc d LLLL yyyy';
this._timeFormat = config.timeFormat ?? 'HH:mm';
this._showNavigationLabel = config.showNavigationLabel ?? true;
this._navigationLabelFormat = config.navigationLabelFormat ?? 'MMMM';
this._locationLink = config.locationLink ?? 'https://www.google.com/maps/search/?api=1&query=';
this._showTitle = config.showTitle ?? true;
this._showDescription = config.showDescription ?? false;
Expand Down Expand Up @@ -365,11 +368,51 @@ export class WeekPlannerCard extends LitElement {
<li @click="${this._handleNavigationOriginalClick}"><ha-icon icon="mdi:circle-medium"></ha-icon></li>
<li @click="${this._handleNavigationNextClick}"><ha-icon icon="mdi:arrow-right"></ha-icon></li>
</ul>
<div class="month">${this._startDate.toFormat('MMMM')}</div>
${this._showNavigationLabel ?
html`<div class="month">${this._getNavigationLabel()}</div>` :
''
}
</div>
`;
}

_getNavigationLabel() {
if (this._showNavigationLabel) {
const template = this._navigationLabelFormat;

// Support explicit start/end templates like "{start: MMM} - {end: MMM yyyy}"
if (template?.includes('{')) {
return this._formatNavigationLabel(template);
}

// Default: single-date formatting
return this._startDate.toFormat(template);
}
return '';
}

_formatNavigationLabel(template) {
const startInclusive = this._startDate;
let endInclusive;

if (this._numberOfDaysIsMonth) {
// Show the visual end of the month
endInclusive = startInclusive.endOf('month');
} else {
// End is exclusive in calculations; make inclusive for display
endInclusive = startInclusive.plus({ days: this._numberOfDays }).minus({ days: 1 });
}

return template.replace(/\{(start|end):([^}]+)\}/g, (match, which, fmt) => {
const date = which === 'start' ? startInclusive : endInclusive;
try {
return date.toFormat(fmt.trim());
} catch (e) {
return match;
}
});
}

_renderDays() {
if (!this._days) {
return html``;
Expand Down
2 changes: 2 additions & 0 deletions src/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ export class WeekPlannerCardEditor extends LitElement {
${this.addBooleanField('hideTodayWithoutEvents', 'Also hide today without events')}
${this.addTextField('maxDayEvents', 'Maximum number of events per day (0 is no maximum)', 'number', 0)}
${this.addBooleanField('showNavigation', 'Show navigation')}
${this.addBooleanField('showNavigationLabel', 'Show navigation label', true)}
${this.addTextField('navigationLabelFormat', 'Navigation label format (Luxon)', 'text', 'MMMM')}
`
)}
${this.addExpansionPanel(
Expand Down