Migrate changeCSS() to CSS variable in utils/utils.jsx, ln. 700 #16028
Labels
Area/Technical Debt
Difficulty/1:Easy
Easy ticket
Hacktoberfest
Help Wanted
Community help wanted
PR Exists
Tech/ReactJS
Web app
Context:
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 occurances ofchangeCSS()
within theapplyTheme()
function with corresponding CSS variables directly in the CSS files. This ticket is part of a larger campaign.Migration TL;DR
In the Mattermost Webapp repo, go to line number 700 in the file
utils/utils.jsx
(link). You should see the following (might not be the exact line number):campaign/applytheme_center-channel-color
theme.centerChannelColor
with the CSS variable--center-channel-color
from the line abovecampaign/applytheme_center-channel-color
when ready (not 'Master')Additional details on how to migrate
For this ticket, we will be replacing the use of the Javascript variable
theme.centerChannelColor
from the above line of code with the CSS variable--center-channel-color
. Please work off the branchcampaign/applytheme_center-channel-color
to avoid conflicts with other tickets for the same campaign. The line number may not be the same as when this ticket was created, but should be close.You can use these steps to help determine where to apply the new CSS variable followed by removing the call to
changeCSS()
fromutils/utils.jsx
:changeCSS
and specifically the final selector (eg..app__body .sidebar--menu
)changeCSS()
above (eg.'background:' </ins> theme.sidebarBg
)sass/layout/_sidebar-menu.scss
)utils/utils.jsx
.campaign/applytheme_center-channel-color
. We will be using this branch to review and QA changes in batches 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 line you are working onchangeCSS()
include the use of a customchangeOpacity()
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))
inutils/utils.jsx
would becomergba(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 thergba
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.Example of migrated code
PR #6655
Questions
Feel free to 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-29842
The text was updated successfully, but these errors were encountered: