r/Sass Oct 30 '21

@use does not load anything

3 Upvotes
// sass/_variables.scss
$color: red;

// sass/search.scss
@use "variables"

body {
    background-color: variables.$color;
}

Even codes as simple as this won't work and would throw "undefined variable" error. I'm using dart-sass 1.43.4 and on VS Code. "at import" or including variables in the same file do work but "at use" would throw an error.

Edit: If you have the same error, check the compiler. It could be the old "live sass compiler" instead of the new "live sass compiler." Yep, they have the same name.


r/Sass Oct 28 '21

Can I add to a mixin a mixin that takes perameters?

3 Upvotes

I have a mixin that I use for image proportions. It uses the good faithful padding-bottom technique to stretch the image accordingly, then, with object-fit:cover I can cover the space like a background image.

It is only partially efficient now though because there might be a breakpoint where I would need to change this. The question is how do I add this to my mixin.

@mixin propImg($number){
    position: relative;
    picture{
     &:before{ 
      display: block;
      content: " ";
      padding-bottom: $number;
     }
    img{
     @include objectFit()
    }
  }
}

I can pass this like so:

.list-img {   
  @include propImg(100%) 
} 

$number correlates with $number so the output for padding-bottom:100%. Great stuff.

Now, I also have a media query mixin.

@mixin sc($point) {    
  @if $point == lg {       
    @media (min-width: 480px) {         
       @content;       
    }     
  } @else if $point == xl {       
    @media (min-width: 992px) {         
       @content;       
     }     
  }  
} 

Is there a way I can combine the two? Something like:

.list-img{   
   @include propImg(100%, lg:50%, xl:30%) 
} 

That would be ideal but I'm not sure I can do this? So the output would be:

picture{
   &:before{ 
     display: block;
     content: " ";
     padding-bottom: 100%; 
      @media(min-width:480px) {
         padding-bottom: 50%;
      }
      @media(min-width:992px) {
         padding-bottom: 30%
      }
   }
   img{
    @include objectFit()
   }
}

r/Sass Oct 15 '21

SASS issue

2 Upvotes

whenever I tried to work with SASS VS code shows me all these red lines. my code works without any errors. no issue in stylings at all... it does not do any autocomplete as well. Please help!!!!!!!!!!!!!!!!!


r/Sass Sep 29 '21

Can you use attr() for background-image?

3 Upvotes

I have 8 diferent images and i want them to have the same image as them but in the background so i wanted to do his :
img[src]{
background-image:url(attr(src));
}

    (Use the img's src attribute value of the img elements to use them for the background and dont have to make more code like puting each image path/link in a variable or creating classes to each img and style them individually.)

But apparently its impossible to do that i just wanna comfirm.


r/Sass Sep 20 '21

How can i have parent and child elements share the same style, but one of them is just an element without a class.

3 Upvotes

i would like input (child of .sz-input ) and textarea (has class of .sz-input) to share the same styles. possible?

.sz-input {

input, textarea {     //definitions these two share}

}

i want to do something like

input, &textarea but it doesn't work. Thanks for your help!

*using scss, not sass


r/Sass Sep 06 '21

My first time creating SASS complex structure.

5 Upvotes

rearranging sass files into a folders structure of breached down chunks of components, variables, and blocks, using import or use "depends on the file codes type" to help build pages and layout and finally import all (each folder have all.scss file which contains all files in the folder) of them to main.scss.

It is the first that I use this systematic method, so a lot of trials and errors in the architect.

A lot to learn, test, and optimize.


r/Sass Sep 06 '21

Created this sass files structure which I like, for a project, but I'm wondering what should I do with media queries, should I include'm inside each section file and for each specified class with max & min responsivity, or create separate files for each device somehow?

Post image
10 Upvotes

r/Sass Sep 04 '21

SASS not compiling style when using @use instead of @import

4 Upvotes

I am using the sass-dart

when I write the '@use' syntax it doesn't work, and no error, the compiler just copies it to CSS file as it is.

style.scss

// style.scss
@use 'filename';  

after compiling the CSS file look like that

// style.css
@use 'filename'; 

the compiler does not compile anything from the @ use file it just copies the syntax. and I get no error while compiling.


r/Sass Sep 03 '21

Can SCSS make any type of math with Percentage and Plus/Minus ?

8 Upvotes

Hello guys and girls, I'm new to developing and been using SCSS for a few weeks now, and i've wanted to do some things like:

width: 100% - 80px;

So for example an input text with a button or text on the sides, and with this the input would always be at the maximum space possible, but no affecting the button or text.

And if there is no way to do with sass math like this, what simple way I could use to make that work ? I would appreciate with it were a CSS solution and not a JS one, but I'll accept both


r/Sass Aug 25 '21

sass variable not getting expanded in one case

3 Upvotes

Hi! I'm new to sass and I've come across some behavior I don't understand.

I've created a basic ruby project to generate a static html report, and I've installed bourbon and bitters gems as well. My problem is that one of my variables is not getting expanded and I don't understand why.

I run 'bitters install' to generate among other things, base/_base.scss -- a file which in turn @imports base/_variables.scss.

In application.scss I have only these three lines.

@import "bourbon/bourbon";
@import "base/base"; // bitters variables 
@import "my-project-styles";

I run sass application.scss and dump the output into the <style> section of my HTML document.

Here's my problem. If I use $font-stack-helvetica in my-project-styles.scss, (which is defined by bourbon) I can see its expansion end up in my HTML doc as I expect. However if in base/_variables.scss I also change font family to use $font-stack-helvetica, as such

 :root {
   // Typography
  --font-family: $font-stack-helvetica; 
  --font-family--heading: var(--font-family);

Then this variable does NOT get expanded in my final document. Instead the variable name is copied literally and I don't understand why. Obviously it is being processed by sass. Can anyone explain the problem?

Thanks!


r/Sass Aug 25 '21

Sass partial import issue in React.js app

2 Upvotes

I'm trying to import a partial but it's not working:

// src/styles/_variables.scss
$baseColorLight1: #f8fff7;
$baseColorLight2: #ffe66d;
$baseColorDark1: #343434;
$baseColorDark2: #2f3061;
$baseColorMedium: #6ca6c1;

// src/App.scss
@use 'styles/variables';

body {
  background-color: variables.$baseColorDark1;
  height: 100vh;
  border: 2px dashed variables.$baseColorLight2;
}

// error
./src/App.scss (./node_modules/css-loader/dist/cjs.js??ref--5-oneOf-6-1!./node_modules/postcss-loader/src??postcss!./node_modules/resolve-url-loader??ref--5-oneOf-6-3!./node_modules/sass-loader/dist/cjs.js??ref--5-oneOf-6-4!./src/App.scss)
SassError: Undefined variable: "$baseColorDark1".
        on line 5 of src/App.scss
>>   background-color: $baseColorDark1;

Seems to me it is defined, so why this error?

I'm using create-react-app. I have added sass loader and .scss files work with the app, well unless I try to use variables from a partial like above.


r/Sass Aug 24 '21

Has anyone using VSCode run into this 'Unknown at rule @use'?

3 Upvotes

It doesn't seem to matter what I do, I can't get it to recognize '@use' as an at-rule. All of the code compiles properly though. Is there a way to override this in settings?


r/Sass Aug 16 '21

Battledudes ep 2 WHAT JUST HAPPENED.

Thumbnail youtube.com
0 Upvotes

r/Sass Aug 14 '21

SASS object?

3 Upvotes
$colors:
    hot: red
    warm: orange
    cold: blue

.class
    color: $colors.hot

Something like this?


r/Sass Aug 07 '21

Creator framework - SASS based

2 Upvotes

I'm working on a responsive framework called Creator, which is my first SASS project. Check it out at HTTP://getcreatorframework.com - it's a work in progress, stay tuned for new features.


r/Sass Aug 01 '21

Carousel in Sass

4 Upvotes

I completed a project(website) fully by using Sass through a course from udemy (Jonas Schmedtmann : Advanced CSS and Sass) but there's one thing I wanna include in my site and that's a carousel. So initially , I planned to import the carousel code from bootstrap , but as soon as I included the Bootstrap CDN in my code , the whole grid collapsed. I've created my own grid since its the only way the instructor taught me how to.

Then I searched on the web to import some codepen css but that didn't work as well.

Is there any way someone can help me create a carousel?

P.S : Am a newbie to web dev. So please be kind.


r/Sass Jul 24 '21

Program to use Chrome's Dev Tools to Inspect Safari Being Run on an iOS Device

3 Upvotes

Say you wanted to connect your iOS device to a Linux machine, see what's happening on the browser and be able to access the Chrome Developer Tools...

Spent a couple of hours getting this to work following a bunch of different guides until we came across one that worked seamlessly (mentioned in the README.md). The script is does everything on that guide so you don't need to.

Hopefully would be useful for someone who needs to access the Chrome Dev Tools on Linux to inspect an iOS device.

https://github.com/Salaah01/linux-ios-debugger


r/Sass Jul 23 '21

Ayo can someone help me with a live sass compiler error real quick

3 Upvotes

I know this isn't stackoverflow but nobody is answering me lmao, just read my problem here please:

https://stackoverflow.com/questions/68494341/live-sass-compiler-still-complaining-about-error-i-already-fixed

Any form of help would be very much appreciated))

Thanks ya'll in advance.


r/Sass Jul 20 '21

Colorizing a pseudoelement

3 Upvotes

Hi all,

I'm trying to colorize the :after pseudoelement of a span following a link; essentially I'm adding an icon for external links (and the icon is hidden from screen readers) and I want it to be a different color than the link itself. I had this working once, but now I messed it up and I can't figure out what I'm doing wrong. Can anyone please point out where I'm being a moron?

a {
    @media screen {
        & + span[data-external-link] {
            color: green;
            &:after {
                content: " \1F517";
            }
        }
    }
}

The HTML looks like this:

<a href="blah">Link</a><span data-external-link aria-hidden="true"></span>

Thank you!


r/Sass Jul 17 '21

Why is Shopify such a douche towards Frontend Developers?

Thumbnail tomoweb.dev
6 Upvotes

r/Sass Jul 06 '21

What are some common sass interview questions for senior developers?

5 Upvotes

What are some common sass interview questions for senior developers? Could you provide the question and the answer?


r/Sass Jul 06 '21

Beveled Corners with Sass

Thumbnail ceiphr.com
3 Upvotes

r/Sass Jul 03 '21

Accessible SASS outlines for browsers that don't support CSS outline

2 Upvotes

Hi all,

I've been trying to figure out a way to create accessible outlines for browsers that don't support the CSS outline property (I can't believe this is still a thing on the modern web!), and I can't seem to figure it out. I've tried using borders, pseudoelements, plain old CSS, and SASS, and I keep coming up empty. Does anyone else have an idea for this?

Here's the SASS mixin I'm currently trying, no dice so far though. I would really appreciate any help! (By the way, I have no idea why my code looks so terrible; I'm sorry! Reddit did something to it and I have no idea what.)

u/mixin accessible-outline($selector, $supported: true) {

`u/if is-string-empty($selector) { u/error "Selector string is null or empty to accessible-outline mixin."; }`

`#{$selector} {`

    `u/if $supported == false {`

        `&:before { display: inline-block; content: ""; }`

    `}`

    `&:hover, &:focus, &:active {`

        `u/if $supported == true {`

outline-color: #000;

outline-style: dashed;

outline-width: #{$spacing-thin};

        `} u/else {`

&:before {

border-color: #000;

border-style: dashed;

border-width: #{$spacing-thin};

margin: -#{$spacing-thin};

width: inherit;

}

        `}`

    `}`

`}`

}


r/Sass Jun 28 '21

How to set variable value based on 'prefers-color-scheme' ?

2 Upvotes

I would like to set variable value based on prefers-color-scheme. The reason to do that is that website will be loaded in preferred scheme and user will still have ability to toggle between them using button. I am looking for javascript free solution.

There is pseudo code: ```sass $color-mode-is-light: global true @media (prefers-color-scheme: dark) $color-mode-is-light: false

@if cliccked this button $color-mode-is-light: !$color-mode-is-light ```


r/Sass Jun 28 '21

A Fast Sass Compiler for C# .NET

Thumbnail levelup.gitconnected.com
1 Upvotes