diff --git a/src/Web/CSSOM/CSSStyleDeclaration.js b/src/Web/CSSOM/CSSStyleDeclaration.js new file mode 100644 index 0000000..c43b49b --- /dev/null +++ b/src/Web/CSSOM/CSSStyleDeclaration.js @@ -0,0 +1,55 @@ +"use strict"; + +exports.cssText = function(style) { + return function() { + return style.cssText; + }; +}; + +exports.setCssText = function(style) { + return function(newCSS) { + return function() { + style.cssText = newCSS; + }; + }; +}; + +exports.length = function(style) { + return function() { + return style.length; + }; +}; + +exports.getPropertyPriority = function(style) { + return function(propName) { + return function() { + return style.getPropertyPriority(propName); + }; + }; +}; + +exports.getPropertyValue = function(style) { + return function(propName) { + return function() { + return style.getPropertyValue(propName); + }; + }; +}; + +exports.removeProperty = function(style) { + return function(propName) { + return function() { + style.removeProperty(propName); + }; + }; +}; + +exports.setProperty = function(style) { + return function(propName) { + return function(propValue) { + return function() { + style.setProperty(propName, propValue); + }; + }; + }; +}; diff --git a/src/Web/CSSOM/CSSStyleDeclaration.purs b/src/Web/CSSOM/CSSStyleDeclaration.purs new file mode 100644 index 0000000..f0bd516 --- /dev/null +++ b/src/Web/CSSOM/CSSStyleDeclaration.purs @@ -0,0 +1,22 @@ +module Web.CSSOM.CSSStyleDeclaration + ( module Exports + , length + , getPropertyPriority + , getPropertyValue + , removeProperty + , setProperty + ) where + +import Prelude +import Effect (Effect) +import Web.CSSOM.Internal.Types (CSSStyleDeclaration) as Exports +import Web.CSSOM.Internal.Types (CSSStyleDeclaration) + +foreign import cssText :: CSSStyleDeclaration -> Effect String +foreign import setCssText :: CSSStyleDeclaration -> String -> Effect Unit +foreign import length :: CSSStyleDeclaration -> Effect Number + +foreign import getPropertyPriority :: CSSStyleDeclaration -> String -> Effect String +foreign import getPropertyValue :: CSSStyleDeclaration -> String -> Effect String +foreign import removeProperty :: CSSStyleDeclaration -> String -> Effect Unit +foreign import setProperty :: CSSStyleDeclaration -> String -> String -> Effect Unit diff --git a/src/Web/CSSOM/ElementCSSInlineStyle.js b/src/Web/CSSOM/ElementCSSInlineStyle.js new file mode 100644 index 0000000..c4f0a4d --- /dev/null +++ b/src/Web/CSSOM/ElementCSSInlineStyle.js @@ -0,0 +1,7 @@ +"use strict"; + +exports.style = function(el) { + return function() { + return el.style; + }; +}; diff --git a/src/Web/CSSOM/ElementCSSInlineStyle.purs b/src/Web/CSSOM/ElementCSSInlineStyle.purs new file mode 100644 index 0000000..59af769 --- /dev/null +++ b/src/Web/CSSOM/ElementCSSInlineStyle.purs @@ -0,0 +1,16 @@ +module Web.CSSOM.ElementCSSInlineStyle + ( module Exports + , style + , fromHTMLElement + ) where + +import Effect (Effect) +import Unsafe.Coerce (unsafeCoerce) +import Web.CSSOM.Internal.Types (ElementCSSInlineStyle) as Exports +import Web.CSSOM.Internal.Types (ElementCSSInlineStyle, CSSStyleDeclaration) +import Web.HTML.HTMLElement (HTMLElement) + +foreign import style :: ElementCSSInlineStyle -> Effect CSSStyleDeclaration + +fromHTMLElement :: HTMLElement -> ElementCSSInlineStyle +fromHTMLElement = unsafeCoerce diff --git a/src/Web/CSSOM/Internal/Types.purs b/src/Web/CSSOM/Internal/Types.purs index 8f97417..1bfc112 100644 --- a/src/Web/CSSOM/Internal/Types.purs +++ b/src/Web/CSSOM/Internal/Types.purs @@ -1,4 +1,6 @@ module Web.CSSOM.Internal.Types where +foreign import data CSSStyleDeclaration :: Type foreign import data CSSStyleSheet :: Type +foreign import data ElementCSSInlineStyle :: Type foreign import data StyleSheetList :: Type