If Statements and Mixins Best Practices in Sass

Learn best practices for using Sass if statements and mixins to enhance SMT Theme Skin Manager performance.

·2 min read·View Oracle Docs

If you are developing Sass for the SMT Theme Skin Manager (STMT), it's critical to understand how certain practices can impact the user experience. Specifically, when Sass variables are exposed to SMT, they can alter how the application compiles and renders changes.

How to Format Sass for SMT

To maximize the efficiency of your Sart development for SMT, it’s important to expose variables carefully. When an SMT administrator modifies an exposed variable, the changes go through two compilations. The first, taking place on the frontend, can be done within 2 seconds, while a second compilation occurs on the backend after 5 seconds of user inactivity. This structure emphasizes the need for optimal Sass structure to minimize downtime.

Common Pitfalls

There are specific practices in Sass development that should be avoided when exposing variables to SMT, which include:

  • Sass variables that utilize user-defined function calls.
  • Conditional statements using if constructions.
  • Mixing multiple variables within mixins.

Avoiding these practices ensures that all variables remain accessible during the frontend compilation process.

Avoid User-Defined Function Calls

Using user-defined function calls in Sass can complicate the access of exposed variables. For instance, if you define a variable like this:

scss
$sc-color-secondary: myfunc($sc-primary-color) /*editable(…)*/

If $sc-primary-color is marked as editable, when the SMT administrator updates the primary color, the changes will compile quickly on the frontend. Unfortunately, myfunc($sc-primary-color) can only be evaluated in the backend, resulting in delayed previews.

If Statements and Mixins: Best Practices

Another critical pitfall occurs when using if expressions with exposed Sass variables. For example:

scss
@if $sc-color-secondary == $12345 { background-color: $sc-color-primary; }
@else { background-color: $56789;}

The above code snippet illustrates a significant issue: the condition in the else statement is unknown to the frontend. This situation considerably complicates the user experience, as the resultant preview is contingent upon backend compilation and often takes longer to reflect changes.

Passing values or grouping variables within mixins can lead to similar issues; these variables are also resolved during backend compilation, extending preview delays. Overall, awareness and adherence to these best practices for Sass development will significantly enhance your SMT Theme Skin Manager user experience.

Frequently Asked Questions (4)

Does using user-defined functions in Sass variables affect SMT frontend performance?
Yes, using user-defined functions can delay previews because such functions require backend compilation, which does not happen instantly.
What happens if an SMT administrator modifies an exposed Sass variable?
Changes to an exposed Sass variable undergo frontend compilation within 2 seconds, followed by backend compilation after 5 seconds of inactivity.
Why should if statements be avoided in exposed Sass variables for SMT?
If statements can lead to complications because their conditions are unknown to the frontend, causing delays and dependency on backend compilation for preview updates.
How do mixins affect the preview delay in SMT theme skin management?
Variables within mixins are resolved during backend compilation, extending preview delays just like with if statements.
Source: If Statements and Mixins Oracle NetSuite Help Center. This article was generated from official Oracle documentation and enriched with additional context and best practices.

Was this article helpful?

More in Administration

View all Administration articles →