أصبحت السمات ومكونات السمات أكثر قوة بشكل مطرد، ويصبح المطورون أكثر طموحًا. لتسهيل الأمور على المطورين، يمكن للسمات الآن تقسيم ملفات SCSS الخاصة بها إلى ملفات متعددة.
عند إنشاء سمة جديدة باستخدام أداة سطر الأوامر للسمات (theme CLI)، أو مشاركة سمة على github، ما عليك سوى إنشاء مجلد جديد يسمى scss. املأه بملفات .scss الخاصة بك، باتباع أي هيكل مجلد، وستكون جميع الملفات متاحة لك للاستيراد في أقسام SCSS المشتركة / لسطح المكتب / للجوال في السمة الخاصة بك.
على سبيل المثال، إذا كنت تريد أن يكون متغير مشترك متاحًا لكل من SCSS للجوال وسطح المكتب، يمكنك القيام بشيء كهذا:
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;
}
تمت إضافة هذه الميزة في الإصدار v2.3.0.beta8، لذا لا تستخدم هذه الميزات بعد إذا كنت بحاجة إلى الحفاظ على التوافق مع الإصدارات الأقدم من Discourse. يمكنك استخدام معلمة minimum_discourse_version في about.json لضمان عدم استخدام المكون الخاص بك على إصدار سابق.
يتم التحكم في إصدار هذه الوثيقة - اقترح تغييرات على 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)