Partage
  • Partager sur Facebook
  • Partager sur Twitter

SASS : boucles / potentielproblème de compilation

    23 janvier 2020 à 6:16:50

    Bonjour, 

    Je galère avec le cours sur SASS suivant : "https://openclassrooms.com/fr/courses/6106181-simplifiez-vous-le-css-avec-sass/6606591-utilisez-les-boucles-dans-sass-pour-fluidifier-votre-code" partie : "Pour chacun et jusqu'au dernier" , je reprends le code de la prof pour voir ce que ça donne et comprendre mais malgré le fait que je colle exactement la même chose, je n'ai pas d'affichage et de nombreuses erreurs incompréhensives.

    J'ai pourtant relu le cours et beaucoup cherchée sur internet mais je ne comprends pas ce qui ne marche pas. J'ai fait l'exercice qui suit et j'y suis parvenue sans soucis. J'ai relu le cours plusieurs fois et je ne vois pas où sont les erreurs. En plus, j'ai des signes étranges dans le CSS mais ma compilation ne semble pas se faire correctement.

    Voici mon code SCSS : 

    $colour-primary: #00cc99;
    $colour-secondary: #001534;
    $colour-accent: #D6FFF5;
    $colour-white: #fff;
    $colour-invalid: #DB464B;
    $red: red;
    
    $heading-shadow-size: .55rem;
    $layout-margin: 6rem;
    $grid-gutter: $layout-margin * .25;
    
    
    // map couleurs
    $txt-input-palette: (
      active: (
          bg: $colour-primary,
          border1: $colour-primary,
          txt: $colour-white,
       ),
      focus: (
          bg: $colour-primary,
          border1: $colour-primary,
          txt: $colour-white,
      ),
      invalid: (
          bg: $colour-invalid,
          border1: $colour-white,
          txt: $colour-white,
      )
    );
    
    
    @mixin txt-input-palette($palettes) 
    {
        // $state : key, $palette: value, $palettes : map(état ? cad invalid...
          @each $state, $palette in $palettes 
          {
              border: 2px solid map-get($palette, border1),
              background-color: map-get($palette, bg),
              color: map-get($palette, txt),
          }
    }
        
        
    .form__field
            {  
                input
                {
                   // box-shadow: 2px 2px red;
                   @include txt-input-palette($palettes);
                }
              
            }
    
    

    Voici mon code CSS : 

    /*
    Error: Invalid CSS after "   ": expected ":", was "),"
            on line 19 of SCSS/utils/_variables.scss
            from line 1 of ./SCSS/main.scss
    
    14: $txt-input-palette: (
    15:   active: (
    16:       bg: $colour-primary,
    17:       border1: $colour-primary,
    18:       txt: $colour-white,
    19:    ),
    20:   focus: (
    21:       bg: $colour-primary,
    22:       border1: $colour-primary,
    23:       txt: $colour-white,
    24:   ),
    
    Backtrace:
    SCSS/utils/_variables.scss:19
    ./SCSS/main.scss:1
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/scss/parser.rb:1308:in `expected'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/script/lexer.rb:240:in `expected!'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/script/parser.rb:862:in `assert_tok'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/script/parser.rb:337:in `map_pair'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/script/parser.rb:327:in `map'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/script/parser.rb:794:in `block in paren'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/script/parser.rb:904:in `without_stop_at'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/script/parser.rb:792:in `paren'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/script/parser.rb:746:in `square_list'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/script/parser.rb:733:in `special_fun'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/script/parser.rb:727:in `raw'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/script/parser.rb:642:in `funcall'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/script/parser.rb:531:in `css_min_max'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/script/parser.rb:507:in `ident'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/script/parser.rb:295:in `unary_not'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/script/parser.rb:295:in `unary_div'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/script/parser.rb:295:in `unary_minus'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/script/parser.rb:295:in `unary_plus'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/script/parser.rb:272:in `times_div_or_mod'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/script/parser.rb:272:in `plus_or_minus'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/script/parser.rb:272:in `relational'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/script/parser.rb:272:in `eq_or_neq'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/script/parser.rb:272:in `and_expr'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/script/parser.rb:272:in `or_expr'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/script/parser.rb:481:in `space'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/script/parser.rb:422:in `interpolation'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/script/parser.rb:853:in `assert_expr'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/script/parser.rb:338:in `map_pair'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/script/parser.rb:324:in `map'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/script/parser.rb:794:in `block in paren'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/script/parser.rb:904:in `without_stop_at'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/script/parser.rb:792:in `paren'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/script/parser.rb:746:in `square_list'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/script/parser.rb:733:in `special_fun'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/script/parser.rb:727:in `raw'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/script/parser.rb:642:in `funcall'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/script/parser.rb:531:in `css_min_max'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/script/parser.rb:507:in `ident'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/script/parser.rb:295:in `unary_not'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/script/parser.rb:295:in `unary_div'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/script/parser.rb:295:in `unary_minus'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/script/parser.rb:295:in `unary_plus'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/script/parser.rb:272:in `times_div_or_mod'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/script/parser.rb:272:in `plus_or_minus'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/script/parser.rb:272:in `relational'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/script/parser.rb:272:in `eq_or_neq'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/script/parser.rb:272:in `and_expr'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/script/parser.rb:272:in `or_expr'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/script/parser.rb:481:in `space'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/script/parser.rb:422:in `interpolation'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/script/parser.rb:343:in `expr'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/script/parser.rb:853:in `assert_expr'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/script/parser.rb:68:in `parse'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/scss/parser.rb:1164:in `sass_script'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/scss/parser.rb:653:in `variable'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/scss/parser.rb:707:in `block_child'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/scss/parser.rb:700:in `block_contents'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/scss/parser.rb:137:in `stylesheet'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/scss/parser.rb:41:in `parse'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/engine.rb:414:in `_to_tree'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/engine.rb:321:in `to_tree'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/tree/visitors/perform.rb:323:in `block in visit_import'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/stack.rb:88:in `block in with_import'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/stack.rb:135:in `with_frame'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/stack.rb:88:in `with_import'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/tree/visitors/perform.rb:322:in `visit_import'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/tree/visitors/base.rb:36:in `visit'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/tree/visitors/perform.rb:158:in `block in visit'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/stack.rb:79:in `block in with_base'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/stack.rb:135:in `with_frame'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/stack.rb:79:in `with_base'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/tree/visitors/perform.rb:158:in `visit'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/tree/visitors/base.rb:52:in `block in visit_children'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/tree/visitors/base.rb:52:in `map'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/tree/visitors/base.rb:52:in `visit_children'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/tree/visitors/perform.rb:167:in `block in visit_children'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/tree/visitors/perform.rb:179:in `with_environment'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/tree/visitors/perform.rb:166:in `visit_children'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/tree/visitors/base.rb:36:in `block in visit'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/tree/visitors/perform.rb:186:in `visit_root'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/tree/visitors/base.rb:36:in `visit'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/tree/visitors/perform.rb:157:in `visit'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/tree/visitors/perform.rb:10:in `visit'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/tree/root_node.rb:36:in `css_tree'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/tree/root_node.rb:29:in `render_with_sourcemap'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/engine.rb:389:in `_render_with_sourcemap'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/engine.rb:307:in `render_with_sourcemap'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/plugin/compiler.rb:462:in `update_stylesheet'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/plugin/compiler.rb:215:in `block in update_stylesheets'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/plugin/compiler.rb:209:in `each'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/plugin/compiler.rb:209:in `update_stylesheets'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/plugin/compiler.rb:443:in `on_file_changed'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-3.7.4/lib/sass/plugin/compiler.rb:320:in `block in watch'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-listen-4.0.0/lib/sass-listen/event/config.rb:23:in `call'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-listen-4.0.0/lib/sass-listen/event/processor.rb:115:in `_process_changes'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-listen-4.0.0/lib/sass-listen/event/processor.rb:19:in `block in loop_for'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-listen-4.0.0/lib/sass-listen/event/processor.rb:15:in `loop'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-listen-4.0.0/lib/sass-listen/event/processor.rb:15:in `loop_for'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-listen-4.0.0/lib/sass-listen/event/loop.rb:84:in `_wait_for_changes'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-listen-4.0.0/lib/sass-listen/event/loop.rb:42:in `block in setup'
    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sass-listen-4.0.0/lib/sass-listen/internals/thread_pool.rb:6:in `block in add'
    */
    body:before {
      white-space: pre;
      font-family: monospace;
      content: "Error: Invalid CSS after \"   \": expected \":\", was \"),\"\A         on line 19 of SCSS/utils/_variables.scss\A         from line 1 of ./SCSS/main.scss\A \A 14: $txt-input-palette: (\A 15:   active: (\A 16:       bg: $colour-primary,\A 17:       border1: $colour-primary,\A 18:       txt: $colour-white,\A 19:    ),\A 20:   focus: (\A 21:       bg: $colour-primary,\A 22:       border1: $colour-primary,\A 23:       txt: $colour-white,\A 24:   ),"; }
    

    Il manque pas mal de chose pourtant le watch est actif, mes modifications simples passent bien... 

    Je ne m'explique pas les signes ressemblant à ┬á┬á┬á dans le CSS notamment que l'on voit ici : 

    Merci par avance à ceux qui liront mon post. 

    Bonne journée.




    -
    Edité par laure79 23 janvier 2020 à 6:29:27

    • Partager sur Facebook
    • Partager sur Twitter
      23 janvier 2020 à 8:40:40

      bonjour le  cours sur SASS à l'air intéréssant c'est surtout pour ça que j'ai cliqué je n'ai malheuresement pas vraiment de connaissance en SASS pour l'instant :lol: .

      Mais une idée de debug un peut généraliste serait de mettre des parties du code en commentaire puis recompilé jusqu'à ce que le message d'erreur change pour tenté d'isolé le/les origines de problèmes ( attention tout de même à ne pas mettre des déclaration de variables en commentaires et laisser leur utilisation en dessous ) .

      SASS doc si ça peut t'aidé , bonne chance . 

      • Partager sur Facebook
      • Partager sur Twitter

      suggestion de présentation.

        23 janvier 2020 à 11:47:44

        Bonjour Samuel,

        Merci pour le message. J'ai déjà vu la doc et beaucoup recherché sur internet. J'ai aussi isolé mon code mais ça ne fonctionne pas. 

        • Partager sur Facebook
        • Partager sur Twitter
          23 janvier 2020 à 14:29:54

          peut-être un problème d'encodage quelqu'un à proposé d'ajouté

          @charset "UTF-8";

          sur la premiére ligne avant le moindre espace sur un autre topic de StackOverflow

          il y à une page de la doc sur les charset parce que le topic de stackoverflow et un peut vieux ( 5ans ) ...

          -
          Edité par SamuelGaborieau3 23 janvier 2020 à 14:31:32

          • Partager sur Facebook
          • Partager sur Twitter

          suggestion de présentation.

            23 janvier 2020 à 18:45:33

            Bonjour laure79 ,

            J'ai repris le code que tu fournis et j'ai pas de problème hormis  :

            dans le  @each on ne doit pas finir par une "," mais un ";"

            @include txt-input-palette($palettes); c'est pas $palettes mais $txt-input-palette

            Essayes de voir, si cela règle le pb?

            Mais j'ai des doutes, mais bon on sait jamais ...

            • Partager sur Facebook
            • Partager sur Twitter
            Découvrez les Css avec la zonecss.fr
              24 janvier 2020 à 5:32:33

              Bonjour Samuel et Alias Dmc, 

              Merci pour vos messages et merci AliasDmc pour le nom de la palette, ça m'avait échappé !

              Les signes étranges ont disparu. Par défaut, d'après le cours, on utilise en principe le style nested mais je ne suis pas sûre que cela soit valable dans toutes les versions. Car, j'ai supprimé tous mes espaces mis à part les retours à la ligne et finalement les signes ont disparus. Vu que ce n'est vraiment pas très lisibles, j'ai remis mes espaces après avoir mis le code CSS en style nested dans le fichier json. Depuis, les signes ont disparus et les erreurs aussi. En gros, j'ai précisé le style par défaut qui par défaut ne s'appliquait pas... :)

              Merci beaucoup pour votre aide. 

              -
              Edité par laure79 24 janvier 2020 à 5:48:20

              • Partager sur Facebook
              • Partager sur Twitter

              SASS : boucles / potentielproblème de compilation

              × Après avoir cliqué sur "Répondre" vous serez invité à vous connecter pour que votre message soit publié.
              × Attention, ce sujet est très ancien. Le déterrer n'est pas forcément approprié. Nous te conseillons de créer un nouveau sujet pour poser ta question.
              • Editeur
              • Markdown