Los temas y los componentes de tema son cada vez más potentes y los desarrolladores son cada vez más ambiciosos. Para facilitar las cosas a los desarrolladores, los temas ahora pueden dividir su SCSS en varios archivos.
Al crear un nuevo tema con el theme CLI, o al compartir un tema en github, simplemente crea una nueva carpeta llamada scss. Llénala con tus archivos .scss, siguiendo cualquier estructura de carpetas, y todos los archivos estarán disponibles para que los importes en las secciones comunes / de escritorio / móvil de SCSS de tu tema.
Por ejemplo, si quieres tener una variable común disponible tanto para el SCSS móvil como para el de escritorio, podrías hacer algo como esto:
scss/my-folder/variables.scss
$favourite-color = red;
desktop/desktop.scss
@import "my-folder/variables";
body {
background-color: $favourite-color;
}
mobile/mobile.scss
@import "my-folder/variables";
body {
color: $favourite-color;
}
Esta característica se añadió en v2.3.0.beta8, así que no utilices estas características todavía si necesitas mantener la compatibilidad con versiones anteriores de Discourse. Puedes usar el minimum_discourse_version parameter of about.json para asegurar que tu componente no se use en una versión anterior.
Este documento está controlado por versiones: sugiere cambios en github.
When converted to a stand-alone theme the background colour will be green, but when used as a component within another theme it doesn’t change the background colour at all.
The theme setup has default file structure and I added scss/test.scss Then I state @import "test";
On the console (using discourse_theme watch) I get: ✘ Error in common scss: Error: File to import not found or unreadable: test. on line 1 of common.scss
Just declared one variable (btw there’s a typo on the first code block above, declared with equals: $favourite-color = red;)
But just solved it. I set the minimum version in about.json as v2.3.0.beta8 and when I remove that, it works just fine. Never used that before, so not sure what’s wrong with the declaration.
Interesting! If you add the minimum version again, does it consistently break? If so, would you mind zipping up the broken theme and sharing it here? (or PMing it to me)