{"size": 1015, "ext": "js", "max_stars_repo_path": "src/js/lib.js", "max_stars_repo_name": "bryanwills/acss_devtools", "max_stars_repo_stars_event_min_datetime": "2018-07-19T15:30:42.000Z", "max_stars_repo_stars_event_max_datetime": "2019-02-14T08:53:18.000Z", "max_issues_repo_path": "src/js/lib.js", "max_issues_repo_name": "bryanwills/acss_devtools", "max_issues_repo_issues_event_min_datetime": "2018-07-23T09:36:01.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-26T04:43:35.000Z", "max_forks_repo_path": "src/js/lib.js", "max_forks_repo_name": "bryanwills/acss_devtools", "max_forks_repo_forks_event_min_datetime": "2018-07-23T09:02:39.000Z", "max_forks_repo_forks_event_max_datetime": "2021-04-19T17:33:37.000Z"}
{"max_stars_count": 4, "max_issues_count": 10, "max_forks_count": 3, "avg_line_length": 28.1944444444, "max_line_length": 74, "alphanum_fraction": 0.5172413793}
import acssRuleMap from './ruleMap';

export const generateAtomicClass = (selectedElementCssText = '') => {
    const inlineStyleText = selectedElementCssText;
    const inlineStyleArray =
        (inlineStyleText && inlineStyleText.split('; ')) || [];
    const styleMap = [];

    inlineStyleArray.forEach(styleString => {
        if (!styleString) {
            return;
        }
        const styleArray = styleString.replace(';', '').split(': ');
        const style = {
            [styleArray[0]]: styleArray[1]
        };

        let acssClass = acssRuleMap[`${styleArray[0]}: ${styleArray[1]}`];

        if (acssClass) {
            styleMap.push(acssClass);
        } else {
            acssClass = acssRuleMap[`${styleArray[0]}: value`];
            styleMap.push(
                acssClass
                    .replace('<value> or ', '')
                    .replace('<custom-param>', styleArray[1])
            );
        }
    });

    return {
        acss: styleMap.join(' ').toString()
    };
};
