primeflex icon indicating copy to clipboard operation
primeflex copied to clipboard

Why removing p- prefix?

Open FadiNouh1 opened this issue 5 years ago • 16 comments

I think it was wrong idea about removing the p- prefix from the classes of the primeflex. This require big changes in many projects which are using the library after that update

FadiNouh1 avatar Aug 24 '21 20:08 FadiNouh1

@FadiNouh1 We have written a migration tool you can use which will convert your whole project.

See: https://github.com/primefaces/primefaces/tree/master/primefaces-cli

melloware avatar Aug 25 '21 11:08 melloware

@melloware When are you going to update the primeng showcase? There it is still with "p-", this can generate confusion, because the user installs the dependency in the project, will use the example and it doesn't work.

elielcena avatar Aug 28 '21 13:08 elielcena

@elielcena I don't work for Primetek I am just an open source committer on the PrimeFaces JSF project.

melloware avatar Aug 28 '21 13:08 melloware

All themes are still using p-grid too https://github.com/primefaces/primeng/search?l=CSS&q=p-grid

I think it is a really bad idea

At this point it is not possible to upgrade, as PrimeNG is not compatible with PrimeFlex

https://github.com/primefaces/primeng/issues/10469

AmazingDreams avatar Sep 01 '21 10:09 AmazingDreams

The problem with the lack of a namespace is that... there is no namespace. SASS doesn't support importing classes without leaking them to global scope, and the libary doesn't provide SASS placeholders that would allow to use custom class names. This makes the library useless for the use in scopes you don't own - a module in your company or a widget on somebody else's website. It would be a good idea to prefix all class names with optional variable.

bisubus avatar Sep 03 '21 17:09 bisubus

This could indeed be a major problem.

I know that many customers are using bootstrap for its grid system, but primeng for some of its components. I'm not sure, is there a fixed dependency from primeng to primeflex for some layouting? But if there is, this will totally block the upgrade to the new primeflex, because its class names would now clash with many bootstrap class names.

Schmaga avatar Sep 20 '21 09:09 Schmaga

All themes are still using p-grid too https://github.com/primefaces/primeng/search?l=CSS&q=p-grid

I think it is a really bad idea

At this point it is not possible to upgrade, as PrimeNG is not compatible with PrimeFlex

primefaces/primeng#10469

I'm using PrimeFlex 3.0 within my PrimeNG 12 project without any issues. Prime flex is just a css utility library which can be used with any kind of front-end framework. The only thing you'll have to do is to figure out how to convert the old naming conventions to the new ones which isn't difficult at all with help of its excellent docs.

GeertHuls avatar Sep 22 '21 21:09 GeertHuls

We have a PrimeFaces CLI that will convert your entire project for you if you look at the PrimeFaces repo. The Readme shows you how to use it.

See: https://github.com/primefaces/primefaces/tree/master/primefaces-cli

melloware avatar Sep 22 '21 21:09 melloware

I totally understand the migration issue but PrimeFlex had to be rewritten as a fully featured CSS utility library so that we can create PrimeBlocks. With V2 it was impossible. While doing the rewrite, we removed p- prefix because it became too cumbersome and unreadable adding p-* to every css class as by nature there are many classes on an element e.g.

<div class="bg-blue-500 text-white p-3 m-2 sm:w-6 lg:col-12 absolute top-0">

It would be hard to read and confusing with;

<div class="p-bg-blue-500 p-text-white p-p-3 p-m-2 p-sm-w-6 p-lg-col-12 p-absolute p-top-0">

Also PrimeFlex is not a must for Prime libraries, we use it for PrimeBlocks and for demos (will be updated to v3 as well). Components do not utilize it (except view which will be decoupled.) Prime libraries can be used with any CSS utility library, this could be PrimeFlex v2 and v3 as well, you don't have to migrate if v2 works for you.

cagataycivici avatar Oct 11 '21 08:10 cagataycivici

@cagataycivici Why was the issue closed? It is a serious one and still relevant. PrimeBlocks is only one of possible implications. Other libraries like Primevue share this approach and still use p- for own classes, they aren't linked to Primeflex itself but if all Prime libraries tend to get rid of prefixes, we're in trouble.

It's not a good idea to revert the change after the release, this doesn't mean that it can't be fixed. It would be a dead simple addition to add $pfPrefix variable that is empty by default that would benefit anyone who's interested in more than quick style prototyping with prebuilt CSS.

<div class="p-bg-blue-500 p-text-white p-p-3 p-m-2 p-sm-w-6 p-lg-col-12 p-absolute p-top-0">

The readability is improved in any framework by making the string dynamic:

<div className={pfClasses('bg-blue-500 text-white p-3 m-2 sm:w-6 lg:col-12 absolute top-0')}>

Currently I had to ditch v3 from my projects because it pollutes global scope and interferes with other unprefixed classes on a page which cannot be controlled. A really short prefix like p- is not ideal but no prefix is a no-go.

bisubus avatar Oct 11 '21 10:10 bisubus

I agree with @bisubus . It is a seriously unfounded thing to say (as @cagataycivici did above) that "we are removing p- because look how silly it gets when you use lots of classes in combination":

<div class="p-bg-blue-500 p-text-white p-p-3 p-m-2 p-sm-w-6 p-lg-col-12 p-absolute p-top-0">

So what? These are utility classes, exactly the reason why there may be a lot, and at least they can (could) be isolated from the global styling namespace. I personally use 3 character prefixes for my project classes, for exactly the same reason. I'd rather have my own issues with readability - and how long my lines are in my editor - these are not a package's concern!

andrewlorenz avatar Jan 04 '22 17:01 andrewlorenz

All themes are still using p-grid too https://github.com/primefaces/primeng/search?l=CSS&q=p-grid I think it is a really bad idea At this point it is not possible to upgrade, as PrimeNG is not compatible with PrimeFlex primefaces/primeng#10469

I'm using PrimeFlex 3.0 within my PrimeNG 12 project without any issues. Prime flex is just a css utility library which can be used with any kind of front-end framework. The only thing you'll have to do is to figure out how to convert the old naming conventions to the new ones which isn't difficult at all with help of its excellent docs.

I guess you haven't used many of the PrimeNG components. Internally PrimeNG components (the template html of components) still use old classes. So you cannot remove primeflex 2 from your project completely.

You can see a demo here what it causes https://github.com/primefaces/primeng/issues/10469

Since this is just css it can be fixed by having both Primeflex v2 and primeflex v3 in your project. This doesn't cause any issues as long as you are not using any other css-framework like bootstrap.

Jagan-P avatar Jan 10 '22 09:01 Jagan-P

All themes are still using p-grid too https://github.com/primefaces/primeng/search?l=CSS&q=p-grid I think it is a really bad idea At this point it is not possible to upgrade, as PrimeNG is not compatible with PrimeFlex primefaces/primeng#10469

I'm using PrimeFlex 3.0 within my PrimeNG 12 project without any issues. Prime flex is just a css utility library which can be used with any kind of front-end framework. The only thing you'll have to do is to figure out how to convert the old naming conventions to the new ones which isn't difficult at all with help of its excellent docs.

I guess you haven't used many of the PrimeNG components. Internally PrimeNG components (the template html of components) still use old classes. So you cannot remove primeflex 2 from your project completely.

You can see a demo here what it causes https://github.com/primefaces/primeng/issues/10469

Since this is just css it can be fixed by having both Primeflex v2 and primeflex v3 in your project. This doesn't cause any issues as long as you are using any other css-framework like bootstrap.

Actually I am building an app with PrimeNG at the moment, so far I haven't encountered any issues yet. Then again, at the moment I've only got a handful of components so that might be the reason. :)

Looking at template code in your stackblitz example: https://stackblitz.com/edit/primeng-dataview-demo-f6fbie?file=src%2Fapp%2Fapp.component.html

TBH I don't see the issue there either. The only thing is noticed is the styleClass="p-mb-2 p-mb-md-0" on the dropdown in the header template on line 7. But that code is under your control as a content projection template so you could easily change it to styleClass="mb-2 md:mb-0", I guess.

Perhaps I'm missing something. Can you give an example of old classes being used in the p-dataview component?

GeertHuls avatar Jan 12 '22 22:01 GeertHuls

All themes are still using p-grid too https://github.com/primefaces/primeng/search?l=CSS&q=p-grid I think it is a really bad idea At this point it is not possible to upgrade, as PrimeNG is not compatible with PrimeFlex primefaces/primeng#10469

I'm using PrimeFlex 3.0 within my PrimeNG 12 project without any issues. Prime flex is just a css utility library which can be used with any kind of front-end framework. The only thing you'll have to do is to figure out how to convert the old naming conventions to the new ones which isn't difficult at all with help of its excellent docs.

I guess you haven't used many of the PrimeNG components. Internally PrimeNG components (the template html of components) still use old classes. So you cannot remove primeflex 2 from your project completely. You can see a demo here what it causes https://github.com/primefaces/primeng/issues/10469 Since this is just css it can be fixed by having both Primeflex v2 and primeflex v3 in your project. This doesn't cause any issues as long as you are using any other css-framework like bootstrap.

Actually I am building an app with PrimeNG at the moment, so far I haven't encountered any issues yet. Then again, at the moment I've only got a handful of components so that might be the reason. :)

Looking at template code in your stackblitz example: https://stackblitz.com/edit/primeng-dataview-demo-f6fbie?file=src%2Fapp%2Fapp.component.html

TBH I don't see the issue there either. The only thing is noticed is the styleClass="p-mb-2 p-mb-md-0" on the dropdown in the header template on line 7. But that code is under your control as a content projection template so you could easily change it to styleClass="mb-2 md:mb-0", I guess.

Perhaps I'm missing something. Can you give an example of old classes being used in the p-dataview component?

Upon going through the source code I observed that primeng is made compatible with primeflex v2 and v3 from the major release v12.

So the issue I reported 5 months ago is fixed 10469

Not sure about themes though which @AmazingDreams has mentioned.

Jagan-P avatar Jan 13 '22 03:01 Jagan-P

If this is such a trivial change and has no great inconvenience, why is the showcase and examples still using the p prefix?

siriussoftware avatar Jul 20 '22 23:07 siriussoftware

I overcame this issue by adding $prefix: 'p-' !default; // override primeflex variable before @import primeflex.scss

swotiendang avatar Oct 26 '23 02:10 swotiendang