diff --git a/ui/packages/consul-ui/app/modifiers/css-prop.js b/ui/packages/consul-ui/app/modifiers/css-prop.js new file mode 100644 index 0000000000..2b836acd11 --- /dev/null +++ b/ui/packages/consul-ui/app/modifiers/css-prop.js @@ -0,0 +1,12 @@ +import Modifier from 'ember-modifier'; +import { inject as service } from '@ember/service'; + +export default class CSSPropModifier extends Modifier { + @service('-document') doc; + didReceiveArguments() { + const params = this.args.positional; + const options = this.args.named; + const returns = params[1] || options.returns; + returns(this.doc.defaultView.getComputedStyle(this.element).getPropertyValue(params[0])); + } +} diff --git a/ui/packages/consul-ui/app/modifiers/css-prop.mdx b/ui/packages/consul-ui/app/modifiers/css-prop.mdx new file mode 100644 index 0000000000..2ddf1bead5 --- /dev/null +++ b/ui/packages/consul-ui/app/modifiers/css-prop.mdx @@ -0,0 +1,25 @@ +# css-prop + +Get the value for a single specific CSS Property from the modified element. +`returns` can be specified either as a second parameter or an option. + +```hbs preview-template +
--red-500: {{this.red}}
+