ionic-framework icon indicating copy to clipboard operation
ionic-framework copied to clipboard

Use sufix or prefix for main classes in ionic.css

Open sarath2 opened this issue 13 years ago • 13 comments

First thank for your great library.

eg: .io-modal{} instead of .modal{}

beocz I used bootstrap for large screens. ionic replace bootstrap features.

Otherwise it work nicely.

sarath2 avatar Nov 26 '13 07:11 sarath2

Hey @sarath2 I'm not sure I agree with this one. Largely because we are only targeting hybrid apps, so using Bootstrap with this doesn't seem like a great idea, and I don't want to make using the framework more difficult for the general case, only to make it a bit more friendly to bootstrap in a few cases.

Let me know if you have any other thoughts about this. For now, I am going to close this because it's something we talked about previously but decided we didn't like, especially if this is the only framework you are going to use for your app.

mlynch avatar Nov 26 '13 14:11 mlynch

Also disagree here for reasons similar to those mentioned in #333. I don't see how prefixing CSS classes would make the library more difficult for the general case. Another I'll add is that I don't want to be locked into one UI library for my app.

ewinslow avatar Feb 07 '14 22:02 ewinslow

Since we decided to prefix directives, doesn't it makes sense to do the same for class names?

ewinslow avatar Feb 11 '14 17:02 ewinslow

Funnily enough, we just talked about this! :-)

[11:35 AM] Andy Joslin: should we prefix our css classes too?
        just thought about that
        one person already had a conflict they posted about on the forums
[11:40 AM] Adam Bradley: The way i see it, for css we ARE the framework they're using. Like bootstrap doesn't prefix their class with .bs-panel, they just use .panel
[11:40 AM] Andy Joslin: yeah good point
[11:40 AM] Adam Bradley: if they conflict its on them
[11:40 AM] Andy Joslin: yeah
[11:41 AM] Adam Bradley: and of all our classes, if we prefixed four characters, ion-, to every class it'd add a lot to our file size

Prefixing CSS isn't commonly done for css frameworks, and I think for good reason.

ajoslin avatar Feb 11 '14 17:02 ajoslin

I'm opposed to prefixing the class names because I think it looks dirty and it's just more to type.

That being said, if we expose most of the stuff through directives, then the class names underneath aren't as important.

I still vote no on it though.

On Tue, Feb 11, 2014 at 11:09 AM, Andy Joslin [email protected]:

We just talked about this! haha :-)

[11:35 AM] Andy Joslin: should we prefix our css classes too? just thought about that one person already had a conflict they posted about on the forums [11:38 AM] Adam Bradley: meh [11:40 AM] Adam Bradley: the way i see it, for css we ARE the framework they're using. Like bootstrap doesn't prefix their class with .bs-panel, they just use .panel [11:40 AM] Andy Joslin: yeah good point [11:40 AM] Adam Bradley: if they conflict its on them [11:40 AM] Andy Joslin: yeah and it's annoying to do anyway more annoying than the directives [11:41 AM] Adam Bradley: and of all our classes, if we prefixed four characters, ion-, to every class it'd add a lot to our file size [11:41 AM] Andy Joslin: haha true

— Reply to this email directly or view it on GitHubhttps://github.com/driftyco/ionic/issues/222#issuecomment-34776465 .

mlynch avatar Feb 11 '14 17:02 mlynch

Not interested in beating a dead horse so I'll leave my thoughts here and then let you guys do what you like with the framework. I just hope you'll reconsider as you did with directives. That's actually the main thing that confuses me here. What did you find compelling about the argument for prefixing directives that doesn't also apply here?

the way i see it, for css we ARE the framework they're using.

Except we're not. I mean, right? That's why they are having a conflict. Because ionic ISN'T the (only) framework they're using. This is a reality we can accept or ignore. I'd prefer to just accept it early and move on to building an awesome mobile UI framework.

Prefixing CSS isn't commonly done for css frameworks, and I think for good reason.

I agree that most CSS frameworks do this. Which is why conflicts are such a problem. Prefixing classes could be a(nother) positive differentiator for Ionic. Like "tired of constantly running into CSS conflicts when trying to mix and match other frameworks? Ionic plays well with your existing CSS".

As a counter-example: consider jquery-ui which prefixes everything with "ui-". This is very nice because you can pretty much drop any of their widgets it anywhere and be sure that the styles aren't bleeding over into the rest of your app.

Like bootstrap doesn't prefix their class with .bs-panel, they just use .panel

And bootstrap is a bad example to follow in this regard, precisely for the conflicts reason above. Your panel might mean something different than their panel. That's why you prefix -- to reduce conflicts and ambiguity, and to improve maintainability.

I think it looks dirty and it's just more to type

A small price to pay for the clear conflict problem. Besides, your code will be read 100x more that it will be written. Better to optimize for readability and long-term maintenance.

if we expose most of the stuff through directives, then the class names underneath aren't as important.

I would 100% agree with this if we had shadow-DOM today and the CSS wasn't global. But it is global still so namespacing still becomes a necessary evil.

it'd add a lot to our file size

I appreciate the performance-conscious reasoning, but gzip pretty much eliminates this problem, no?

As more UI frameworks come on the scene this problem will only get worse. Ionic is a fantastic and beautiful and feature-full framework, but I guarantee these conflicts will lose us clients.

Ok, that's all. You don't have to hear from me any more on this!

ewinslow avatar Feb 11 '14 18:02 ewinslow

FYI, we just faced the problem today. We are assembling a series of components under an ionic app, and some of these components are already built using bootstrap. And we are having conflict, like the definition of .modal. Evan is right, and the burden of having a prefix is out-beaten by a better integration story.

priand avatar Mar 18 '15 22:03 priand

:) thanks for the vote of confidence. Doubtful we will see the issue fixed though.

Hopefully this problem will just quietly go away as folks move over to shadow Dom. (I.e. angular 2)

ewinslow avatar Mar 18 '15 22:03 ewinslow

Evan

http://ongoo.cz/kerb

19.03.2015, 01:29, "Evan Winslow" [email protected]::) thanks for the vote of confidence. Doubtful we will see the issue fixed though.

Hopefully this problem will just quietly go away as folks move over to shadow Dom. (I.e. angular 2)

—Reply to this email directly or .

Fayozjon avatar Mar 24 '15 23:03 Fayozjon

Philippe

http://medgorodok.org.ua/strategii_foreks

19.03.2015, 01:25, "Philippe Riand" [email protected]:FYI, we just faced the problem today. We are assembling a series of components under an ionic app, and some of these components are already built using bootstrap. And we are having conflict, like the definition of .modal. Evan is right, and the burden of having a prefix is out-beaten by a better integration story.

—Reply to this email directly or .

Fayozjon avatar Mar 24 '15 23:03 Fayozjon

A similar discussion thread in Twitter Bootstrap suggests the _variables.scss file to implement an additional variable such as $prefix. When it is left blank, SASS will generate the clean CSS class names exactly as they are now. When $prefix has a value, SASS will generate prefixed class names. That way, it doesn't affect existing user base, while different teams can select different prefixes to avoid collisions with the UI frameworks that they are currently using. The best of both worlds.

yyl000000 avatar Oct 05 '15 18:10 yyl000000

Having the same problem when trying to mix clarity with ionic, just saying

yelhouti avatar Sep 14 '17 06:09 yelhouti

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

ionitron-bot[bot] avatar Sep 02 '18 03:09 ionitron-bot[bot]