Filter blur CSS property from Dart - dart

Dart filter blur doesn't work with Safari, Chrome... Why ?
<h1>This text will blur in Firefox, not in Webkit</h1>
import 'dart:html';
import 'dart:core';
main() {
document.querySelector('h1').style.filter = 'blur(5px)';
}

Looks like Dart doesn't replace filter with -webkit-filter in Chrome but it should. There are plans to support unprefixed filter in Chrome (https://groups.google.com/a/chromium.org/forum/#!topic/blink-dev/R2gCfHjNgKs) but it's not clear when this will ship. It might be worth creating a bug report in http://github.com/dart-lang/sdk/issues/new so the prefix gets added automatically for Chrome.

Related

Can't suppress Konva warnings in Vue

I'm using Konva in a Vue application, and I can't suppress Konva's warnings in browser console.
According to Konva docs, there is an option for this, Konva.showWarnings = false. (I understood the warning itself and am aware of its possible implications).
I've checked this: Turn off Konvajs warnings, but to no avail, the answer here just explains that such a setting exists.
What I'm doing in my main.js file:
import VueKonva from 'vue-konva'
Vue.use(VueKonva)
and then I'm trying to apply the setting:
VueKonva.showWarnings = false
I've also tried adding it inside Vue.use as option:
Vue.use(VueKonva, {showWarnings: false})
...but to no avail.
What am I missing here?
You should do the same:
import Konva from 'konva';
Konva.showWarnings = false;
Are you sure you want to disable them?
edited: as the final solution to the problem, I'm adding #lavrton's comment from below:
For the showWarnings property to work in vue-konva, you need to import both the original konva library, and the vue one for vue-bindings.
The working code now looks like this:
import VueKonva from "vue-konva";
import Konva from "konva";
Konva.showWarnings = false;
Vue.use(VueKonva);
Vue.use(Konva);

codemirror - line numbers overlapped with code

I'm using codemirror latest (v5.49.0). for my electron text editor app, sometimes line numbers are rendered overlapped with the text. cannot reproduce the bug because it doesn't happen always. easily it can reproduce by refreshing the app several times. Anyone have an idea? or may be this is a known issue for you?
I was having this issue as well but what worked for me was this answer from Github.
const Editor = CodeMirror.fromTextArea(element, { lineNumbers: true });
Editor.refresh();
This answer worked for me.
import CodeMirror from 'codemirror';
import htmlembedded from 'codemirror/mode/htmlembedded/htmlembedded';
import js from 'codemirror/mode/javascript/javascript';
import 'codemirror/lib/codemirror.css';
import 'codemirror/addon/display/autorefresh';
// ...
const codeEditor = CodeMirror.fromTextArea(this.$('#isCalculatedValueTextField')[0], {
lineNumbers: true,
autoRefresh:true,
// ...
});

Angular Dart Components: cssUrl not working in Internet Explorer

I have come across this strange problem and it is driving me nuts.
It looks like a bug, but I don't know if maybe I am doing someting wrong.
The CSS attached to a component via cssUrl doesn't work on Internet Explorer.
If I add some content to the html template and I use classes from the CSS, those classes are not applied in IE. However, the same code works fine in Dartium, Chrome and Firefox.
I have created a sample project in github showing the error:
https://github.com/gonzalopezzi/ie-angulardart-shadowdom-bug
The project has the following dependencies:
dependencies:
browser: 0.10.0+2
angular: 0.11.0
shadow_dom: 0.10.0
(I have tried to avoid "any" but those are the latest versions of such packages)
I have a very simple component:
import 'package:angular/angular.dart';
#Component(selector: 'internet-explorer-bug',
templateUrl:'internet-explorer-bug/internet-explorer-bug.html',
cssUrl:'internet-explorer-bug/internet-explorer-bug.css',
useShadowDom: true,
publishAs: 'cmp')
class InternetExplorerBug {
}
This is the css file (internet-explorer-bug.css):
.red-div {
background-color: red;
}
And this is the template (internet-explorer-bug.html)
<div id="main-div">
<div class="red-div">Red background?</div>
</div>
The component works properly in Dartium, Chrome and Firefox. It doesn't show the red background in Internet Explorer, though.
I have tested it in Internet Explorer 10 and 11. These are the results:
The red background is not displayed
The browser downloads the css file (I can see that in IE dev tools)
If I inspect the DOM, I see a strange css attribute assigned to the div with the name "background-color:red" and no value:
.red-div {
background-color:red: ;
}
I have posted the same question in the mailing list (here). If I somebody helps me there I will post the solution here too.
Any help will be appreciated.
Thanks in advance.
I guess this line causes the problem
<script src="packages/shadow_dom/shadow_dom.min.js"></script>
This is deprecated. You should use
<script src="packages/web_components/platform.js"></script>
You need to change your pubspec.yaml too (shadow_dom to web_components)

Bootstrap 3 Pages Printing Mobile Version

When we print pages from our web site, which is based on Bootstrap 3, they are printing on some browsers showing the mobile version. I have Googled to try and find a good solution, but not really found anything that works.
Using the same CSS for the screen and adding the "print-hidden" class to specific DIV's our pages look fine using Safari on a Mac, but using Chrome on the Mac or Firexof and Chrome on the PC the print preview shows the mobile version.
Is there an easy way to tell the browser that the viewport width is a regular screen not a phone (XS), or do we have to incorporate a lot of complicated grid changes etc?
Adding a print media query worked for me. This is what I finally stumbled onto.
#media print {
#page {
size: 330mm 427mm;
margin: 14mm;
}
.container {
width: 1170px;
}
}
The 330mm and 427mm dimensions were just what seem to fit for my 1170px breakpoint. (They're also the 8.5/11 ration.)
EDIT: As #tony-payne said, this likely only works for Chrome. In my use case, that was fine. Just added a script with a warning about printing if not in Chrome.
<script>
(function() {
var isChromium = !!window.chrome;
var beforePrint = function() {
alert("Printing is optimized for the Chrome browser.");
};
if (window.matchMedia) {
var mediaQueryList = window.matchMedia('print');
mediaQueryList.addListener(function(mql) {
if (mql.matches && !isChromium) {
beforePrint();
}
});
}
window.onbeforeprint = beforePrint;
}());
</script>
Something that worked for me...
in bootstrap grid.scss find:
#include make-grid(xs);
then add below:
#media print {
#include make-grid(sm);
}
This is a known issue that's mentioned in the official docs:
Printer viewports
Even in some modern browsers, printing can be quirky. In particular, as of Chrome v32 and regardless of margin settings, Chrome uses a viewport width significantly narrower than the physical paper size when resolving media queries while printing a webpage. This can result in Bootstrap's extra-small grid being unexpectedly activated when printing. See #12078 for some details. Suggested workarounds:
Embrace the extra-small grid and make sure your page looks acceptable under it.
Customize the values of the #screen-* Less variables so that your printer paper is considered larger than extra-small.
Add custom media queries to change the grid size breakpoints for print media only.

Using thirdparty libraries from dart language

How can import and use any third party javascript libraries in dart..? I want to use snapsvg in my dart application to render svg. But not sure how to add dependencies to add and import it.
I added js: any to my pubspec.yaml and imported packages/browser/interop.js into my html. Where do I place downloaded snapsvg.js and import it to my dart source file to use it.
I am trying to use following javascript code using snapsvg framework from dart.
s = Snap(800, 600);
s.rect(0, 0, 100, 100).attr({
fill: 'white',
stroke: 'black'
});
I tried this code from in dart:
import 'package:js/js.dart' as js;
void main() {
var s = js.context.Snap(800, 600);
s.rect(0, 0, 100, 100);
}
This works fine in dartium, but when I Run as Javascript after build, I got javascript error "method zm not found in object"
I believe this is not right way and I should use be using callMethod on proxy. So I changed code like this
import 'dart:js' show context, JsObject;
void main() {
var snap = context['Snap'];
snap.callMethod('rect', 0,0,100,100);
}
This is not working in Dartium as itself. I would appreciate if someone can provide example of how to call constructor Snap(800, 600) from dart and also rect and attr methods in my example code.
You add them to the HTML file using <script> tags.
You can call JavaScript functions from Dart using dart-js-interop.
There are many examples here on Stackoverflow under this tag - just click on the tag below your question.
When you provide a more concrete example it is easier to help.
You can call into JavaScript with the built-in dart:js library. Please try to avoid using /package/ js, which is what you install by adding js: any to your pubspec. The js package is likely to cause the dart2js output to be bloated and we're probably going to deprecate it at some point.
You can reference JavaScript files like you would in any HTML page, via script tags. You don't actually import them into Dart source, you use dart:js to access JavaScript via its top-level context property.

Resources