Is it true that SASS is unable to compile variables within the filter: dropshadow() function?

I have integrated a SASS compiler into my Node.js environment for my React project (https://www.npmjs.com/package/sass). I am reusing SCSS files from another project stored in my CMS, which compiles SCSS as well.

However, I encountered an error when attempting to compile SCSS with the line:

filter: drop-shadow( $b $c $d rgba($color, $a));

The specific error message is:

SassError: Undefined variable.
   ╷
93 │   filter: drop-shadow( $b $c $d rgba($color, $a));

Despite having defined the variable, it seems that my SASS compiler may not support this type of variable usage. Can anyone suggest a workaround or adjustment that I can make?

This is my complete code snippet:

@mixin svg-shadow($size: 'top', $color: $night) {
  @if $size == 'top' {
      $a: 0.12; // alpha
      $b: 0px; // horizontal
      $c: 5px; // vertical
      $d: 2px; // blur
  }
  @else if $size == 'bottom' {
      $a: 0.05;
      $b: 0px;
      $c: -2px;
      $d: 2px;
  }
  @else {
      $a: 0.12;
      $b: 0px;
      $c: 5px;
      $d: 2px;
  }
   
  filter: drop-shadow( $b $c $d rgba($color, $a));
}

Answer №1

This scenario showcases the distinction between local scope and mixin level scope. By defining it within the blocks of @if or @else, the value is not being recognized.

To resolve this issue, simply move it to the mixin level.

Here is a suggested solution:

@mixin svg-shadow($size: 'top', $color: $night) {
  // DEFINE YOUR VARIABLES AT MIXIN LEVEL HERE
  // ASSIGN INITIAL VALUES BASED ON YOUR NEEDS
  $a: 0; // alpha
  $b: 0px; // horizontal
  $c: 0px; // vertical
  $d: 0px; // blur

  @if $size == 'top' {
    $a: 0.12;
    $b: 0px;
    $c: 5px;
    $d: 2px;
  }
  @else if $size == 'bottom' {
    $a: 0.05;
    $b: 0px;
    $c: -2px;
    $d: 2px;
  }
  @else {
    $a: 0.12;
    $b: 0px;
    $c: 5px;
    $d: 2px;
  }
   
  filter: drop-shadow($b $c $d rgba($color, $a));
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

perform a search query in mongoose with sorting

Having an issue with a mongo request: models.user.findOne( {}, { sort: { date_register: -1 } }, function(err, result) { console.log(err); } This error is showing up: { [MongoError: Error: Unsupported pro ...

Implementing CSS loading using Webpack

My attempt to incorporate the bootstrap css file into my app using Webpack (v4.5) by following the guidelines on the official website (https://getbootstrap.com/docs/4.0/getting-started/webpack/) is resulting in an error message while running webpack. ERRO ...

The Call was successfully completed despite receiving a TwilioException with the message "31002: Connection Declined"

Every time I make an outgoing call using Twilio, I receive a "TwilioException {message: "31002: Connection Declined"}. However, the call successfully goes through to my phone and I am able to answer it and hear the default message. Despite this, I still ...

Ways to split images and text in list items using CSS

Can the text be formatted in a specific location on the page, separate from the image and heading? This is the HTML code I am currently using: <div class="tab-pane container fade" id="environmental"> <div class="row"> <div class="c ...

Exploring the Aurelia package within the Visual Studio 2015 Community edition

In my package.json file, I have a postinstall rule set up like this: "postinstall": "aurelia bundle --force" When I run npm install from the command line in the project directory, no errors are displayed. However, when the project is loaded in Visual Stu ...

There was an unexpected error: The module "@angular-devkit/build-angular" could not be located

After entering the terminal commands ng server or ng serve, I encountered the following problem: An unexpected error occured: Module "@angular-devkit/build-angular" could not be located ...

Difficulty Implementing 'js-cookie' Library in NPM: Challenge with Managing Cookies

Encountering an issue with the js-cookie library while working on my Node.js application. I'm utilizing it to handle cookies, particularly setting a cookie called 'gameData' with the value 'value'. However, when attempting to retri ...

The fixed perspectives showcased on ever-changing pathways

Can someone explain why the image file in my classroom.ejs is not displaying when I use this configuration? app.configure(function() { //app.use('/room1',express.static(__dirname+'/public')); app.use(express.static(__dirname+&a ...

HTML5 Adaptive Button Arrangement

I'm working on making my buttons adaptive to screen orientation changes on mobile devices. My goal is to ensure that the website remains user-friendly regardless of how it's being accessed. I know how to adjust button size using CSS in scripts, b ...

Preventing background image repetition in Internet Explorer

I'm having an issue that seems simple but I can't figure out what's wrong. The background image repeats perfectly in non-IE browsers, but not in IE8. For reference, the site is located at: #wrapper { max-width:100%; min-width:1000 ...

Issue with Node.js Post method request: {"statusCode":404,"error":"Not Found","message":"Resource cannot be located"}

I recently started working with Node.js and found a helpful tutorial on the following page. However, I encountered an issue when trying to use the POST method instead of the GET methods, resulting in the following error: https://github.com/srinivastamada ...

Troubleshooting: Issue with reloading in MERN setup on Heroku

I successfully deployed my MERN stack application on Heroku using the following code: import express from "express"; import path from "path"; const app = express(); const port = process.env.PORT || 5000; app.get("/health-check&qu ...

Tips for concealing all items except the currently selected branch when clicking on a menu drop-down

I am seeking a solution to open only one node at a time on click, and remove the 'is-active' class from other items. Currently, there is excessive space taken up after opening multiple menu items. I want to ensure that only one node is open at a ...

Unable to get windw.location.href to function properly on local server

Having trouble with window.location.href not working for me :/ Everything is running on a localhost using "xampp" //javascript function 1 function onLogin() { window.location = "http://localhost:4000/deletetable"; console.log("running..."); con ...

Having Trouble Saving Nested JSON Array in MongoDB with Mongoose

Within Postman, I currently have JSON data structured like this: { "hostname": [ { "item": [ { "system": "10l313", "severity": "2" }, { ...

What is the reason behind Chrome's fullscreen mode turning the background black?

I created a webpage with full-screen functionality and made sure to use the correct CSS properties to ensure that my gradient background covers the entire screen perfectly. However, I encountered an issue when clicking the full-screen button in Chrome - th ...

Margin in Bootstrap Panel Not Set to 0 as Needed

My bootstrap panel's margins are set to 0, but it doesn't seem to actually be 0. In the image attached, the margin shows as "-", which I assume means 0. However, when I highlight it, I see a large block of orange. Does this indicate that the marg ...

Guide to setting up a nodejs server for automating tasks with cron jobs on a fixed schedule

I am in need of developing a nodejs "server" that will not serve any assets or content, but rather will be responsible for running scheduled tasks to retrieve data from one database and update another database. The schedule of these tasks should be customi ...

Dropdown selection menu reverts to default styling following ajax response

My form allows users to select their country, which then dynamically changes the dropdown menu to display states or provinces based on the selected country. The issue arises when the dropdown menu loses its CSS styling after an ajax script is called to upd ...

Delegating events with .on('click') and using the CSS negation selector :not()

Struggling to implement event delegation for a dynamically added or removed class? I need to create an event for elements that are clicked, but without a specific class. Here's the code I have so far, but it doesn't seem to be working. Could it b ...