Skip to content

Add global configuration and methods to enable the use of calc by default in numeric operations #40412

Closed as not planned
@SalimBensiali

Description

Looking at

$input-height-inner: add($input-line-height * 1em, $input-padding-y * 2) !default;

while add is using calc by default (See https://github.com/twbs/bootstrap/blob/main/scss/_functions.scss#L222), if $input-padding-y is overridden to use calc (say calc(2 * 14px)), then the entire assignment will fail with an error such as

Undefined operation "calc(2 * 14px) * 2".

because the outer multiplication by 2 is not using calc itself.

Could we add a global and overridable SCSS variable ($return-calc) and introduce a multiply function that would use that variable to decide whether to return calc or not? The existing add could also benefit from that global $return-calc variable.

The original assignment would then turn change to the below and would no longer fail.

add(multiply($input-line-height, 1em), multiply($input-padding-y, 2)) !default;

I would be happy to supply a PR for this if you see value in it.

Cheers

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions