We are working on replacing our older custom theme implementation (applyTheme()
) currently used to change component colors throughout the webapp to match the selected theme. We have decided to utilize CSS variables as a replacement and so we now need to replace all occurrences of changeCSS()
within the applyTheme()
function with corresponding CSS variables directly in the CSS files. This ticket is part of a larger campaign.
Go to line number 504 in the file utils/utlis.jsx
. You should see the following:
changeCss('@media(max-width: 768px){.app__body .modal .settings-modal:not(.settings-modal--tabless):not(.display--content) .modal-content', 'background:' + theme.sidebarBg);
For this ticket, we will be replacing the use of the Javascript variable theme.sidebarBg
from this line of code with the CSS variable --sidebar-bg
Run through these steps to determine where to apply the new CSS variable followed by removing the call to changeCSS()
from utils/utlis.jsx
:
changeCSS
and specifically the final selector (eg. .app__body .sidebar--menu
)changeCSS()
above (eg. 'background:' </ins> theme.sidebarBg
)sass/layout/_sidebar-menu.scss
, ln.3)changeCSS()
from utils/utlis.jsx
.campaign/applytheme_sidebar-bg
. We will be using this branch to review and QA changes in batches on a regular basis instead of on each individual ticket in the campaign given the number of overall tickets for this campaign.Notes:
changeCSS()
affect the styles of sections of the UI that might not be visible by default. Remember to check modals, pop-ups, menus and different interaction states (hover, active, etc.) as necessary based on the particular ticket you are working onchangeCSS()
include the use of a custom changeOpacity()
function when applying colours that need to be partially transparent. These instances will need to be replaced with the rgba CSS function. For example, changeOpacity(theme.sidebarBg, 0.3))
in utils/utlis.jsx
would become rgba(var(--sidebar-bg-rgb), 0.3)
in CSS. Appending -rgb
to the CSS variable name is necessary when using one of the theme variables to work with the rgba
CSS function.changeCSS()
line is no longer valid, in which case, just removing the line as part of your PR is a perfectly valid solution.Feel free to can ask for help by messaging either @deanwhillier or @hmhealey or by posting in the ~webapp channel on the Mattermost Community server.
If you're interested please comment here and come join our "Contributors" community channel on our daily build server, where you can discuss questions with community members and the Mattermost core team. For technical advice or questions, please join our "Developers" community channel.
New contributors please see our Developer's Guide.
JIRA ticket: https://mattermost.atlassian.net/browse/MM-29387
Hey Dean,
I will like to give a shot to this one 馃憤
Cheers,
All yours @ng29, thanks!
All yours @ng29, thanks!
Hey Dean,
Apology for the delay, got stuck in shifting. I Will try my best to resolve this before weekend.
Hi Nitin, no problem at all and thanks again!
Hi Nitin, no problem at all and thanks again!
Can you please help how to start with this, as per my understanding them.sidebarbg needs to be replaced with --sidebar-bg, is there anything else that needs to be catered ??
Can you please help how to start with this, as per my understanding them.sidebarbg needs to be replaced with --sidebar-bg, is there anything else that needs to be catered ??
That's pretty much it. Not difficult on the surface, however, you will need to track down where to put the CSS variable so that it applies the same styling as the JS line it is replacing. The ticket description includes some steps you can take with additional notes to consider.
Give it a go and if you are having trouble, message again and I can give you a hand!
Most helpful comment
Hi Nitin, no problem at all and thanks again!