Remove the "isUniqueControlInPage" from AdaptiveCardHost control by rebuild the way to apply AC CSS class names
See original GitHub issueCategory
[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)?
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (3 by maintainers)
Top GitHub Comments
@fabiofranzini for compatibility yes make sense for me.
@fabiofranzini I don’t know if someone is using the control or not…maybe is better to marked as obsolete