-
Notifications
You must be signed in to change notification settings - Fork 43
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
[web] Agama core/Section improvements #816
Conversation
99c28c5
to
c459324
Compare
aad3182
to
7379ff3
Compare
7094689
to
a61df81
Compare
@@ -149,10 +147,19 @@ const icons = { | |||
* | |||
*/ | |||
export default function Icon({ name, className = "", size = 32, ...otherProps }) { | |||
if (!icons[name]) { | |||
console.error(sprintf(_("Icon %s not found!"), name)); |
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.
NOTE: I wonder if worth it adding a process.env.NODE_ENV
check for not delivering these console.error
in the production build.
console.error(sprintf(_("Icon %s not found!"), name)); | |
process.env.NODE_ENV !== "production" && console.error(sprintf(_("Icon %s not found!"), name)); |
or even to have a logError
util for using it in every place we do a console.error
const logError = (error) => {
if (process.node.NODE_ENV !== "production") {
console.error(error);
}
};
console.error(sprintf(_("Icon %s not found!"), name)); | |
logError(sprintf(_("Icon %s not found!"), name)); |
Not sure if webpack automatically drop these blocks from the production build. Has to check.
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've checked by my own that blocks conditioned to process.env.NODE_ENV !== 'production'
are not shipped in the production build. Which is great. So, creating an issue for wrap all console.error
s
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.
Discarded. See #842
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 looks good. Thanks!
Oh, it looks like you have a conflict to fix (originated after merging #831). |
By using aria-label and aria-laballedby attributes.
And set the aria-busy attribute when it's in loading mode.
Trust in the truthy value of props instead of checking if present and not empty. See https://developer.mozilla.org/en-US/docs/Glossary/Truthy
Beacuse crypto.randomUUID() was added in version 22.1.0 [1][2] but the jest-environment-jsdom dependency will be updated with jest v30[3] [1] jsdom/jsdom#3551 [2] https://github.com/jsdom/jsdom/blob/master/Changelog.md#2210 [3] jestjs/jest#13825 (comment)
Because it's no longer possible to mock some window properties since jsdom 21.0.0 and it was updated to version 22.1.0 in previous commits. See https://github.com/jsdom/jsdom/blob/master/Changelog.md#2100 and jsdom/jsdom#3492
Output the error to the console instead of rendering it in the UI.
Checking the data-icon-name attribute.
eedc325
to
7daef3e
Compare
Problem
We've identified a use case where a section without title makes a lot of sense. The introductory sections at the top of the page, which is the case of current Software page at the time of writing.
And probably more use cases will arise.
Solution
To add support for sections without title and take the opportunity for improving the component a little bit and start adding support for a11n.
Additionally, the layout/Icon component has been improved a bit too, for outputting errors to the console instead of the UI and for including the icon name as data attribute of the rendered SVG for easily identify it.
Side effects
As part of this PR
jsdom
dependency has been updated by using theoverrides
package.json key because of the use ofcrypto.randomUUID
and a few tests using mocks forwindown.location
has to be rewritten since it's no longer possible to mock it anymore. See https://github.com/jsdom/jsdom/blob/master/Changelog.md#2100 and jsdom/jsdom#3492 to know more.In any case,
jest-environtment-jsdom
is about to update it in the next version, jestjs/jest#13825 (comment). So, we're prepared already.Testing