Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • B bootstrap
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 263
    • Issues 263
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 114
    • Merge requests 114
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Bootstrap
  • bootstrap
  • Merge requests
  • !28915

Add "add" and "subtract" func to return valid calc

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Administrator requested to merge master-ysds-addition-subtraction-func into master Jun 17, 2019
  • Overview 0
  • Commits 6
  • Pipelines 0
  • Changes 9

Created by: ysds

Fixes #28792 (closed)

Add the two Sass functions (add(), subtract()) to return a valid calc. These functions basically return a calc expression, but if one value is 0 the functions return another value.

e.g.

div {
  padding: add(1rem, 1px);  // calc(1rem + 1px)
  padding: add(1rem, 0);    // 1rem
}

The each functions has the third argument (boolean). If true, the expression is returned with wrapped by calc, but if false, the expression is not wrapped with calc. The default is true. This option is intended for use in complex nested expressions:

e.g.

div {
  padding: add(1rem, add(1em, 1px));         // calc(1rem + calc(1em + 1px)) : invalid in IE
  padding: add(1rem, add(1em, 1px, false));  // calc(1rem + 1em + 1px) : valid in IE
}
  • add calc() to stylelint function-blacklist
Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: master-ysds-addition-subtraction-func