Skip to content

Functions ​

File Information ​

  • Path: app/assets/scss/abstracts/_functions.scss
  • Purpose: SCSS functions for calculations and color manipulations
  • Type: Abstract (no CSS output)
  • Status: Placeholder (currently contains commented examples)

Overview ​

The functions file is reserved for SCSS functions that perform calculations or manipulate values. Currently, this file contains commented example functions that can be implemented as needed.

Available Functions ​

Currently, no functions are active. The file contains commented examples that can be uncommented and used:

Example Functions (Commented) ​

calculate-rem($pixels) ​

Converts pixels to rem units.

Example:

scss
// @function calculate-rem($pixels) {
//   @return ($pixels / 16) * 1rem;
// }

Usage (if uncommented):

scss
.font-size {
  font-size: calculate-rem(16px); // Returns 1rem
}

lighten-color($color, $percentage) ​

Lightens a color by a specified percentage.

Example:

scss
// @function lighten-color($color, $percentage) {
//   @return mix(white, $color, $percentage);
// }

Usage (if uncommented):

scss
.light-background {
  background-color: lighten-color($blue-color-500, 20%);
}

darken-color($color, $percentage) ​

Darkens a color by a specified percentage.

Example:

scss
// @function darken-color($color, $percentage) {
//   @return mix(black, $color, $percentage);
// }

Usage (if uncommented):

scss
.dark-text {
  color: darken-color($blue-color-500, 10%);
}

When to Use Functions ​

Functions are useful for:

  • Calculations: Converting units, calculating dimensions
  • Color Manipulation: Lightening, darkening, or adjusting colors dynamically
  • Value Transformations: Converting or transforming values based on input

Current Status ​

The functions file is currently a placeholder. The project primarily uses:

  • Variables for static values (colors, spacing, etc.)
  • Mixins for reusable patterns
  • Direct calculations in component styles when needed

Future Considerations ​

If functions are needed in the future, consider:

  1. Unit conversion functions - Converting between px, rem, em
  2. Color manipulation functions - Dynamic color adjustments
  3. Spacing calculations - Calculating responsive spacing
  4. Z-index management - Managing z-index layers
  • Variables - Static values that functions might manipulate
  • Mixins - Reusable patterns (alternative to functions for some use cases)