0
Welcome Guest! Login
0 items Join Now

SOLVED LESS misunderstanding?

    • Luke W's Avatar
    • Luke W
    • Rocketeer
    • Posts: 51
    • Thanks: 8

    Re: SOLVED LESS misunderstanding?

    Posted 10 years 9 months ago
    • Thanks Mark - I've just started really getting into LESS :)

      If I update main-style.less, I'll have to remember to redo if I update the template.

      I've worked out how to do it with CSS - it's a bit ugly that's all :/

      FWIW - I think that the way the compiler is processing the individual files, I can't use classes from main-style.less (even though I can use variables like @blocks-default)...strange.

      I need to learn more about the whole LESS process.

      Thanks again for your time!
    • MrT's Avatar
    • MrT
    • Preeminent Rocketeer
    • Posts: 101084
    • Thanks: 13482
    • Web Designer/Developer

    Re: SOLVED LESS misunderstanding?

    Posted 10 years 9 months ago
    • I did not say to change main-styles.less - you need to create a custom LESS file to make overrides to it called main-styles-custom.less

      Regards, Mark.
    • Please search forums before posting. Please make sure your post includes the version of the CMS you are using and a link to the problem. Annotations on screenshots can also be helpful to explain problems/goals. Please use the "secure" tab for confidential information.
    • Luke W's Avatar
    • Luke W
    • Rocketeer
    • Posts: 51
    • Thanks: 8

    Re: SOLVED LESS misunderstanding?

    Posted 10 years 9 months ago
    • oh - thank you!!!

      I was just in my kitchen and I thought - hey I wonder if you can override main-style.less ??

      I didn't realise you could and so I mis-read your reply! You're right - thanks again !!!!!!



      :)
    • Luke W's Avatar
    • Luke W
    • Rocketeer
    • Posts: 51
    • Thanks: 8

    Re: SOLVED LESS misunderstanding?

    Posted 10 years 9 months ago
    • custom main-style didn't work - continuing to investigate.

      Thanks.
    • Last Edit: 10 years 9 months ago by Luke W. Reason: still investigating
  • Re: SOLVED LESS misunderstanding?

    Posted 10 years 8 months ago
    • The first and fastest method to override a style is to add "rt_metropolis-custom.css" to your templates css folder and add the appropriate css code.

      The second method is to use the less compiler

      Option 1:
      To add minor style changes - How to add your template-custom.less

      After creating the file, simply add a reference in the /less/global.less master LESS file. The global.less file imports the other LESS files via the @import function. See the example below:
      // Core variables and mixins
      @import "variables.less";
      @import "mixins/index.less";
      // Core and Grid
      @import "gantry-core.less";
      @import "wordpress-core.less";
      // Template core styling and layout
      @import "template.less";
      @import "style.less";
      @import @headerstyle;
      @import "prettify.less";
      
      // Custom Overrides
      @import "template-custom.less";

      All mixins and viariables you used in template-custom.less are taken from /less/variables.less and /less/mixins/index.less.

      Option 2:
      To add mayor style changes - How to add your template-custom.less

      Add the code below to your templates /index.php file
          $gantry->addLess('template-custom.less', myOverrides.css', 1000);


      Your template-custom.less file should begin with the code below, if you want to use the .btn mixins and colors!
      @import "jui/less/variables.less";      // Bootstrap style variables (to get the vars and their values used below)
      @import "jui/less/mixins.less";         // Bootstrap Mixins
      
      .btn {
          .buttonBackground(@btnPrimaryBackground, @btnPrimaryBackgroundHighlight);
      }

      This would simply override the background color for all .btn elements with the colors for .btn-primary

      The file will then be compiled and stored in /compiled-css folder as myOverrides.css file

      The priority is the same as the rt_metropilis-custom.css would have.
      Taken from gantry frameworks finalize method
          $this->addStyle($this->templateName . '-custom.css', 1000);


      If you need further informations on how to work with less and gantry, please have a look in the gantry docs here
    • Last Edit: 10 years 8 months ago by Lahmizzar V. Reason: added url
    • Why i am doing what i do? Sometimes it simply came over me!

      Don't forget to hit the THANKS button for those who helped you and for those who need this for their alter ego :)
    • Luke W's Avatar
    • Luke W
    • Rocketeer
    • Posts: 51
    • Thanks: 8

    Re: SOLVED LESS misunderstanding?

    Posted 10 years 8 months ago
    • Thanks Lahmizzar M

      I'll go through the info and the Gantry doc.

      Quick question - if I do all the imports in my custom less file, am I duplicating all the code (Gantry loads them, then my custom less loads them again)?

      I guess the main question is: will the CSS that is downloaded by the browser double in size, or does the compiler recognize all the duplicates and just use one copy?
  • Re: SOLVED LESS misunderstanding?

    Posted 10 years 8 months ago
    • I'll try to hold my answer as short as possible :)


      Doing overrides resulting everytime in a bigger output file. To optimize the size, you have to cleanup all less and css files which need higher css/less programmer skills.

      But if you understand the core rules of less, its easy to work with.

      See:

      your html markup
      <div class="my-class-header">
          <h1>Header</h1>
      </div>

      your global.less ( add via $gantry->addLess('global.less', 'master.css'); )
      @import "variables.less";   // For example, with over 20000 lines of variables
      @import "mixin.less";      // For example, with over 50000 lines of mixins
      
      // your override files
      @import "your-custom.less";
      Here we import your-custom.less file

      the content of your-custom.less
      @import "rockettheme/variables.less";   // rt_template variables
      @import "rockettheme/mixin.less";      // rt_template mixins
      
      @import "variables.less";   // For example, with over 20000 lines of variables
      @import "mixin.less";      // For example, with over 50000 lines of mixins
      
      @import "special-mixins-from-smashing-magazine.com.less";      // For example, with over 60000 lines of mixins
      
      @import "myoverrides/your-custom-variables.less";   // For example, with over 5000 lines of different variables
      @import "myoverrides/your-custom-mixin.less";      // For example, with over 10000 lines of mixins
      
      
      // Colorize (for easieness here, but this is a part of a mixin file)
      .doColorAnimation(@color, @animation) {
          .color: @color;
          .doAnimationFromSmashingMagazine(@animation);
      }
      
      
      
      // @header-dark is for example a variable thet is defined in your-custom-variables.less, and the animation (which is in this example a string/not a var) is in the smashing.mixin..less file with a simple ruleset like: if blingbling, then do this, if pulsate, do that
      .my-class-header h1 {
          .doColorAnimation(@header-dark, blingbling);
      }
      


      the ready compiled master.css file looks like
      .my-class-header h1 {
          color: black;
          -webkit-animation: ..........;
                  animation: ..........;
          etc...   
      }


      As you can see we have imported a lot of variables and mixins in the global.less, heck, even in your custom less file.
      But the output is still that short peace of code (see master.css example).

      So all variables and mixins only are important for the compiler, that have to check if .doColorAnimation match a rule.


      Other example

      example.less
      @import "rt_template-variables.less";   // This file contain a variable => @headerColor: red;
      
      // at this point the @headerColor is still "red"
      
      @import "header-classes.less";   // This is for example a less file where RT defines all header classes, which need the var @headerColor
      
      The header color in the master.css is red


      NOW => Override the headerColor var

      example.less
      @import "rt_template-variables.less";   // This file contain a variable => @headerColor: red;
      
      // at this point the @headerColor is still "red"
      
      @import "my_override-variables.less";   // This file contain your variable as override => @headerColor: green;
      
      // at this point the @headerColor now is "green"
      
      @import "header-classes.less";   // This is for example a less file where RT defines all header classes, which need the var @headerColor

      The header color in the master.css is now green



      You could also have a look into the more advanced docs for less compiling on leafos homepage for his lessphp compiler which is a part of the gantry framework. Please note that the compiler in gantry is version 0.3.9 and is perfect for max bootstrap version 2.3.2.
    • Last Edit: 10 years 8 months ago by Lahmizzar V.
    • The following users have thanked you: David Goode

    • Why i am doing what i do? Sometimes it simply came over me!

      Don't forget to hit the THANKS button for those who helped you and for those who need this for their alter ego :)
    • David Goode's Avatar
    • David Goode
    • Preeminent Rocketeer
    • Posts: 17058
    • Thanks: 890
    • Web Designer and Host

    Re: SOLVED LESS misunderstanding?

    Posted 10 years 8 months ago
    • This message contains only secure information that is visible to Lahmizzar V, moderators and administrators

    • Please search forums before posting. Please make sure your post includes the version of the CMS you are using and a link to the problem. Annotations on screenshots can also be helpful to explain problems/goals. Please use the "secure" tab for confidential information
  • Re: SOLVED LESS misunderstanding?

    Posted 10 years 8 months ago
    • This message contains only secure information that is visible to David Goode, moderators and administrators
    • Last Edit: 10 years 8 months ago by Lahmizzar V.
    • Why i am doing what i do? Sometimes it simply came over me!

      Don't forget to hit the THANKS button for those who helped you and for those who need this for their alter ego :)
    • David Goode's Avatar
    • David Goode
    • Preeminent Rocketeer
    • Posts: 17058
    • Thanks: 890
    • Web Designer and Host

    Re: SOLVED LESS misunderstanding?

    Posted 10 years 8 months ago
    • This message contains only secure information that is visible to Lahmizzar V, moderators and administrators
    • The following users have thanked you: Lahmizzar V


    • Please search forums before posting. Please make sure your post includes the version of the CMS you are using and a link to the problem. Annotations on screenshots can also be helpful to explain problems/goals. Please use the "secure" tab for confidential information

Time to create page: 0.062 seconds