elyra icon indicating copy to clipboard operation
elyra copied to clipboard

Use jupyterlab util for adding class names in React elements

Open karlaspuldaro opened this issue 4 years ago • 7 comments

As suggested by @ajbozarth in a review discussion on #241 , it would be helpful to have an app util for adding class names to JSX elements across our packages

karlaspuldaro avatar Apr 03 '20 17:04 karlaspuldaro

As mentioned in the comment Jupyterlab has a util for this that we may either reuse or emulate https://github.com/ajbozarth/jupyterlab/blob/cd465c8436dad1abb7ed1a399b21b98d2bb9c19a/packages/ui-components/src/utils.ts#L31

ajbozarth avatar Apr 03 '20 17:04 ajbozarth

We can most likely just use the jupyterlab util directly and don't need to create our own

ajbozarth avatar Apr 06 '20 18:04 ajbozarth

@ajbozarth for my own curiosity, what is the value of creating a whole new module or importing just for concatenating some strings?

vabarbosa avatar Jun 23 '20 14:06 vabarbosa

The value is simply cleaner and more readable code. As for the importing, it would require adding a new import to the files that use it, but all our packages already depend on the package that contains it (since that package handles icons as well), so it would not add any dependancies.

ajbozarth avatar Jun 23 '20 16:06 ajbozarth

oh ok, but i am not sure doing something like this:

className=classes('name-one', NAME_TWO)

is more readable or easier to understand than simply:

className=`name-one ${NAME_TWO}`

vabarbosa avatar Jun 23 '20 17:06 vabarbosa

In that case it wouldn't be, the idea would be that we inline more of these, which would be cleaner since we would no longer have string interpolation making line wrapping odd.

ajbozarth avatar Jun 23 '20 18:06 ajbozarth

not sure what you mean by making line wrapping odd (i would expect that to apply whether inline of not). in any case, if you feel it necessary (and that much of an improvement) i'm good.

vabarbosa avatar Jun 25 '20 14:06 vabarbosa