Skip to content
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

chore(ApplicationLauncher): Convert examples to typescript #6834

Merged

Conversation

jpuzz0
Copy link
Contributor

@jpuzz0 jpuzz0 commented Jan 19, 2022

What: Closes #6797

@@ -0,0 +1,4 @@
declare module '*.svg' {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reason for this is mentioned here: #6791 (comment)

@patternfly-build
Copy link
Contributor

patternfly-build commented Jan 19, 2022

Copy link
Contributor

@wise-king-sullyman wise-king-sullyman left a comment

Choose a reason for hiding this comment

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

Neither of these are major blockers for me, just topics I'd like to discuss before this PR gets merged:

Comment on lines 19 to 20
const onToggle = React.useCallback((isOpen: boolean) => setIsOpen(isOpen), []);
const onSelect = React.useCallback((_event: any) => setIsOpen(prevIsOpen => !prevIsOpen), []);
Copy link
Contributor

Choose a reason for hiding this comment

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

I know that we discussed the optimization of examples as we work through these conversions, and the conclusion I remember being reached was that it was up to each of us to do as we see fit.

I debate though whether the usage of useCallback in situations like this is actually optimization or just excessive pre-optimization that doesn't actually improve performance, and may in fact decrease performance. I tend to agree with the arguments made by Kent C. Dodds in this article of his.

That being said my mind isn't hard set on that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a great article for sure and a good discussion to have. I think in this case, you're right in that they're not needed and even though there's a possibility of these functions being used for side-effects that would require referential equality checks, probably best to not make that assumption so I'll update.

);
}
}
```ts file="./ApplicationLauncherMenu.tsx"
Copy link
Contributor

Choose a reason for hiding this comment

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

I see you've got some notable differences here between example names and component/file names. I can't remember if the team came to an alignment on this topic at the last meeting, unfortunately, but if not I feel like we should. I know that @thatblindgeye and I proposed a standard of component name + example name that matches 1:1, and I recall some debate on whether the name of the component was necessary but that's all I can recall at the moment.

I do understand (especially with the context of this example name) why you made the decisions you did though, and if we want to just standardize on something looser like component name + something that uniquely identifies the example I don't think I'd be opposed to that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh I see, I didn't realize we had said exactly the name of the example, versus something that resembles it (this leads to fewer characters in most cases), which is what I was aiming for. I'm fine with re-opening the discussion.

Copy link
Contributor

Choose a reason for hiding this comment

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

I know that was our proposal, but I can't recall if there was a consensus reached on it and regretfully I didn't take notes. I do think some examples (like the one for the file I pointed out) have names that just don't work well for this purpose.

@thatblindgeye do you have any thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think componentName[exampleName] can work most of the time, but falling back to componentName[shortenedExampleName] would be good to have especially when it comes to something like "Basic with menu appended to document body". I think it's really just going to have to be a "use your best judgment" thing on which one to use and which best describes the example itself (in this instance, for example, I would say ApplicationLauncherDocumentBody or similar might be a more fitting name).

We could tweak the example name to something like "Menu appended to document body", but that would still result in a rather lengthy file/example name of ApplicationLauncherMenuAppendedToDocumentBody (give or take a few characters if this is shortened slightly further). This is definitely an example we knew would come up to show just how lengthy these names can get.

If we'd want the verbiage written down anywhere to actually reference I can write something a little more formal up as well, or help work on that.

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree that shortening the example part of the name would be good to keep the overall length of the filename down. What do you think of abbreviating the component name where applicable as well (AppLaunch or AppLauncher in this case), or dropping the component name section altogether because it isn't directly user displayed and can be inferred from the file structure?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had suggested the same as I thought the name of the component was redundant, but I don't recall there being much of a reception to that when discussed in standup a week ago.

</ApplicationLauncherItem>
];

export const ApplicationLauncherMenu: React.FunctionComponent = () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Based on the conversation regarding naming, I'm wondering if this name should instead revert back to ApplicationLauncherDocumentBody instead of ApplicationLauncherMenu, or if that does stray into "too long" territory.

Copy link
Contributor

@wise-king-sullyman wise-king-sullyman left a comment

Choose a reason for hiding this comment

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

At the risk of being excessively pedantic: aligned right, aligned top, and some of the with examples don't match the name of the examples 1:1 despite their lengths not being excessive if they did IMO.

These are just small nits though and "too long" is, of course, subjective so none of these are blockers for me. I just didn't feel right not pointing it out when I noticed it, since it doesn't quite match up with my understanding of the consensus we reached on this topic earlier today.

@nicolethoen nicolethoen merged commit 5749133 into patternfly:main Jan 21, 2022
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.

Application launcher: Convert examples to typescript
6 participants