less / less/less.js

How do I use a variable in less js as a command that appears before a parenthesis?

Open
#3,606 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

question
Dominant language
JavaScript
Stars
17k
Forks
3.4k
Avg merge
7h 42m
Merged PRs (30d)
26

Description

How do I use a variable in less js as a command that appears before a ( bracket or parenthesis?
I asked on Stack Overflow and couldn't get any help.


.breadcrumb li:nth-child(2) a       { background:  darken(@breadcrumbrootback, 5%); }
.breadcrumb li:nth-child(2) a:after { border-left-color:  darken(@breadcrumbrootback, 5%); }

I would like to change darken( to @breadcrumbcolouraction( so the command is chosen based on a variable (so it could be either lighten or darken based on the value or a variable). How do I do this?

@breadcrumbcolouraction: "darken";
@breadcrumbcolouraction: "lighten";

In less version 4.1.1 if I changed darken to the variable @breadcrumbcolouraction, the less file would fail to compile.

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

The issue names Less 4.1.1 but no repository files or tests. Start by checking the documented handling of variables before parentheses and the relevant Less function-resolution behavior; done means determining whether the requested dynamic lighten/darken selection is supported and documenting or scoping the required change.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.