Skip to content

Add ElementCSSInlineStyle and CSSStyleDeclaration #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions src/Web/CSSOM/CSSStyleDeclaration.js
Original file line number Diff line number Diff line change
@@ -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);
};
};
};
};
22 changes: 22 additions & 0 deletions src/Web/CSSOM/CSSStyleDeclaration.purs
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions src/Web/CSSOM/ElementCSSInlineStyle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"use strict";

exports.style = function(el) {
return function() {
return el.style;
};
};
16 changes: 16 additions & 0 deletions src/Web/CSSOM/ElementCSSInlineStyle.purs
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions src/Web/CSSOM/Internal/Types.purs
Original file line number Diff line number Diff line change
@@ -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