How to alter index.less file based on config option toggle


#1

I have a theme and I would like to alter my files included in my index.less based on whether someone checked a checkbox within the settings or not.

So far I’ve got

#settings.coffee

module.exports =
    config:
        dynamicUI:
            type: 'object'
            properties:
                toggleDinamicUI:
                    title: 'Toggle Dynamic UI Colour'
                    description: 'UI will change colours based on syntax chosen'
                    type: 'boolean'
                    default: false

    activate: (state) ->
        atom.themes.onDidChangeActiveThemes ->
            Config = require './config'
            Config.apply()

config.coffee

	toggleDinamicUI = (boolean) ->
		if boolean
			# add import to file
		else
			# remove imports from file

	atom.config.onDidChange 'genesis-ui.dynamicUI.toggleDinamicUI', ->
		toggleDinamicUI(atom.config.get('genesis-ui.dynamicUI.toggleDinamicUI'))

	toggleDinamicUI(atom.config.get('genesis-ui.dynamicUI.toggleDinamicUI'))

#2

Doing what you’re describing either isn’t possible or is a much, much harder way than it needs to be. See my post in a recent topic for more information.


#3

Well my issue is that I can’t just simply add hard coded less selectors styles I need to alter variables based on config selection. So I must either somehow get vars from the less file and alter them or swap loaded files by asking user to reopen there editor.

Or I write to file…

but I figured it would be easier to just swap index.less files onload of atom. But I don’t know how.