Sign In Register

How can we help you today?

Start a new topic
Answered

CSS in dynamic-forms

Are there any best practises I should know about when using CSS in dynamic-forms?  I have had success adding a <style> tag to the top of the GSML. But I am worried it could cause problem if I have several snippets on a screen and each snippet has its own style block.   Also, I find myself copy/pasting the same style code into multiple snippets.  I would prefer to link to a single stylesheet with something like <link rel="stylesheet" type="text/css" href="mystyle.css">


But I don't know how I could control the contents of such a stylesheet



Best Answer

Hi James,


I wouldn't call it a best practice but what I have done in the past is have one single snippet that contains the css and include that snippet in the screens. Do you think that would suit your needs?


Kind regards,

 - Steve


Answer

Hi James,


I wouldn't call it a best practice but what I have done in the past is have one single snippet that contains the css and include that snippet in the screens. Do you think that would suit your needs?


Kind regards,

 - Steve

This is a useful idea. It is better than copy/pasting the same text into each snippet. 


Is there any way to conditionally include a snippet only if it hasn't been included before?  Can a snippet somehow set a flag when it is included and have that flag be checked with a {{#if}} in the spots that conditionally include it?  My concern is I want my snippets to be self contained. I want to be able to view an individual snippet like "player_details" on its own when designing and debugging it. So I want the "player_detail" snippet to include the css snippet so player_details can run on its own. Similarly "players_virtual_goodls" will also need to same CSS and should be able to run on its own. But then when "player_master" includes both "player_detail" and "player_virtual_goolds" I don't want those snippets to include duplicate copies of the CSS. 


I guess "player_master" could pass a param something like  "player_detail?embedded=true" and I could check that flag before including the css snippet. But ideally the css snippet itself would set the flag. Or ideally there would just be a simple way to include a snippet only once. Or some other approach to proving style sheets that doesn't make them a snippet. 

Hi James,


Unfortunately I don't know of a way to conditionally include a snippet based on whether it has been included already or not. In terms of your requirements I think your method of including a snippet with a passed parameter might be the best approach for the moment.


Kind regards,

 - Steve

Thanks for your help Steve.  Safe to close.

Login to post a comment