(Gareth, pls excuse my jumping in. Add to or correct what I write.)
Arend,
In the framework, using classes is typically a two stage process:
1) Creating a class somewhere in a Less file.
2) Applying it to an Adapt content structure.
Create a class somewhere in a Less file.
- You can use pure CSS or Less; however, be sure to use a .less extension and keep your file in one of the Less folders in the framework. Grunt will look in these to compile the styles.
- You can create your own Less file or add your class to one that already exists. The separate files are purely for organization; they are processed into a single CSS file. If you want to modify the Less of a component, it is recommended that you copy the Less file into the Vanilla theme's Less folder and modify it there. If the files are named the same, the theme's file will override any similarly named styles that exist in the component's Less. (You get to make modifications while preserving the original styles.)
- Vanilla has gathered some commonly used values into four files dedicated to variables: fonts.less, paddings.less, colors.less, and generic.less. I recommend that you keep these dedicated to variables that you want to use elsewhere in your styles (but that an organizational thing, not technical restriction). You can start another file of variables if it suits you, or throw some into generic.less. Heads-up: there are two fonts.less files on two separate levels. One is intended for variables and one is intended for styles (once again, not a technical restriction).
Apply it to an Adapt content structure.
- By content structure I mean contentObject, article, block, or component. (It's possible that an extension could use a class, but I can't think of an example right now.) Each of these has a "_classes" field. Using this "_classes" attribute is often the easiest way to customize individual instances of components or articles. If you want to apply a style change to all instances of a component throughout your course, it is often more efficient to modify directly the component's Less file.
- Do not include the dot/class selector when using "_classes". Simply list one or more classes separated with a space like this:
"_classes": "blue-bkgd narrow_border"
- The classes whose names you add to the "_classes" property must be defined somewhere in a Less file. While Less will allow you to use variables and mixins, "_classes" is no place for them.
- In most cases, the classes you enter in "_classes" will be applied to the structure's root div. It is worth taking the time to examine this the first time you use this technique. It can help you understand what is necessary to target child divs or why other classes may interfere with yours.
Arend, my apologies if I told you something you already know in this long response. It sounds like your plans might warrant a new Less file or two to organize your classes (maybe backgrounds.less or images.less).
This technique of styling was difficult for me to envision when I was first reading about it. The lightbulb came on when I engaged the process. And now it's become pretty easy, especially as my Less skills have improved. Come back with more questions if it's tough to get started.
Hope something in this helps.
Chuck