Sha256: 79c381a22164b408dce5b5169504f179db0af9d96e6851e900df3834390109de

Contents?: true

Size: 776 Bytes

Versions: 4

Compression:

Stored size: 776 Bytes

Contents

def add_new_class(class_name, tag_name, tag_content)

`
  var styleTag = document.getElementById("atomic_style");
  styleTag.innerHTML += "\n    ."+#{class_name}+'{\n        '+#{tag_name}+': '+#{tag_content}+';\n}';
`
end

add_new_class('new_class', 'background-color','yellow')
add_new_class('other_class', 'color','red')

def update_css_tag(tag_name, var_name, value)
  `
  var rules = null;
      var cssRules = document.styleSheets[0].cssRules;
      for (var i = 0; i < cssRules.length; i++) {
      var rule = cssRules[i];
      if (rule.selectorText === '.'+#{tag_name}) {
        rules = rule;
        break;
      }
      }

      if (rules) {

      rules.style.setProperty(#{var_name}, #{value});
      }
`
end

update_css_tag('other_class', '--end-color', 'blue')

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
atome-0.5.4.1.7 lib/atome/renderers/browser/opal_add_on.rb
atome-0.5.4.1.3 lib/atome/renderers/browser/opal_add_on.rb
atome-0.5.4.1.2 lib/atome/renderers/browser/opal_add_on.rb
atome-0.5.4.1.1 lib/atome/renderers/browser/opal_add_on.rb