Sha256: c4d444563a9aeced47fd5473aaa9058dd619f3083996005eb4309b1046b528cc

Contents?: true

Size: 688 Bytes

Versions: 1

Compression:

Stored size: 688 Bytes

Contents

module React
  module Component
    class Styles
      def initialize(native)
        @native = native
      end

      # TODO method chain access
      # we have class.property
      def method_missing(prop, *args, &block)
        %x{
          if (!#@native || typeof #@native[prop] === 'undefined') { return #{nil}; }
          let value = #@native[prop];
          if (typeof value === 'string' || typeof value === 'number' || Array.isArray(value)) { return value; }
          if (typeof value === 'function') { return #{Proc.new { `value()` }} }
          return Opal.React.Component.Styles.$new(value);
        }
      end

      def to_n
        @native
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
isomorfeus-react-16.9.15 lib/react/component/styles.rb