"String Interpolation' excercise returns a compile error


#1

After inserting the code lines

@mixin photo-content($file) {
  content: url(#{$file}.jpg); 
  object-fit: cover;
}

and

@include photo-content('titanosaur');
        width: 60%;
        margin: 0px auto;

into main.sass I receive the compilation error

Error: wrong number of arguments (1 for 0) for photo-content on line 100 of main.scss >> @include photo-content('titanosaur'); -----------------^

Obviously the photo-content mixin has an argument of the image file name. Any ideas?


#2

Exercise 7, https://www.codecademy.com/en/courses/learn-sass/lessons/mixins-and-parent-selector/exercises/string-interpolation

Could you post all of your main.css file please?


#3

2 posts were split to a new topic: 7. This is my main.scss


#4

Just sharing an idea here, I don't know what's going on or really anything at all about sass.

What if the function/whatever-it-is is failing to compile/whatever-it-does and you're using a previous version that takes no arguments?
And I'm suggesting this because the creation of the file name looks really odd to me. Again, I don't know what it's supposed to look like.


#5

Sure here it is:

$stripe-properties: to bottom, 15%, blue, white;

@mixin photo-content($file) {
  content: url(#{$file}.jpg); 
  object-fit: cover;
}


@mixin transition($time){
  transition: $time;
  -webkit-transition: $time;
  -moz-transition: $time;
  -o-transition: $time;
}

@mixin transform-style($style){
   transform-style: $style;
  -moz-transform-style: $style;
  -o-transform-style: $style;
  -ms-transform-style: $style;
  -webkit-transform-style: $style;
}

@mixin backface-visibility($visibility: hidden) { 
  //Add an argument
  backface-visibility: $visibility;
  -webkit-backface-visibility: $visibility;
  -moz-backface-visibility: $visibility;
  -ms-backface-visibility: $visibility;
  -o-backface-visibility: $visibility;
}

@mixin stripes($direction, $width-percent, $stripe-color, $stripe-background: #FFF) {
  background: repeating-linear-gradient(
    $direction,
    $stripe-background,
    $stripe-background ($width-percent - 1),
    $stripe-color 1%,
    $stripe-background $width-percent
  );
}

@mixin transform($transformation) {
  transform: $transformation;
  -webkit-transform: $transformation;
  -moz-transform: $transformation;
  -ms-transform: $transformation;
  -o-transform: $transformation;  
}

@mixin photo-content {
  object-fit: cover;
}

//Add your own mixins here

.notecard {
  width: 300px;
  height: 180px;
  border: 1px solid black;
  display: inline-block;
  margin: 20px;
  font-family: Roboto, sans-serif;
  box-shadow: 1px 1px 2px 2px rgba(0,0,0,.2);
  @include transform-style(preserve-3d);
  @include transition(0.4s);
  
  .front, .back {
    width: 100%;
    height: 100%;
    position: absolute;
    @include backface-visibility;
  }
  
  .front {
  z-index: 3;
  font-size: 20px;

    .word {
      display: block;
      text-align: center;
      position: relative;
      top: 40%;
    }    
  }
  
  
  .back {
  z-index: 1;
  word-wrap: break-word;
  line-height: 1.6;
    @include transform(rotatey(-180deg));
    
    .definition {
      width: 100%;
      height: 100%;
      @include stripes($stripe-properties...);
            
      .photo {
       
        @include photo-content('titanosaur');
        width: 60%;
        margin: 0px auto;  

          
      }
    }
  }
  &:hover {
    @include transform (rotatey(-180deg)); 
  }
}

#6

Thanks for the suggestion but as you may know codecademy uses automatic compilation in the background, so there is no version control possible. In other hand, as far as I know Sass supported mixin arguments since its eraly versions.


#8

There are two versions of photo-content in your code.
One of them takes no arguments.


#9

Thanks, it solved the problem.


#11

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.


Method argument error in 7th level