-
Notifications
You must be signed in to change notification settings - Fork 24.8k
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
Add a unique identifier to a component's style #54869
Comments
@JoostK |
pseudo code snippet: <nzx-print-v
#nzxPrintV
[enablePreview]="true"
printTitle="HUAWEI Mate 60 Pro">
<div nzxPrintHeader>
<button nz-button nzType="primary" (click)="nzxPrintV.print()">
print
</button>
</div>
<div nzxPrintContent [identifierStr]="'.mate-pro-header'">
<nzx-good-evaluate-pdf-v></nzx-good-evaluate-pdf-v>
<!-- `nzx-good-evaluate-pdf-v` is the template component designated for printing.
'.mate-pro-header' refers to the style class defined within the component's CSS.
Eventually, component 'nzx-good-evaluate-pdf-v' will be placed within an iframe.
However, I need to extract the styles from the current document and insert them into the iframe's header.
The challenge arises from the multitude of other styles present in the current document, making it inconvenient to readily identify and isolate the styles generated by this particular component.
Consequently, I've resorted to using style classes written directly within the component, but this approach is prone to naming conflicts. -->
</div>
</nzx-print-v> |
I (sort of) see. You might have some success with ShadowDOM encapsulation, as then the styles would be placed within the shadow root. That might come with problems of its own or not be sufficient in terms of which styles you need to clone. That said, this is quite a niche problem and I don't think the framework will be of any help here. |
Indeed, I'm not inclined towards using Shadow DOM, as typically there's a shared common stylesheet across the global scope for component libraries. It's true that this poses minimal impact when everything operates under a single document, but complications arise when dealing with multiple documents or attempting to locate component style sheets, where efficiently querying for specific component styles becomes inconvenient. |
Which @angular/* package(s) are relevant/related to the feature request?
compiler
Description
Now the component's style will generate a style tag that will be inserted into the html header. When I render the component into the iframe, I find that I can't easily filter out the component's style
Proposed solution
Alternatives considered
none
The text was updated successfully, but these errors were encountered: