-
Notifications
You must be signed in to change notification settings - Fork 36
feat(atomic): add formats for new numeric facet #911
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
Conversation
@@ -6,11 +6,11 @@ | |||
"experimentalDecorators": true, | |||
"lib": [ | |||
"dom", | |||
"es2017" | |||
"es2020" |
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.
Bumped in order to get the latest changes for that issue microsoft/TypeScript#38012
PR adds to ES2020 and not ES2017 microsoft/TypeScript#38013
I could also roll it back and use declaration merging for the NumberFormatOptions
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 think it should be good for all modern browser, so...
formatter: NumberFormatter, | ||
element: Element | ||
) => { | ||
const event = buildCustomEvent('atomic/numberFormat', formatter); |
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.
Any component that will listen to that event can use the formats web component as children
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 might pose a small challenge for documentation, to be able to express that component X should be used with component Y (child/parent).
Food for thoughts @dlutzCoveo :)
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.
RIght now only that facet, in the future, possibly some result template component e.g. atomic-result-number
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.
We could leverage doc tags here 🤔
Pull Request Report PR Title ✅ Title follows the conventional commit spec. Bundle Size
|
event.preventDefault(); | ||
event.stopPropagation(); |
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 don't understand the purpose of these two lines.
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.
preventDefault: If invoked when the cancelable attribute value is true, and while executing a listener for the event with passive set to false, signals to the operation that caused event to be dispatched that it needs to be canceled.
It allows us to know when the event has been caught by an handler, this way, if it's not caught, we can display an error saying "The component was not handled as it is not a child of a compatible component"
stopPropagation: When dispatched in a tree, invoking this method prevents event from reaching any objects other than the current object.
Basically prevents the event from bubbling up once it's caught, a safety mesure
packages/atomic/src/components/formats/atomic-format-currency.tsx
Outdated
Show resolved
Hide resolved
packages/atomic/src/components/facets-v1/atomic-numeric-facet/atomic-numeric-facet.tsx
Outdated
Show resolved
Hide resolved
|
||
/** | ||
* The currency to use in currency formatting. Possible values are the ISO 4217 currency codes, such as "USD" for the US dollar, "EUR" for the euro, or "CNY" for the Chinese RMB. | ||
* See the current [currency & funds code list](https://tc39.es/proposal-unified-intl-numberformat/section6/locales-currencies-tz_proposed_out.html#sec-currency-codes). |
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 checked that URL but could not see any list... 🤔
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.
updated with link in mozilla doc
@Prop() public currency!: string; | ||
|
||
componentWillLoad() { | ||
try { |
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.
Why could this throw an error ? In what scenario ?
edit: Is it the parseFloat
inside 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.
toLocaleString
throws errors e.g. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toLocaleString#checking_for_support_for_locales_and_options_arguments
If you use a wrong, locale, unit, currency, etc.
packages/atomic/src/components/formats/atomic-format-currency.tsx
Outdated
Show resolved
Hide resolved
packages/atomic/src/components/formats/atomic-format-number.tsx
Outdated
Show resolved
Hide resolved
@Prop() public maximumSignificantDigits?: number; | ||
|
||
componentWillLoad() { | ||
try { |
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.
Same question as above regarding why this can throw an error.
formatter: NumberFormatter, | ||
element: Element | ||
) => { | ||
const event = buildCustomEvent('atomic/numberFormat', formatter); |
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 might pose a small challenge for documentation, to be able to express that component X should be used with component Y (child/parent).
Food for thoughts @dlutzCoveo :)
@@ -6,11 +6,11 @@ | |||
"experimentalDecorators": true, | |||
"lib": [ | |||
"dom", | |||
"es2017" | |||
"es2020" |
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 think it should be good for all modern browser, so...
https://coveord.atlassian.net/browse/KIT-751
Upcoming work:
https://www.figma.com/file/BWSlnVeORhILh79Z2gSf1U/Atomic-v1?node-id=0%3A1
https://docs.google.com/document/d/1Mg-5Iuh88trrulUUYzfQh2npSboMhzvWkXzaMQDsUEs/edit#heading=h.soxpq1m179g6