FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

feat(date-picker): add pf-date-picker by ArathyKumar · Pull Request #2599 · patternfly/patternfly-elements · GitHub

feat(date-picker): add pf-date-picker - #2599

Draft
ArathyKumar wants to merge 19 commits into
patternfly:mainfrom
ArathyKumar:feature/pf-date-picker
Draft

feat(date-picker): add pf-date-picker#2599
ArathyKumar wants to merge 19 commits into
patternfly:mainfrom
ArathyKumar:feature/pf-date-picker

Conversation

Copy link
Copy Markdown
Collaborator

What I did

Created date-picker component to resolve the issue #2536.

changeset-bot Bot commented Sep 27, 2023
edited
Loading

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: e9e9833

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

ArathyKumar marked this pull request as ready for review September 27, 2023 13:48
bennypowers changed the title Feature/pf date picker feat(date-picker): add pf-date-picker Sep 27, 2023
bennypowers requested a review from nikkimk October 15, 2023 07:14
bennypowers added this to the PatternFly Elements 3 milestone Nov 8, 2023
bennypowers removed this from the PatternFly Elements 3 milestone Dec 4, 2023

bennypowers left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

some initial review to get the ball rolling

Comment thread elements/pf-date-picker/demo/demo.css Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

we should prefer to inline all the css and js for the demos directly into the html files

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Added inline css and js for the html demo files.

<section>
<h2>Date Format</h2>
<pre><code>&lt;pf-date-picker dateFormatInput="YYYY-DD-MM"&gt;&lt;/pf-date-picker&gt;</code></pre>
<pf-date-picker dateFormatInput="YYYY-DD-MM"></pf-date-picker>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

we should prefer dash-case attributes for camelCase DOM properties, i.e. date-format-input, since HTML attributes are case-insensitive.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Changed the DOM properties format from cameCase to dash-case.

<section>
<h2>Disabled</h2>
<pre><code>&lt;pf-date-picker isDisabled="true"&gt;&lt;/pf-date-picker&gt;</code></pre>
<pf-date-picker isDisabled="true"></pf-date-picker>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

We typically remove the is prefix for boolean attributes, see <pf-button disabled> for example

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Removed the is prefix form the disabled property.

Comment thread elements/package.json Outdated
Comment on lines +36 to +42
"./pf-date-picker/date-picker-helper.js": "./pf-date-picker/date-picker-helper.js",
"./pf-date-picker/pf-calendar.js": "./pf-date-picker/pf-calendar.js",
"./pf-date-picker/pf-date-picker.js": "./pf-date-picker/pf-date-picker.js",
"./pf-date-picker/pf-month-select.js": "./pf-date-picker/pf-month-select.js",
"./pf-date-picker/pf-next-button.js": "./pf-date-picker/pf-next-button.js",
"./pf-date-picker/pf-previous-button.js": "./pf-date-picker/pf-previous-button.js",
"./pf-date-picker/pf-year-input.js": "./pf-date-picker/pf-year-input.js",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

since upstream only provides the DatePicker react component, we should also try to limit the number of public components we ship here. We may make an exception if, for accessibility reasons, we need to put these elements in the same root. However, in the case of date picker, We can probably allow ourselves the luxury of doing everything in the same shadow root. We'll need to investigate that carefully

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Done.
Removed the child components exports list.

Comment thread elements/pf-date-picker/pf-calendar.ts Outdated
export class PfCalendar extends LitElement {
static readonly styles = [styles];

private currentDate: Date = new Date();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

prefer ecmascript private fields where possible

Suggested change
private currentDate: Date = new Date();
#currentDate = new Date();

also note that in this case you can do without the type annotation, TS will figure it out from the initializer on the RHS

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Added ES6 private fields

Comment thread elements/pf-date-picker/pf-calendar.ts Outdated
private weeks: number[] = [0, 1, 2, 3, 4, 5]; // 1 previous month week, 4 current month weeks, 1 next month week

// Input properties from the parent
@property() currentYear: number = this.currentDate.getFullYear();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I noticed this isn't a public prop on pfv4 DatePicker or CalendarFormat, so do we need it to be a public @property here? or can it be a private field?

if it does need to be private, see notes on the demo file regarding attribute names

Suggested change
@property() currentYear: number = this.currentDate.getFullYear();
@property({ type: Number, attribute: 'current-year' }) currentYear: number = this.currentDate.getFullYear();

@property() currentMonth: number = this.currentDate.getMonth();
@property() currentWeek = 0;
@property() selectedDay: number = this.currentDate.getDate();
@property() focusRef!: HTMLButtonElement;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

we shouldn't need this to be a public @property

Comment thread elements/pf-date-picker/pf-calendar.ts Outdated
Comment on lines +73 to +76
constructor() {
super();
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality
Suggested change
constructor() {
super();
}

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Removed the constructor.

Comment thread elements/pf-date-picker/pf-calendar.ts Outdated
Comment on lines +54 to +55
private weekdays: number[] = [0, 1, 2, 3, 4, 5, 6]; // S, M, T, W, T, F, S
private weeks: number[] = [0, 1, 2, 3, 4, 5]; // 1 previous month week, 4 current month weeks, 1 next month week

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

if these are constants, we probably don't need to store them on the class.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Added constants to the helper file.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

These shouldn't be separate elements, but rather pf-button in the parent template

</pf-previous-button>
</div>
<div class="date-picker-table-col date-picker-table-month-year">
<pf-month-select

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I believe we'd want to use <pf-dropdown> here instead of creating the new component of <pf-month-select>.

This goes along with @bennypowers previous comment about public components #2599 (comment) and his comment about <pf-next/previous-button> #2599 (comment)

ArathyKumar Jun 29, 2024
edited
Loading

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Hey @zeroedin
Thank you so much for reviewing.

I developed the <pf-month-select> component for the date-picker because <pf-dropdown> was not yet available. I will go ahead and change it now to <pf-dropdown> as it will be a much simpler implementation.

@monthExpandState=${this.#getMonthExpandState}
.isMonthExpanded=${this.monthExpand}>
</pf-month-select>
<pf-year-input

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Similar to the above, I would think we'd want to use <pf-text-input type="number"> instead of creating a new component here. However I do see that pf-text-input doesn't support min and max attrs which are needed here, @bennypowers since PF4 doesn't appear to extend these attributes on a number type, would we just want to implement a standard <input type="number">?

bennypowers marked this pull request as draft July 18, 2024 14:25
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants


Back | FazBrowse Home | New Git URL