less / less/less-docs

About Variables / Default Variables

Open
#515 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Less
Stars
680
Forks
442
PR merge metrics
No merged PRs in 30d

Description

http://lesscss.cn/features/#variables-feature-default-variables
It writes:
We sometimes get requests for default variables - an ability to set a variable only if it is not already set.

This feature is not required because you can easily override a variable by putting the definition afterwards.

For instance:

// library
@base-color: green;
@dark-color: darken(@base-color, 10%);

// use of library
@import "library.less";
@base-color: red;

This works fine because of Lazy Loading - base-color is overridden and dark-color is a dark red.


I don't think the behavior in the example meets the instruction, because the @base-color is already set to green, it shouldn't be reset to red.

So I think the instruction should be:
" We sometimes get requests for default variables - an ability to set a variable only if it is not already set.

This feature is conflicted with 'overriding a variable by putting the definition afterwards', so we couldn't implement the behavior of default variables."

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Open the variables-feature-default-variables section at lesscss.cn/features/ and compare its explanation with the example in this issue. Update the documentation to state that default variables conflict with overriding a variable later, then verify that the revised wording accurately describes the example.

Written by the indexing model from the issue text.

Assessment

Tech stack
css
Domain
documentation
Issue type
Documentation
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.