-
Notifications
You must be signed in to change notification settings - Fork 0
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
Style (CSS) Architecture #4
Comments
A copy style-related information transferred from #3: @kirlat wrote:
@irina060981 wrote:
@irina060981 wrote:
|
Technologies
Are there any other technologies beyond above that can be beneficial to us? Syntactic ComparisonEverything is in one line so that it will be easier to compare BEMStyle Definition: Scoped CSSStyle Definition: CSS ModulesStyle Definition: Examples are taken from this great article comparing Scoped CSS and CSS Modules in Vue.js: https://www.netguru.co/codestories/vue.js-scoped-styles-vs-css-modules |
Great information, @kirlat! :) |
BEMAdvantages
Disadvantages
Scoped CSSAdvantages
Disadvantages
CSS ModulesAdvantages
Disadvantages
That's all I was able to come up with. Is there anything else that is forgotten? Can anyone offer any corrections? |
@kirlat , if I understand correctly the the CSS modules technology - it operates only css classes? |
@irina060981, great questions! If I understand correctly, it's all pretty straight forward. Once we add
Vue adds a
So instead of If in definitions we inject an HTML code with "regular" class names, then we should use "regular' class names to style them. We can control what a component name can be and we can have several different For skins, I think, we can probably combine two class names together using a usual approach.
It will render as:
Then in a separate skin file we define This approach simple with CSS modules, but will be harder with scoped CSS because there we have to override a double selector such as What do you think? Will the above work for us? |
An approach above would require us to assign "regular" class names to component elements so that they be used in skin styles. That's more complexity, but as side advantage we can define what can be skinned and what can not (i.e. if it does not have a "regular" class, it cannot be skinned). This could be important if we allow third-parties to provide their own skins. This would allow us to divide HTML components into "private" and "public" in terms of skinning (of course this can be overcome with more specific selectors or Another approach is that we could tell Vue loader to generate class names without hash, so they will be constant, such as |
We have multi-part selectors in any case because we have
Also we won't be able to garantee the same styles always becase there are sites that applies styles directly to tags and could overide it with some combination of classes (that's why it is added ID selectors I think) |
Actually, class names are seem to be generated not by Vue, but by Webpack's CSS loader: https://vue-loader.vuejs.org/guide/css-modules.html#usage, https://github.com/webpack-contrib/css-loader. So we could make those names whatever we want them to be.
|
I think we should add: styles need to be able to be specific to target language (for example, we want to be able to optimize fonts for Arabic, etc.) |
Thanks for the comment, updated the Goals section. |
this is a very interesting discussion. Thank you both for your initiative and valuable contributions to it! I have a couple more questions:
|
Here are answers based on what I know so far:
I believe it was modeled in Vue.js after an HTML's draft of
CSS Modules is not part of any W3C standards. It is an independent framework-neutral initiative that has specs of its own: https://github.com/css-modules/css-modules. It is currently implemented by Webpack via a CSS loader (https://github.com/webpack-contrib/css-loader) and by React and Vue via Webpack. According to documentation, "A CSS Module is a CSS file in which all class names and animation names are scoped locally by default". Just that. And a way to import styles form other modules. My impression is it's more just a convenience tool than any new HTML spec.
I think neither. CSS Scoping Module Level 1 uses slotted items and Shadow DOM and seems to be much more ambitious venture than both Scoped CSS and CSS Modules (that's IMHO). |
ok thank you for this. While I really like the simplicity of the scoped attribute I am hesitate to go with something that is framework specific. so if the complexity is too much for the BEM solution, and it sounds like it is, my vote would be for CSS Modules if it provides what we need. Perhaps the best time to move to this for existing components would be when we implement the concept design (whenever we get it) and to apply it from the outset to any new components from this point on. What do you both think? |
BEM is simple, but really painful to maintain in large projects (IMHO) and impossible to enforce. CSS modules are similar to BEM by their naming schema except they're generated automatically. Looks like the same thing, but better. Plus, it has some additional features, if we would like to use them. @irina060981, what do you think? Any CSS schema described here can be combined with any other. It's not all or nothing approach. We can try a new schema on some small and unimportant component and see how well it will work. It it won't, we can try the other one or scrap it all together. No rush here. |
I think that we could use any approach but we should think about the following: One of the common problems for the free-distributed open-source tools is that they are hardly customizable and appliable in a real world to some out-side projects. According to our choices:
And the both 2. and 3. would need cascade of classes and ID identifiers and some long class names. So I think that we should think what developers would use our extension and would try to apply to there need. What way would they like and would be able to change styles. If to be honest, I don't know whom in IT community we are appealing with this great linguistic project. (It is really great I think. Because my several tries to easily find some inflection tables for testing show that it is not an easy task) P.S. Of course as a developer I would love to work with CSS Modules as it is unknown for me and would increase my skills :) |
Actually you're right here. I've checked the data I was able to find on that and it seems that selector performance is almost the same in any case: https://benfrain.com/css-performance-revisited-selectors-bloat-expensive-styles/ Don't know from where I had it in my head. I'll remove it from list of advantages. |
That's a very interesting topic Irina brought: what are our requirements in terms of complexity that defines barriers to entry for people who will use it or work on its development. We probably should separate persons who will contribute to developemet of the Alpheios "core" libraries and persons who will use it, but might adjustit to their needs (i.e. a company that would use an embedded lib might want to customize it or create a custom skin for it). Those two groups are probably different so we should consider them separately. @balmas, what do you think? |
Yes, this is a very good topic for discussion. And yes, I think we have to talk about 2 types of contributors: 1 - other developers who will work on the core Alpheios code We could further break down the 2nd category into 2a - people who will do cosmetic customization - e.g. skinning for branding For 1, based upon past experience I think we will not likely get people contributing to the core code unless they are professional developers who are able to manage complexity (and likely, paid to do it). So our priority there should be to make sure our code is clean and well documented and follows best practices (such as having unit tests, etc.) so that new developers coming on board have a a path to follow to understand it and add to it. And I think trying to reduce complexity is a best practice, but so is minimizing dependencies upon any specific framework and/or bundling system. For 2a, I would like it to be dead simple to skin the UI for things like colors, fonts, icons, etc. Ideally not requiring any knowledge other than CSS and HTML. For 2b, I would like it to manageable for a novice programmer to do. |
Moving the discussion from alpheios-project/webextension#135
|
I decided to move this from #3 to keep the latter manageable. I think architecture of styles is not directly related to the component architecture. Both topics can be voluminous. In order to keep issues clean and manageable it's probably better to keep discussion separate (please let me know if you do not agree).
Design Goals
Listed in order of importance:
a. Styles for one component should not interfere with styles of the other component or with styles of the page. Styles that are defined on a web page should not inadvertently change the look of Alpheios components, no matter how complex a web page is.
b. Styles need to be able to be specific to target language (for example, we want to be able to optimize fonts for Arabic, etc.)
c. Components should be skinnable. Third party or us should be able to create a skin to change visual appearance of Alpheios components.
d. Style files should have the smallest size possible.
Is there anything else I forgot to mention here? If we agree on the goals, we can discuss the best solution to achieve them.
The text was updated successfully, but these errors were encountered: