Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(sbb-calendar): vertical orientation #3378

Open
wants to merge 21 commits into
base: main
Choose a base branch
from

Conversation

DavideMininni-Fincons
Copy link
Contributor

Preflight Checklist

Issue

This PR Closes #3336

Pull request checklist

Please check if your PR fulfills the following requirements:

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been reviewed and added / updated if needed (for bug fixes / features)

See Review Guidelines for more information what is checked during review process.

Changes

Changes in this pull request:

  • a new parameter called orientation has been added on the sbb-calendar, which accept horizontal (default) and vertical as values;
  • implementation of vertical orientation;
  • fix bug in keyboard navigation in wide mode in month view;
  • refactoring of the whole logic of the keyboard navigation in day view, since it relies on calculation on the elements position (index of the element in the array of rendered cells). With vertical orientation the first rendered element is always the first Monday of the month and not the first day of the month. To fix this, the data-day attribute has been replaced with the value which is filled with the day's corresponding date as ISO string. Keyboard navigation is now a date calculation;
  • related to previous point, fix on the logic of the firstFocusable calculation;
  • improvements on docs and tests

Browsers

I tested the build on the following browsers:

  • Firefox Desktop
  • Chrome Desktop
  • Edge Desktop
  • Safari Desktop
  • Chrome Mobile
  • Safari Mobile

Screen readers

I tested the build on the following browsers:

  • JAWS Firefox Desktop
  • JAWS Chrome Desktop
  • NVDA Firefox Desktop
  • NVDA Chrome Desktop
  • VoiceOver Safari Desktop
  • VoiceOver Chrome Desktop
  • VoiceOver Safari Mobile
  • Android Accessibility Suite Chrome Mobile

Pull request type

Please check the type of change your PR introduces:

  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes
  • Other (please describe):

Does this introduce a breaking change?

  • Yes
  • No

Other information

@DavideMininni-Fincons DavideMininni-Fincons linked an issue Jan 31, 2025 that may be closed by this pull request
9 tasks
@github-actions github-actions bot added target: 2.x pr: peer review required A peer review is required for this pull request labels Jan 31, 2025
@github-actions github-actions bot temporarily deployed to pr3378 January 31, 2025 10:20 Inactive
@github-actions github-actions bot temporarily deployed to pr3378-diff January 31, 2025 10:20 Inactive
Copy link
Contributor

@MarioCastigliano MarioCastigliano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job. Just a consideration about the fact that the width of the component depends on which month is currently in view, like in horizontal mode the height was changing, but in this case it can happen that you kinda have to chase the next month arrow around. Should this be addressed somehow? (maybe an empty column when necessary)

Also I think I might have a suggestion for a more efficient way to render the tables, but since it would have been a million comments (and I'm not 100% sure it would work) it's easier for me to try to implement it and show it to you

@github-actions github-actions bot temporarily deployed to pr3378 February 4, 2025 17:10 Inactive
@github-actions github-actions bot temporarily deployed to pr3378-diff February 4, 2025 17:10 Inactive
@github-actions github-actions bot temporarily deployed to pr3378 February 5, 2025 11:29 Inactive
@github-actions github-actions bot temporarily deployed to pr3378-diff February 5, 2025 11:30 Inactive
@@ -266,117 +275,236 @@ describe(`sbb-calendar`, () => {
).to.be.equal('2022');
});

describe('navigation', () => {
it('navigates left via keyboard', async () => {
describe('keyboard navigation', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's a little bit more readable if the test names can be read with "it ....", either like "it should focus on the selected...", or "it focuses on the selected date...". Similar for other tests.

value: string;
dayValue: string;
monthValue: string;
yearValue: string;
dateValue: T;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a (soft) breaking change (generic type and required dateValue). Should we merge this or not? @kyubisation

private _handleKeyboardEvent(event: KeyboardEvent, day?: Day): void {
/**
* In `day` view in `vertical` orientation,
* if the first of the month is not a Monday, it is not the first rendered element is the table,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably in?

Suggested change
* if the first of the month is not a Monday, it is not the first rendered element is the table,
* if the first of the month is not a Monday, it is not the first rendered element in the table,

@@ -192,6 +199,15 @@ export abstract class DateAdapter<T = any> {
return `${pad(this.getYear(date), 4)}-${pad(this.getMonth(date))}-${pad(this.getDate(date))}`;
}

/**
* Retruns a date from ISO String.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Retruns a date from ISO String.
* Returns a date from ISO String.

* Retruns a date from ISO String.
* @param date The ISO String date to convert to T.
*/
public fromIso8601(date: string): T {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this method is already covered by deserialize() and should be removed here.

* Gets the date as milliseconds since epoch.
* @param date
*/
public abstract getTime(date: T): number;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

time should not be part of a date adapter. is there an alternative solution?

@@ -34,6 +34,11 @@ export class NativeDateAdapter extends DateAdapter<Date> {
return date.getDate();
}

/** Gets the date as milliseconds since epoch. */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment in date-adapter

@mcilurzo mcilurzo added pr: ux review approved Pull request has been approved by a ux review and removed pr: ux review required A ux review is required for this pull request labels Feb 20, 2025
@mcilurzo
Copy link
Contributor

looks good to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
diff-available pr: peer review required A peer review is required for this pull request pr: ux review approved Pull request has been approved by a ux review pr: visual review required preview-available target: 2.x
Projects
None yet
Development

Successfully merging this pull request may close these issues.

story(sbb-calendar): vertical orientation
5 participants