CSS variable to override the required form input background-image

Created on 22 March 2023, over 1 year ago
Updated 19 April 2023, over 1 year ago

Problem/Motivation

Feature request
Status

Fixed

Version

5.0

Component

User interface

Created by

🇫🇷France Grimreaper France 🇫🇷

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @Grimreaper
  • @grimreaper opened merge request.
  • Assigned to pdureau
  • 🇫🇷France Grimreaper France 🇫🇷

    Not possible to use CSS variable directly inside url() because it is a new whole virtual file that is manipulated so CSS variables of the current document are not available.

    The MR provides UI Skins integration as well as an example in the example subtheme for compiled CSS in custom theme.

    @pdureau: are you ok with that? Especially the machine names of CSS variables.

  • Status changed to Needs review over 1 year ago
  • 🇫🇷France Grimreaper France 🇫🇷
  • Assigned to Grimreaper
  • Status changed to Needs work over 1 year ago
  • 🇫🇷France pdureau Paris

    Hello,

    I disagree about the introduction of a new CSS variable which doesn't belong to the Bootstrap API, and it is not ui_suite_bootstrap job to create or extend an API.

    Because the color of the required mark is already the one, I suggest to hardcode the initial value:

    background-image: url("data:image/svg+xml,%3Csvg height='16' width='16' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='m0 7.562 1.114-3.438c2.565.906 4.43 1.688 5.59 2.35-.306-2.921-.467-4.93-.484-6.027h3.511c-.05 1.597-.234 3.6-.558 6.003 1.664-.838 3.566-1.613 5.714-2.325l1.113 3.437c-2.05.678-4.06 1.131-6.028 1.356.984.856 2.372 2.381 4.166 4.575l-2.906 2.059c-.935-1.274-2.041-3.009-3.316-5.206-1.194 2.275-2.244 4.013-3.147 5.206l-2.856-2.059c1.872-2.307 3.211-3.832 4.017-4.575-2.081-.402-4.058-.856-5.93-1.356' fill='%23dc3545'/%3E%3C/svg%3E%0A");

    And add a UI Ssins related hook/event/alter which "listen" the change of the primary color CSS variable and inject an inline CSS code if different from default.

    Example if primary === navy:

    <style>
    .required-mark::after {
    background-image: url("data:image/svg+xml,%3Csvg height='16' width='16' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='m0 7.562 1.114-3.438c2.565.906 4.43 1.688 5.59 2.35-.306-2.921-.467-4.93-.484-6.027h3.511c-.05 1.597-.234 3.6-.558 6.003 1.664-.838 3.566-1.613 5.714-2.325l1.113 3.437c-2.05.678-4.06 1.131-6.028 1.356.984.856 2.372 2.381 4.166 4.575l-2.906 2.059c-.935-1.274-2.041-3.009-3.316-5.206-1.194 2.275-2.244 4.013-3.147 5.206l-2.856-2.059c1.872-2.307 3.211-3.832 4.017-4.575-2.081-.402-4.058-.856-5.93-1.356' fill='navy'/%3E%3C/svg%3E%0A");
    }
    </style>
    
  • Assigned to pdureau
  • Status changed to Needs review over 1 year ago
  • 🇫🇷France Grimreaper France 🇫🇷

    Thanks,

    Review taken into account. Ready for new review.

  • Assigned to Grimreaper
  • 🇫🇷France pdureau Paris

    Reviewed

  • Status changed to RTBC over 1 year ago
    • Grimreaper committed 5bf097a5 on 5.0.x
      Issue #3349734 by Grimreaper, pdureau: Be able to override required mark...
  • 🇫🇷France Grimreaper France 🇫🇷
  • Issue was unassigned.
  • Status changed to Fixed over 1 year ago
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024