I have a constant called CLASSES:
const CLASSES = {
root: "root",
vertical: "master",
horizontal: "alternate",
}
I have a variable gridType which has a value of either a string of vertical or horizontal.
render() {
const { gridType } = this; // equals either a string of 'vertica'l or horizontal
return html `<div class="${CLASSES.root}"</div>`;
}
How would I add gridType class to the returned html? I can't do <div class="${CLASSES.root} ${CLASSES.gridType}"</div> since gridType is not a value on CLASSES
You can use bracket-notation:
<div class="${CLASSES.root} ${CLASSES[gridType]}"</div>