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
  • Issues
  • #31538
Closed
Open
Issue created Aug 26, 2020 by Administrator@rootContributor

v5: Improve customization by allowing manually setting calculated variables in styles

Created by: ydmitry

Hello!

We can have cases when we need to change specific style property, but we can't do this because this property value set up in Bootstrap library as calculated formula. The idea is to create separate variables for these cases and precalculate it in default values of these variables.

The same was done in this issue and PR, but only for button component: https://github.com/twbs/bootstrap/issues/28899 https://github.com/twbs/bootstrap/pull/29444

The idea is to follow this practice in all components.

Example

Before:

@mixin list-group-item-variant($state, $background, $color) {
  .list-group-item-#{$state} {
    // ...
    background-color: darken($background, 5%);
    // ...
  }
}

After:

@mixin list-group-item-variant($state, $background, $color, $background-hover: darken($background, 5%)) {
  .list-group-item-#{$state} {
    // ...
    background-color: $background-hover;
    // ...
  }
}

The same can be done not only for colors, but for calculated unit values:

Before:

.card-subtitle {
  margin-top: -$card-spacer-y / 2;
}

After:

// In variables:
$card-subtitle-spacer: -$card-spacer-y / 2 !default;

// In styles:
.card-subtitle {
  margin-top: $card-subtitle-spacer;
}

Benefits

  • Allows to customize more properties and if you don't need - just keep default calculation of the value
  • Allows to transform it to CSS variable usage by setting e.g. $background-hover: var(--bs-background-hover); (if we have background-color: darken($background, 5%); we can't do this)

Drawbacks

  • More variables to support
  • Longer migration guide (probably)

What do you thik about this? Should I do a PR?

Assignee
Assign to
Time tracking