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

CSS selector discussion #9

Closed
afshin opened this issue Dec 4, 2019 · 29 comments · Fixed by #20
Closed

CSS selector discussion #9

afshin opened this issue Dec 4, 2019 · 29 comments · Fixed by #20
Labels
question Further information is requested

Comments

@afshin
Copy link
Member

afshin commented Dec 4, 2019

Should all of the legacy p-* CSS selectors be renamed to lm-*?

  • In the interest of clarity (and purity), my intuition is "yes"
  • In the interest of lower churn and a smaller amount of of pain imposed on current consumers of these APIs, "no" seems better.
@afshin afshin added the question Further information is requested label Dec 4, 2019
@jasongrout
Copy link
Contributor

I think this should be a change for Lumino 2.0.

@afshin
Copy link
Member Author

afshin commented Dec 4, 2019

So you think it should be a "yes" ... eventually? Do you think there's room for just leaving them as is or do you consider it too much of an inconsistency in nomenclature to keep the p-* classes?

@jasongrout
Copy link
Contributor

I think the community around Lumino is just starting, and it's more valuable in the long term to have lm- prefixes.

So my intuition is "yes, at the earliest opportunity, which is 2.0".

@jasongrout
Copy link
Contributor

In fact, I think if that is our decision, we should add lm- classes right now, and deprecate p- classes even before 2.0.

@afshin
Copy link
Member Author

afshin commented Dec 4, 2019

In fact, I think if that is our decision, we should add lm- classes right now, and deprecate p- classes even before 2.0.

This is a good idea.

@vidartf
Copy link
Member

vidartf commented Dec 4, 2019

deprecate p- classes even before 2.0.

I'm not sure what you mean here. The way I read semver, you cannot remove anything (whether deprecated or not) in a minor release.

nevermind, my mind read things to me incorrectly

@afshin
Copy link
Member Author

afshin commented Dec 4, 2019

We won't remove it. We'll add a note that the selector is deprecated, but it will continue to work until 2.0 and the lm-* will work as well.

@afshin
Copy link
Member Author

afshin commented Dec 7, 2019

Hm.

I am not sure we can support the legacy deprecation because when we are checking for p-mod-foo in the TS code, do we now need to check for either p-mod-foo and also lm-mod-foo?

Edit: Perhaps we can. I'm still exploring this in: #20

@afshin
Copy link
Member Author

afshin commented Dec 8, 2019

Okay, so the crux of the question is encapsulated in this example CSS:

/* <DEPRECATED> */
.p-TabBar-tab.p-mod-hidden,
/* </DEPRECATED> */
.lm-TabBar-tab.lm-mod-hidden {
  display: none !important;
}

The .p-mod-hidden inside the deprecated class should never naturally arise once we switch to using lm-mod-hidden, however a consumer may have written custom CSS that targets something with a p-mod-hidden class on it. This is a problem that cannot be solved in pure CSS. So the question that arises is: should we add p-mod-hidden in addition to lm-mod-hidden in the TS logic? This doesn't feel correct to me.

Actually, wouldn't every class need to be added in the TS code? This also doesn't seem like a great answer.

@jasongrout
Copy link
Contributor

In other words, are you asking if it should be as follows while it is deprecated?

/* <DEPRECATED> */
.p-TabBar-tab.p-mod-hidden,
.lm-TabBar-tab.p-mod-hidden,
.p-TabBar-tab.lm-mod-hidden,
/* </DEPRECATED> */
.lm-TabBar-tab.lm-mod-hidden {
  display: none !important;
}

@jasongrout
Copy link
Contributor

So the question that arises is: should we add p-mod-hidden in addition to lm-mod-hidden in the TS logic?

Or are you asking if, in Lumino code, we need to add p-mod-hidden as well as lm-mod-hidden?

I think the answer is yes, we need to add it while it is deprecated.

@afshin
Copy link
Member Author

afshin commented Dec 10, 2019

The trouble is that it's not just the mod classes we need to add. We need to add every class. So we'd have to make sure each widget is both lm-Widget and p-Widget.

@jasongrout
Copy link
Contributor

So we'd have to make sure each widget is both lm-Widget and p-Widget.

Correct, of course. What is the problem with that? That we have a combinatorial explosion of class name combinations?

I think it is fine if we officially support in the documentation all lm-, and all p- classes (but deprecated), but not a mix of both.

@jasongrout
Copy link
Contributor

I was imagining we would not be deleting any code adding classes. Just everywhere we added a p- class, we'd add another line adding the corresponding lm- class.

(Too bad lm looks like Im in many fonts...)

@afshin
Copy link
Member Author

afshin commented Dec 11, 2019

Hm, this actually means that we should not need to add the CSS styles like above at all. We only care about clients who target .p-*, but since our TS will always add .lm-* the stylesheets we ship should not need to have both classes, only the TS should.

@afshin
Copy link
Member Author

afshin commented Dec 11, 2019

This is a good time to bring up the data-lm-suppress-shortcuts again. I actually wonder if this should not be a semantic name like data-orientation instead of a namespaced one like data-lm-dragscroll. The latter is namespaced because it's an implementation detail whereas the former has a generic name because it's public API. So I propose data-suppress-shortcuts, which if it exists means block them. Its value would be immaterial.

@jasongrout
Copy link
Contributor

Hm, this actually means that we should not need to add the CSS styles like above at all. We only care about clients who target .p-*, but since our TS will always add .lm-* the stylesheets we ship should not need to have both classes, only the TS should.

Good point. +1.

@jasongrout
Copy link
Contributor

jasongrout commented Dec 11, 2019

This is a good time to bring up the data-lm-suppress-shortcuts again. I actually wonder if this should not be a semantic name like data-orientation instead of a namespaced one like data-lm-dragscroll. The latter is namespaced because it's an implementation detail whereas the former has a generic name because it's public API. So I propose data-suppress-shortcuts, which if it exists means block them. Its value would be immaterial.

I would say the distinction is kind of the opposite. data-orientation is only applied to elements Lumino controls, so we don't have to namespace it since it is an implementation detail. data-lm-dragscroll is applied to elements we do not control, so we have to namespace it so it doesn't conflict with whatever else the user might put on it. For that reason, I think data-lm-supress-shortcuts is better, since it would be a class the user is applying to elements under their control, not under Lumino's control.

@afshin
Copy link
Member Author

afshin commented Dec 11, 2019

@jasongrout That's a good point about the data attributes. I agree.

@vidartf
Copy link
Member

vidartf commented Dec 13, 2019

Hm, this actually means that we should not need to add the CSS styles like above at all. We only care about clients who target .p-, but since our TS will always add .lm- the stylesheets we ship should not need to have both classes, only the TS should.

Unless of course someone is adding the p- classes to their nodes to reuse the existing CSS. Then the question becomes if such use is considered part of the semver guarantee.

@afshin
Copy link
Member Author

afshin commented Dec 13, 2019

Unless of course someone is adding the p- classes to their nodes to reuse the existing CSS. Then the question becomes if such use is considered part of the semver guarantee.

You are correct. But I think if we are deprecating these styles and the use you describe is so edge, I would propose not duplicating the styles in this transition phase. Do you agree with that or do you think it's important to copy the class as well?

@vidartf
Copy link
Member

vidartf commented Dec 13, 2019

and the use you describe is so edge

Well, I know of one project that are relying on them: https://github.com/jupyterlab/jupyterlab/search?q=p-mod-hidden&unscoped_q=p-mod-hidden

@afshin
Copy link
Member Author

afshin commented Dec 13, 2019

one project ... jupyterlab/jupyterlab ...

Never heard of it.

@jasongrout
Copy link
Contributor

@vidartf
Copy link
Member

vidartf commented Dec 14, 2019

For completeness, these are the "adding classes to DOM" examples I could find in jupyterlab:

https://github.com/jupyterlab/jupyterlab/blob/8d773bf136876315e1ff6b0483c5d15307d3cce7/packages/extensionmanager/src/widget.tsx#L700

https://github.com/jupyterlab/jupyterlab/blob/8d773bf136876315e1ff6b0483c5d15307d3cce7/packages/outputarea/src/widget.ts#L473

https://github.com/jupyterlab/jupyterlab/blob/8d773bf136876315e1ff6b0483c5d15307d3cce7/packages/statusbar/src/defaults/lineCol.tsx#L103

https://github.com/jupyterlab/jupyterlab/blob/8d773bf136876315e1ff6b0483c5d15307d3cce7/packages/ui-components/src/icon/tabbarsvg.ts#L135

Now, we can say that these are wrong and should not be supported. I'm just saying we should make such a decision with open eyes, and that thinking of cases such as these as "unlikely edge cases" would be a false premise to make the decision on. I would also argue that as part of #3 we should add a section "Styles/CSS" where we document (among other things) what is covered by semver, and what is not.

@afshin
Copy link
Member Author

afshin commented Dec 14, 2019 via email

@jasongrout
Copy link
Contributor

Going through these too:

https://github.com/jupyterlab/jupyterlab/blob/8d773bf136876315e1ff6b0483c5d15307d3cce7/packages/extensionmanager/src/widget.tsx#L700

We should be using jp-mod-focused here, since it is jlab's component, not phosphor's component.

https://github.com/jupyterlab/jupyterlab/blob/8d773bf136876315e1ff6b0483c5d15307d3cce7/packages/outputarea/src/widget.ts#L473

This is about removing classes, not adding classes. It looks like we just set the class to what we think is the original class. Kind of a kludge, but I think we're accepting there liability for updating that to lm-

https://github.com/jupyterlab/jupyterlab/blob/8d773bf136876315e1ff6b0483c5d15307d3cce7/packages/statusbar/src/defaults/lineCol.tsx#L103

This is not a phosphor class, so it wouldn't be impacted by the switch to lm-. Besides, it is our class, so it should be jp- anyway.

https://github.com/jupyterlab/jupyterlab/blob/8d773bf136876315e1ff6b0483c5d15307d3cce7/packages/ui-components/src/icon/tabbarsvg.ts#L135

Here we are overriding a phosphor class, so again, I think it's reasonable to ask us to change the css to lm- on a major update.

@vidartf
Copy link
Member

vidartf commented Dec 16, 2019

I think it's reasonable to ask us to change the css to lm- on a major update.

I thought we were discussing "shortcuts" in deprecation for a non-major release, i.e. by not duplicating all CSS rules.

@jasongrout
Copy link
Contributor

I thought we were discussing "shortcuts" in deprecation for a non-major release, i.e. by not duplicating all CSS rules.

I thought we were discussing duplicating all CSS rules for deprecation now (minor release), and eventually changing over in a major release.

My point is that I think, after looking at how JLab is using (or abusing) phoshpor/lumino css classes, there is still not a critical blocker for eventually changing the css to be prefixed lm-.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 17, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants