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

Support private classes #294

Closed
idoros opened this issue Mar 19, 2018 · 5 comments
Closed

Support private classes #294

idoros opened this issue Mar 19, 2018 · 5 comments
Assignees
Labels
core Processing and transforming logic discussion Ongoing conversation feature New syntax feature or behavior future Intended for future roadmap

Comments

@idoros
Copy link
Collaborator

idoros commented Mar 19, 2018

Currently any CSS class declared in a Stylable stylesheet is considered a pseudo-element public API. In some cases a stylesheet author could keep "template" classes by importing them and mixin them in, or use the future -st-filter: deny(*) to block any CSS overrides, but it would be much more helpful to introduce an -st-access: private directive that will simply hide the class from external overrides.

/* gallery.st.css */
.navBtn {}
.internalBox {
    -st-access: private;
}
/* page.st.css */
:import {
    -st-from: './gallery.st.css';
    -st-default: Gallery;
}

Gallery::navBtn {/* style the internal navBtn */}
Gallery::internalBox {/* error: unknown pseudo-element "::internalBox" */}

edit: possible values should be:

  • public (default)
  • private - cannot be accessed as a pseudo element or extended
  • protected - cannot be accessed as a pseudo element, but can be styled in the context of a root that directly extends the stylesheet (or extending a stylesheet that extends the original stylesheet).
@idoros idoros added feature New syntax feature or behavior future Intended for future roadmap discussion Ongoing conversation labels Mar 19, 2018
@brucelawson
Copy link
Contributor

OK, putting on my W3C mailing list hat: what's the use-case?

@idoros
Copy link
Collaborator Author

idoros commented Mar 19, 2018

Simply that Stylable exposes any CSS class as a pseudo-element by default, and there is no way to have simple CSS class that are not accessible from the outside.

@brucelawson
Copy link
Contributor

From a conversation with Ido on Slack (putting it here to remind me when I have another attack of the stupids):

why have a special thing that hides it, when -st-overrride: deny(*) would do the same thing?

idoros [6:12 PM]
denying access to override is not the same as hidding a class
denying overrides will not prevent access to any lower pseudo-elements

bruce [6:13 PM]
BINGO
now I understand the difference

@brucelawson
Copy link
Contributor

Interesting note from @tabatkins on design decisions for CSS that allows component authors to "lock down" styles, while allowing component users to override defaults w3c/csswg-drafts#2290 (comment)

@tomrav tomrav added the core Processing and transforming logic label May 29, 2018
@idoros idoros added the good first issue Good place to start contributing to Stylable label Jun 23, 2021
@idoros idoros removed the good first issue Good place to start contributing to Stylable label Jul 26, 2021
@tomrav tomrav changed the title private classes Support private classes Nov 1, 2021
@tomrav
Copy link
Collaborator

tomrav commented Feb 7, 2023

Closing in favor of #2604

@tomrav tomrav closed this as completed Feb 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Processing and transforming logic discussion Ongoing conversation feature New syntax feature or behavior future Intended for future roadmap
Projects
None yet
Development

No branches or pull requests

5 participants