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
  • !36004

Form control: required

  • Review changes

  • Download
  • Email patches
  • Plain diff
Closed Administrator requested to merge main into gs-forms Mar 11, 2022
  • Overview 0
  • Commits 0
  • Pipelines 0
  • Changes 0

Created by: richware

I did not see anywhere that the 'required' attribute was handled, therefore I have created the following SASS: [this includes suggestions by WinterSilence]

.form-control,
.form-select,
.form-range
  &:required
    @include auto-duo-gradient($form-required-bg,5%)
    .disabled&,
    [disabled]& 
        ...

Where the auto-duo-gradient mixin is:

@mixin auto-duo-gradient($color,$adj-amount:18%,$important:true)
  $imp: null
  @if($important)
    $imp: !important
  $color-top: $color
  $color-bottom: $color // darkest color at the bottom
  @if(color.lightness($color) >= (100% - $adj-amount)) // color too light - reverse colors
    $color-bottom: darken($color,$adj-amount)
  @else
    $color-top: lighten($color,$adj-amount)
  background: linear-gradient($color-top,$color-bottom) $imp
  color: color-contrast($color-bottom) $imp

Regards, Rich

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: main