White Label Module
Do you need specific styling per user or per organization in 1 app? Then this is the module for you.
You can load any white label styling on the fly. For example you can change the primary color of the whole application with just 1 nanoflow action.
Credits to Jason Teunissen from Lowcode NZ Limited for helping me with an example implementation of css variables.
Load any white label styling on the fly, you can for example change the primary color whenever you want.
- Overwrite any sass variables whenever you want
- Functionality for easily setting up a custom brand style, allowing you to load a brand based on your own logic.
- Easy to adjust to support any variables you want
- Loads Atlas colors by default
!IF YOU HAVE DONE CHANGES TO THE custom-variables.scss FILE YOU SHOULD MAKE A BACKUP FIRST SO YOU CAN MERGE IT CORRECTLY AFTER INSTALLATION!
- Download the module from the appstore
- In the project settings in the theme tab make sure the module is loaded last
- Open the project folder and then copy the content from the overwrite folder (should be in themesource/whitelabel/web/overwrite) and paste it inside the root folder of your project, this will overwrite some atlas core files and the custom-variables.scss file. Do note that any changes you have done to these files will be lost. SEE IMAGE 2
- Add the SNIP_BrandOverview to an admin page where you can manage and test all the different brands you wish to support.
Once the installation has been successfully set up you will have to choose when to load a brand that you have setup. You will have to create some logic yourself to fire the ACT_Brand_SetVariables nanoflow with a Brand object at the desired moment. An example: You have a multi-tenant application and one a user logs in you want that user to see the styling of the company that he is a part of. In this case it is wise to add a 1 - 1 association between the Brand and Company entity. Now once the user logs in you can add a dataview to the layout of the first page that the user will arrive at. This dataview will run a nanoflow which will retrieve the Brand from the currentuser's Company and then runs the ACT_Brand_SetVariables nanoflow. This will then load the desired styles for the user.
By default this module manages the standard Brand colors a few Font variables and the top and sidebar backgrounds but you can add as many more variables as you wish. This can be especially useful if you have your own design system. You can add more variables by doing the following steps:
- Add the sass variable to the custom-variables.scss file (if it doesnt exist already). The value of the sass variable should be a css variable (for example $brand-secondary: var(--brand-secondary);)
- Navigate to the css-variables.scss file (themesource/whitelabel/web) and add the new css variable to the root (the --brand-secondary). Here you can set the value to a default color you wish to use when a brand has not been loaded yet.
- Add a new string value to the Brand entity for the newly added variable.
You might encounter styling errors in your application after loading the module. Something like Error: $color: var(--brand-primary) is not a color. This is because we are not using css variables instead of sass variables and there are some sass functions that are not supported for css variables. The main 3 that function that Mendix uses that will give this error are the lighten, darken and mix functions. These can either be replaced with a color-mix function or with a new css variable that you will have to load inside the ACT_Brand_SetVariables nanoflow (you can see examples in the overwrite folder from installation step 3).
You can read more about the difference between sass & css variables here.
Please feel free to raise any issues, share suggestions, or request new features on the GitHub repository: