Skip to content
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

Remove the "isUniqueControlInPage" from AdaptiveCardHost control by rebuild the way to apply AC CSS class names #1154

Closed
fabiofranzini opened this issue Mar 15, 2022 · 5 comments · Fixed by #1205
Labels
status:fixed-next-drop Issue will be fixed in upcoming release.
Milestone

Comments

@fabiofranzini
Copy link
Collaborator

fabiofranzini commented Mar 15, 2022

Category

[x] Enhancement
[-] Bug
[-] Question

Version

Please specify what version of the library you are using: [3.6.0]

Expected

Last week I took part in the Adaptive Cards community call and showed the control to the attendees.
After this call I contacted the team behind Adaptive Cards, and they suggested some tips. One of these concerns the implementation of the style for the host control.

Currently a "static" CSS file and CSS variables are used to drive colors and other properties. Finally, a property of the react the control is used called "isUniqueControlInPage" to understand where to set the CSS variables, especially as regards the secondary Action menus.

I state that I was aware that the use of the "isUniqueControlInPage" property was not optimal, but now it was the only way to understand where to set the CSS variables.

Now the approach I have implemented is completely different.
I removed the static CSS file, the point where the CSS variables are generated and I use the Nano-CSS library to generate all the CSS classes I need at runtime, set the color values ​​(taken from the applied theme) and generate class names with a prefix formed from the Web Part instance id.

// ****
currentHostConfig.cssClassNamePrefix = `ach${Text.replaceAll(props.context.instanceId.trim(), "-", "")}`;
applyAdaptiveCardHostStyles(theme, currentHostConfig.cssClassNamePrefix);
// ****

In this way, each instance of Web Part that uses the AdaptiveCardHost control will have its own styles without interfering with other instances and solving the problem of having to set a property, "isUniqueControlInPage", which can hardly be inferred when using within the SharePoint pages.

In addition to this, I have added some Adaptive Cards classes as component export, so you don't need to install the "adaptivecards" library in the project that uses the control to access these classes.

I have already made the changes, if you approve this issue, I can already do the PR.

Only thing, at this point the control feature "isUniqueControlInPage" is no longer used and can be removed.
In this case, how do we behave? Can I remove it? Do we mark it as deprecated (and don't use it)?

/cc @joelfmrodrigues @AJIXuMuK @joaojmendes

@ghost
Copy link

ghost commented Mar 15, 2022

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.

@ghost ghost added the Needs: Triage 🔍 label Mar 15, 2022
@fabiofranzini
Copy link
Collaborator Author

Hi, anyone give me feedback on this? /cc @AJIXuMuK @joelfmrodrigues @joaojmendes 🙂

@joaojmendes
Copy link
Collaborator

@fabiofranzini I don't know if someone is using the control or not..maybe is better to marked as obsolete

@fabiofranzini
Copy link
Collaborator Author

@fabiofranzini I don't know if someone is using the control or not..maybe is better to marked as obsolete

Make sense for you to make it obsolete and not use it even if set?

@joaojmendes
Copy link
Collaborator

@fabiofranzini for compatibility yes make sense for me.

@AJIXuMuK AJIXuMuK added status:fixed-next-drop Issue will be fixed in upcoming release. and removed Needs: Triage 🔍 labels Apr 25, 2022
@AJIXuMuK AJIXuMuK added this to the 3.8.0 milestone Apr 25, 2022
@AJIXuMuK AJIXuMuK mentioned this issue May 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:fixed-next-drop Issue will be fixed in upcoming release.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants