shadycss icon indicating copy to clipboard operation
shadycss copied to clipboard

Nested custom mixin css are not working as expected

Open TimvdLippe opened this issue 8 years ago • 4 comments

From @vimalraj-a on June 28, 2016 17:52

Description

:root {
  --my-app-color: red;
  --my-app-input: {
        --paper-input-container-label-focus: {
          color: var(--my-app-color);
        };
  };
}

In my element style:

paper-input {
    @apply(--my-app-input);
}

paper-input element's label focus color not changed

Live Demo

http://jsbin.com/safeyi/edit?html,output

Steps to Reproduce

Expected Results

paper-input element's label color should be red

Actual Results

paper-input element's label color is default blue

Browsers Affected

  • [x] Chrome
  • [x] Firefox
  • [ ] Edge
  • [ ] Safari 9
  • [ ] Safari 8
  • [ ] IE 11

Versions

  • Polymer: v1.5.0
  • webcomponents: v0.7.22

Copied from original issue: Polymer/polymer#3746

TimvdLippe avatar Feb 11 '18 15:02 TimvdLippe

From @jouni on September 7, 2016 12:52

Can we expect this one to be fixed at some point in the polyfill? Also, CSS standard-wise, is this supposed to work?

TimvdLippe avatar Feb 11 '18 15:02 TimvdLippe

From @cadwmaster on January 26, 2017 10:53

will be really nice +1

TimvdLippe avatar Feb 11 '18 15:02 TimvdLippe

From @jfrazzano on January 26, 2017 10:57

something like this?

var resizedMixin=(function() { "use strict"; function _startDrag(e, context) { context.target; context.target.draggable = true; context.target.style.position = "fixed"; context.offsetX = e.offsetX; var Xoff = context.offsetX = e.offsetX; var Yoff = context.offsetY = e.offsetY; document.addEventListener("mousemove", dragmeplease); document.addEventListener("mouseup", endThisPlease); function endThisPlease(omu) { document.removeEventListener("mousemove", dragmeplease); document.removeEventListener("mouseup", endThisPlease); } function dragmeplease(mp) { var _x = mp.clientX > 10 && mp.clientX < document.body.offsetWidth ? mp.clientX : mp.clientX < 10 ? 10 : mp.clientX > document.body.offsetWidth ? (document.body.offsetWidth - 25) : mp.clientX; _x = _x.toString() + 'px'; var _y = mp.clientY > 8 && mp.clientY < window.innerheight - 125 ? mp.clientY : mp.clientY < 8 ? 8 : mp.clientY > window.innerheight - 125 ? window.innerheight - 125 : mp.clientY; _y = _y.toString() + 'px'; let target = context.target != undefined ? context.target : mp.target.dataset != undefined && mp.target.dataset.dragtarget != undefined ? getTarget(mp) : mp.target.parentElement; target.style.top = _y; target.style.left = _x;

	}
}

function _resizeWidget(e, context) {
	context._X = e.clientX - context.width;
	context._Y = e.clientY - context.height;
	context.target.draggable=false;
	document.addEventListener("mousemove", resizemeplease, true);
	function endResize(omu) {
			document.removeEventListener("mousemove", resizemeplease, true);
			document.removeEventListener("mouseup", endResize);
		}
		document.addEventListener("mouseup", endResize);
	var context2=context;
	function resizemeplease(mp) {
		var _x = (mp.clientX - context._X) > 32 && (mp.clientX - context._X) < (document.body.offsetWidth - 48) ? mp.clientX - context._X : mp.clientX - context._X < 32 ? 32 : (mp.clientX - context._X) > (document.body.offsetWidth - 48) ? (document.body.offsetWidth - 64) : mp.clientX - context._X;
		_x = _x.toString() + 'px';
		var _y = (mp.clientY - context._Y) > 32 && (mp.clientY - context._Y) < (document.getElementById("dash").getBoundingClientRect().height - 64) ? mp.clientY - context._Y : mp.clientY - context._Y < 32 ? 32 : (mp.clientY - context._Y) > (document.getElementById("dash").getBoundingClientRect().height - 64) ? (document.getElementById("dash").getBoundingClientRect().height - 64) : mp.clientY - context._Y;
		_y = _y.toString() + 'px';
		context.width != undefined && context.height != undefined ? (context.height = _y, context.width = _x) : alert("grand error");
	}
}

function htmlTagToProperty(tagId, context) {

	return Object.defineProperty(context, tagId, {
		enumerable: true,
		configurable: true,
		get: function() {
			return document.getElementById(tagId);
		},
		set: function() {
			context[tagId] = document.getElementById(tagId);
		}
	});
}

function tagsToProperties(tagIdArray, context) {
	var i = 0,
		count = tagIdArray.length;
	for (i = 0; i < count; i++) {
		var property = tagIdArray[i];
		htmlTagToProperty(property, context);
	}

}

const dragtag = (targetId) => `<section data-btn="dragme" style="font-size: 24px; cursor: move; color: blue; position: absolute; left: 0px; top: 0px;" draggable drags data-target="id_${targetId}">\&#x2756;</section>`;

const resizer = (id1, id_2) => `<section id="${id1}_${id_2}" data-btn="resizeme" data-target="id_${id1}" style="font-size: 24px; cursor: nwse-resize; color: blue; position: absolute; right: 0px; bottom: 0px;z-index: 39;">\&#x21f1</section>`;

class Widget { constructor(argInit){ tagsToProperties([argInit.targetId], this); Object.defineProperties(this, { "width": { enumerable: true, configurable: true, get: function() { return document.getElementById(argInit.targetId).getBoundingClientRect().width; }, set: function(value) { document.getElementById(argInit.targetId).style.width = value; } }, "height": { enumerable: true, configurable: true, get: function() { return document.getElementById(argInit.targetId).getBoundingClientRect().height; }, set: function(value) { document.getElementById(argInit.targetId).style.height = value; } } }); this.target=argInit.targetId?this[argInit.targetId]:{}; this[argInit.targetId].addEventListener("mousedown", this, true); this.handleEvent=function(e){ var d=e.target.dataset; if(d.target!=undefined){this.getTarget(e); console.log(this.target)} switch (e.type) { case "mousedown": if(d != undefined && d.btn != undefined ){ thisd.btn; } break; }

	};
	this.initializeMixins(argInit);

} getTarget(e){ var d = e.target.dataset,split; this.target=d.target != undefined &&d.target.includes("")? (split = d.target.split(""), split[0]==="id"? document.getElementById(split[1]): e.target.parentElement): e.target.parentElement; } initializeMixins(argInit){ alert("I DID SQUAT"); } }

var dragMixin = Widget => class extends Widget { dragme(e) { _startDrag(e, this);

}

} var resizeMixin = Widget => class extends Widget { resizeme(e) { _resizeWidget(e, this);} }

On Jan 26, 2017, at 5:54 AM, Christian Andrade [email protected] wrote:

will be really nice +1

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Polymer/polymer/issues/3746#issuecomment-275360676, or mute the thread https://github.com/notifications/unsubscribe-auth/AHxnvrSbOXhEhBovjD5zLJT8rU4K-StKks5rWHtKgaJpZM4JAXFK.

TimvdLippe avatar Feb 11 '18 15:02 TimvdLippe

From @craPkit on July 19, 2017 14:22

This kind of works, if you a) happen to know the specific element you want to style and it b) lives inside your own component's shadow DOM:

  paper-dropdown-menu

  /* /deep/ paper-input */
  /* the deep selector is redundant here, since the mixin will be forwarded anyway, magically */
  {
    --paper-input-error: {
      white-space: normal;
    }
  }

My original, naïve, retracted comment:

There are some PolymerElements which cannot be styled at all, due to this restriction.

<paper-dropdown-menu>, for example, instantiates a <paper-input> in its shadow DOM and provides a CSS hook --paper-dropdown-menu-input. I can style the paper-input itself just fine, but not utilise its own styling hooks from outside the paper-dropdown-menu, e.g. to style the internal error message.

TimvdLippe avatar Feb 11 '18 15:02 TimvdLippe