SAP / fundamental-ngx

Fundamental Library for Angular is SAP Design System Angular component library
https://sap.github.io/fundamental-ngx
Apache License 2.0
271 stars 130 forks source link

POC: investigate pros/cons of switching from `ng-content` to `slot` #459

Closed droshev closed 2 years ago

droshev commented 5 years ago

Is this a bug, enhancement, or feature request?

feature request

Briefly describe your proposal.

Currently, when you have nested Angular custom elements, and the child element contains ng-content or content elements in its template, content projection/insertion points don't work. It works if it is used slot elements. More information can be found here: angular/angular/issues/24536

The idea is to explore the option of migrating from using ng-content to slot.

Which versions of Angular and Fundamental NGX are affected? (If this is a feature request, use current version.)

angular 7.2 fundamental-ngx - latest

droshev commented 5 years ago

@JKMarkowski is there a value in that ?

fkolar commented 5 years ago

as you already know you can use both in angular to project the content and I think the only added value as of now if you plan to use your angular component as custom elements. In such case your component is ready for it.

When we implemented a fiori3 shellbar as customer element so it can be used in both angularJS apps and as well as in angular we had to use slots inside angualr components there was no other way - but in here I am not sure..

stefanoScalzo commented 5 years ago

@droshev The thing is we would be using viewEncapsulation: shadowDom, the issue is that we currently have viewEncapsulation: none to allow the css from outer usage to affect it which would no longer be applicable. Having custom elements can be useful but only if we don't want that outer styles be applied to the component

fkolar commented 3 years ago

I would like to reopen this issue, considering new SAP strategy using WebComponents. It will give our components more reuse. We have already several use-cases to use our fundamentals components as web component, but @ContentChild/Children/ng-content will make it difficult to use.

We just introduced a process to convert NG to WC -> UI5, but components that relies on nested structure and make use of ContentChild/children/ng-content its impossible to use.

From one angular' issue:

@ContentChildren/ContentChild cannot be supported in Elements, because Angular has no awareness of what is being projected into a template when used outside of Angular.

droshev commented 3 years ago

@fkolar do you know how many components would be affected? And what should we use to replace them?