-
Notifications
You must be signed in to change notification settings - Fork 601
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: add calendar component #4748
Conversation
β¦/robarb/calendar-component
β¦/robarb/calendar-component
β¦/robarb/calendar-component
β¦/robarb/calendar-component
β¦/robarb/calendar-component
β¦/robarb/calendar-component
β¦/robarb/calendar-component
β¦/robarb/calendar-component
@robarbms Would you mind dropping a few screenshots in? I probably won't get a chance to pull down the code and run it, but I'd love to see how this is looking. |
packages/web-components/fast-foundation/src/calendar/calendar.template.ts
Outdated
Show resolved
Hide resolved
packages/web-components/fast-foundation/src/calendar/calendar.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm having an issue running this in Safari and Firefox - can you look into what might be happening there and if we need fallbacks somewhere?
β¦microsoft/fast into users/robarb/calendar-component
This was an issue on date construction differences. Chrome and IE allow for |
packages/web-components/fast-components/src/calendar/calendar.styles.ts
Outdated
Show resolved
Hide resolved
packages/web-components/fast-foundation/src/calendar/calendar.template.ts
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love the flexibility supported here. Thanks for the hard work getting this done!
packages/web-components/fast-foundation/src/calendar/calendar.template.ts
Show resolved
Hide resolved
change/@microsoft-fast-components-c15c784b-9a60-441a-88dc-f032d990e5bb.json
Show resolved
Hide resolved
change/@microsoft-fast-foundation-8b1801b3-ce1d-4623-af8d-b8b388be0ddd.json
Show resolved
Hide resolved
* @public | ||
*/ | ||
public handleDateSelect(event: Event, day: CalendarDateInfo): void { | ||
event.preventDefault; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be a function call
? date | ||
: `${date.getMonth() + 1}-${date.getDate()}-${date.getFullYear()}`; | ||
|
||
return !!dates.find(d => d === date); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return !!dates.find(d => d === date); | |
return dates.some(d => d === date); |
let className: string = "day"; | ||
|
||
if (todayString === `${month}-${day}-${year}`) { | ||
className += " today"; | ||
} | ||
|
||
if (this.month !== month) { | ||
className += " inactive"; | ||
} | ||
|
||
if (disabled) { | ||
className += " disabled"; | ||
} | ||
|
||
if (selected) { | ||
className += " selected"; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be turned into an array to improve readability.
let className: string = "day"; | |
if (todayString === `${month}-${day}-${year}`) { | |
className += " today"; | |
} | |
if (this.month !== month) { | |
className += " inactive"; | |
} | |
if (disabled) { | |
className += " disabled"; | |
} | |
if (selected) { | |
className += " selected"; | |
} | |
const today = todayString === `${month}-${day}-${year}`; | |
const inactive = this.month !== month; | |
return [ | |
"day", | |
today && "today", | |
inactive && "inactive", | |
disabled && "disabled", | |
selected && "selected", | |
] | |
.filter(Boolean) | |
.join(" "); |
*/ | ||
public handleDateSelect(event: Event, day: CalendarDateInfo): void { | ||
event.preventDefault; | ||
(this as FASTElement).$emit("dateselected", day); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(this as FASTElement).$emit("dateselected", day); | |
this.$emit("dateselected", day); |
parseInt(dates[2]), | ||
parseInt(dates[0]) - 1, | ||
parseInt(dates[1]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be safer to specify the radix here. There are possible historical bugs which can show up when omitting the radix with parseInt
: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt#octal_interpretations_with_no_radix
parseInt(dates[2]), | |
parseInt(dates[0]) - 1, | |
parseInt(dates[1]) | |
parseInt(dates[2], 10), | |
parseInt(dates[0], 10) - 1, | |
parseInt(dates[1], 10) |
locale: string = this.locale | ||
): string { | ||
const dateObj = this.getDateObject(date); | ||
const optionsWithTimeZone = Object.assign({}, { timeZone: "utc" }, format); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const optionsWithTimeZone = Object.assign({}, { timeZone: "utc" }, format); | |
const optionsWithTimeZone = { timeZone: "utc", ...format }; |
Pull Request
π Description
This adds a basic calendar component. This will be used for a date picker component.
π« Issues
π©βπ» Reviewer Notes
Localization is particularly difficult because of all the market, calendar and numbering permutations. I have localization mostly baked in. I wasn't able to find an exact list of what calendar and numbering types each market uses. I haven't tested localization defaults outside of the en-US market.
π Test Plan
Need to figure out how to test other markets, calendar types and numbering systems.
β Checklist
General
$ yarn change
Component-specific
β Next Steps
Find a solution for calendars that don't align with the Gregorian calendar system.