question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
joaojmendescommented, Mar 25, 2022

@fabiofranzini for compatibility yes make sense for me.

1reaction
joaojmendescommented, Mar 25, 2022

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Apply, remove, or rename CSS class styles in Dreamweaver
In the Document window, right-click (Windows) or Control‑click (Macintosh) the selected text, and in the context menu, select CSS Styles and ...
Read more >
How to better control CSS class naming in SPFx - Stefan Bauer
It is just possible through different class names for elements on the page. ... Let us apply some style sheet definition and use...
Read more >
Set Image Class Names for Styling in CSS
One way to give an image a class name is to use the role attribute. You can set it on the image's mediaobject...
Read more >
Class
A class selector selects all elements with a matching class attribute. ... This demo shows how single-class selectors are different from combined ...
Read more >
Classes
Use classes to save styling information that applies to as many elements as you want across your site.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found