Runtime CSS

Forum to discuss the new web client version of Servoy.

Runtime CSS

Postby marco.rossi » Thu Jan 03, 2019 5:55 pm

Hi,
I would like to let the user be able to change the style of the solution.

An example could be to change the font color of the entire solution.

To do this I'm successfully used the instruction:
application.overrideStyle("CSS/black_font.css","CSS/blue_font.css")

The problem of following this way, is that I need to have infinite combinations of pre-compiled stylesheets.

Does exist a way to create a runtime stylesheet and to use the "application.overrideStyle" method to use it?

Best regards
Marco Rossi
Senior Analyst Developer
Freelance Consultant

IT Manager @Mantho
Webmaster @Sitoliquido
marco.rossi
 
Posts: 110
Joined: Sun Apr 12, 2015 9:33 pm

Re: Runtime CSS

Postby Joas » Fri Jan 04, 2019 12:24 pm

Take a look at:
Code: Select all
solutionModel.newStyle(name,content)

I haven't tried it myself, but it looks like it could be what you are looking for.
Joas de Haan
Yield Software Development
Need help on your project? yieldsd.com
User avatar
Joas
Site Admin
 
Posts: 842
Joined: Mon Mar 20, 2006 4:07 pm
Location: Leusden, NL

Re: Runtime CSS

Postby mboegem » Fri Jan 04, 2019 6:25 pm

Hi Marco,

this can be achieved to add a reference to the generated css file.
In my case I didn't want to expose the css files using a public location, so I read the css file from disk, Base64 encode the content and add that to your page like this:

Code: Select all
var _oTag = {
           tagName: "link",
           attrs : [{
            name: "rel",
            value: "stylesheet"
           },{
            name: "href",
            value: "data:text/css;base64," + _sBase64EncodedContent
           }]
          }
      
          plugins.ngclientutils.contributedTags.push(_oTag);


If you store the generated on a public location you can change the href value to valid url just as you would do building a normal webpage.

Hope this helps.
Marc Boegem
Solutiative / JBS Group, Partner
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance Developer

Image

Partner of Tower - The most powerful Git client for Mac and Windows
User avatar
mboegem
 
Posts: 1743
Joined: Sun Oct 14, 2007 1:34 pm
Location: Amsterdam

Re: Runtime CSS

Postby marco.rossi » Fri Jan 25, 2019 5:37 pm

Thank you Marc and Joas,
sorry if my answer comes in late but I got trouble with my forum user login.

Best regards
Marco Rossi
Senior Analyst Developer
Freelance Consultant

IT Manager @Mantho
Webmaster @Sitoliquido
marco.rossi
 
Posts: 110
Joined: Sun Apr 12, 2015 9:33 pm


Return to Servoy NGClient

Who is online

Users browsing this forum: No registered users and 9 guests

cron