main

mattermost/focalboard

Last updated at: 29/12/2023 09:40

globalScssClassLoader.js

TLDR

This file is a JavaScript module that exports a single function called loader. It modifies the source code by adding a specific prefix to lines that start with either a dot (.) or a hash (#), except for lines that match certain conditions defined in the blockList function.

Methods

There are no additional methods defined in this file.

Classes

There are no classes defined in this file.

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.

function blockList(line) {
    return line.startsWith('.focalboard-body') ||
        line.startsWith('.GlobalHeaderComponent') ||
        line.startsWith('.boards-rhs-icon') ||
        line.startsWith('.focalboard-plugin-root') ||
        line.startsWith('.FocalboardUnfurl') ||
        line.startsWith('.CreateBoardFromTemplate');
}

module.exports = function loader(source) {
    var newSource = [];
    source.split('\n').forEach((line) => {
        if ((line.startsWith('.') || line.startsWith('#')) && !blockList(line)) {
            newSource.push('.focalboard-body ' + line);
        } else {
            newSource.push(line);
        }
    });
    return newSource.join('\n');
};