개념/React

SCSS) ..... utils.scss

kiseno 2025. 4. 14. 21:28
728x90
반응형
SMALL
$red : #fa5252;
$orange: #fd7e14;
$yellow : #fcc419;
$green : #40c057;
$blue: #339af0;
$indigo: #5c7cfa;
$violet: #7950f2;

@mixin square($size){
  $calculated : 32px * $size;
  width : $calculated;
  height: $calculated;
}

1. **Color Variables**: The first section declares variables for a range of colors, assigning hex values to each. These variables (`$red`, `$orange`, `$yellow`, `$green`, `$blue`, `$indigo`, `$violet`) store specific color codes, making it easier to manage and reuse these colors throughout your Sass stylesheets. Using variables for colors like this enhances consistency in your design and simplifies changes or theme adjustments since you only need to update the color in one place.

2. **`square` Mixin**: This mixin, named `square`, is designed to create square elements with dynamic sizes. It accepts one parameter, `$size`, which it uses to calculate the width and height of a square. The mixin multiplies a base value (`32px`) by the `$size` parameter to determine the dimensions of the square. This allows for flexible design elements that can be easily adjusted and reused across different parts of a website or application.

   - The `$calculated` variable inside the mixin holds the result of `32px * $size`, which is then applied as both the width and height of the square. This ensures that the resulting element is always square, regardless of the `$size` value passed.
   - By using this mixin, you can quickly generate squares of different sizes by passing in different `$size` values. For example, `@include square(2);` would create a 64px by 64px square, while `@include square(3);` would result in a 96px by 96px square.

728x90
반응형
LIST