Skip to content

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

Merged
merged 3 commits into from
Jun 21, 2021
Merged

Conversation

@@ -6,11 +6,11 @@
"experimentalDecorators": true,
"lib": [
"dom",
"es2017"
"es2020"
Copy link
Contributor Author

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

Copy link
Member

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);
Copy link
Contributor Author

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

Copy link
Member

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 :)

Copy link
Contributor Author

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

Copy link
Contributor Author

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 🤔

@ThibodeauJF ThibodeauJF requested a review from dlutzCoveo June 21, 2021 11:06
@github-actions
Copy link

github-actions bot commented Jun 21, 2021

Pull Request Report

PR Title

✅ Title follows the conventional commit spec.

Bundle Size

File Compression Old (kb) New (kb) Change (%)
dist/browser/headless.js bundled 535.9 535.9 0
minified 220.7 220.7 0
gzipped 63 63 0
dist/browser/headless.esm.js bundled 519.1 519.1 0
minified 283.8 283.8 0
gzipped 69 69 0
dist/browser/case-assist/headless.js bundled 0.5 0.5 0
minified 0.3 0.3 0
gzipped 0.2 0.2 0
dist/browser/case-assist/headless.esm.js bundled 0.1 0.1 0
minified 0 0 0
gzipped 0.1 0.1 0
dist/browser/recommendation/headless.js bundled 352.2 352.2 0
minified 156.4 156.4 0
gzipped 45.3 45.3 0
dist/browser/recommendation/headless.esm.js bundled 343.1 343.1 0
minified 193.4 193.4 0
gzipped 49.5 49.5 0
dist/browser/product-recommendation/headless.js bundled 347.5 347.5 0
minified 154.2 154.2 0
gzipped 44.8 44.8 0
dist/browser/product-recommendation/headless.esm.js bundled 338.4 338.4 0
minified 191.3 191.3 0
gzipped 49 49 0

Comment on lines +139 to +140
event.preventDefault();
event.stopPropagation();
Copy link
Contributor

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.

Copy link
Contributor Author

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


/**
* 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).
Copy link
Member

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... 🤔

Copy link
Contributor Author

@ThibodeauJF ThibodeauJF Jun 21, 2021

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 {
Copy link
Member

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 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Prop() public maximumSignificantDigits?: number;

componentWillLoad() {
try {
Copy link
Member

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);
Copy link
Member

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"
Copy link
Member

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...

@ThibodeauJF ThibodeauJF merged commit aca6a25 into master Jun 21, 2021
@ThibodeauJF ThibodeauJF deleted the KIT-751-3 branch June 21, 2021 19:26
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.

5 participants