Forum Discussion

Alan Trafford's avatar
Alan Trafford
Brass Contributor
Dec 05, 2017

SPFx Extension: Dependency on css class names

Hi

I've created a SharePoint Framework Extension that does the following:

  1. Adds a print stylesheet (@media print)
    • Hides elements.
    • Applies a watermark.
  2. Adds a custom footer to the bottom of the document (JavaScript injection), not the bottom of the page (application customizer).

Both the above are dependent on CSS classes within the rendered page:

 

Hidden when printed:

root_db29caec, nav_995e56d3, #SuiteNavPlaceHolder, commentsWrapper_3f0ee14c, banner_995e56d3, feedback_674c19bf

 

Footer appended to:

CanvasZone--read

 

Should I be concerned about these class names changing? If yes, what are the alternatives?

 

Thanks.

  • I would be very concerned personally as the code can break at any time

    I would follow the application customizer approach as that is the only one that guaranties that your code will always have the required dependencies on the page.

     

    Getting started example 

    • Alan Trafford's avatar
      Alan Trafford
      Brass Contributor

      Hi Joel Rodrigues

       

      I'm familiar with the example, in fact, that's the starting point for my extension. I've modelled the footer in both the application customizer (placeholder) way and the JavaScript injection way. I'm hoping my company will accept the application customizer way.

       

      That still leaves me with the print stylesheet task. As there is no inbuilt way to achieve this, the only solution I can currently think of is to reference the CSS classes. I don't like this solution as it is brittle.

Resources