I'm using ember-emojione to display and insert emoji.
Out of four rendering options that EmojiOne offers:
PNG sprites
PNG individual images
SVG sprites
SVG individual images
...only PNG sprites suit me. Individual images take too much time to load and emoji display sequentially. SVG sprites are awesome, but rerendering the preview area causes SVG sprite emoji to flicker. Only PNG sprite emoji never flicker and display simultaneously.
Unfortunately, EmojiOne offers spritesheets only in three sizes: 64, 128 and 512 px. We need to display emoji in 20 px size.
Resizing emoji displayed via PNG sprites is problematic.
ember-emojione readme suggests this hack to resize PNG sprite emoji:
.emojione {
transform: scale(0.3125);
margin: -22px;
}
It works, but it has some disadvantages:
In certain cases, emoji appear blurred.
Text selection blows up:
The solution is to use emoji spritesheets tailored to desired size. The Deveo/emojione-png-sprites repo offers such spritesheets.
But when I include those spritesheets instead of default ones, ember-emojione emoji picker component displays incorrectly.
Question: how do I use ember-emojione with emojione-png-sprites correctly?
emojione-png-sprites relies on Sass mixins, so you'll need ember-cli-sass. If you don't want to install ember-cli-sass, you can alternatively precompile mixin invocations manually and insert resulting CSS into your app.
Decide which spritesheets to include from emojione-png-sprites.
We're gonna use 20px emoji. For retina, we'll also need double and triple size spritesheets. As 40px and 60px aren't available, we're gonna use next available ones: 48px and 64px.
Include spritesheets and the Sass file into your repo. Run these commands in your Ember app root:
bower i -S emojione-png-sprite-20=https://raw.githubusercontent.com/Deveo/emojione-png-sprites/v0.3.0/dist/sprite-20.png
bower i -S emojione-png-sprite-48=https://raw.githubusercontent.com/Deveo/emojione-png-sprites/v0.3.0/dist/sprite-48.png
bower i -S emojione-png-sprite-64=https://raw.githubusercontent.com/Deveo/emojione-png-sprites/v0.3.0/dist/sprite-64.png
bower i -S emojione-png-sprite-style=https://raw.githubusercontent.com/Deveo/emojione-png-sprites/v0.3.01/dist/style.scss
It's very important that you use a specific release version of the files, so that your dependencies are locked. Otherwise, if the repo has a breaking change, an innocent bower install will break your project.
Tell ember-emojione not to include default EmojiOne CSS and spritesheets. In your app's ember-cli-build.js:
module.exports = function (defaults) {
var app = new EmberApp(defaults, {
"ember-emojione": {
shouldImportCss: false,
shouldIncludePngSprite: false,
shouldIncludeSvgSprite: false,
shouldIncludePngImages: false,
shouldIncludeSvgImages: false
}
});
// ...
Import PNG sprites into your app.
Install broccoli-funnel:
npm install -D broccoli-funnel
In your app's ember-cli-build.js:
var Funnel = require("broccoli-funnel");
module.exports = function (defaults) {
var app = new EmberApp(defaults, {
// ...
}
});
const funnels = [
// PNG sprites
new Funnel(app.bowerDirectory + "/emojione-png-sprite-20", {
include: ['index.png'],
getDestinationPath () {
return "assets/emojione-png-sprites/sprite-20.png";
}
}),
new Funnel(app.bowerDirectory + "/emojione-png-sprite-48", {
include: ['index.png'],
getDestinationPath () {
return "assets/emojione-png-sprites/sprite-48.png";
}
}),
new Funnel(app.bowerDirectory + "/emojione-png-sprite-64", {
include: ['index.png'],
getDestinationPath () {
return "assets/emojione-png-sprites/sprite-64.png";
}
}),
];
if (app.env === "development" || app.env === "test") {
app.import(app.bowerDirectory + "/timekeeper/lib/timekeeper.js");
}
return app.toTree(funnels);
};
In your app's Sass, include the mixin and invoke it:
#import "bower_components/emojione-png-sprite-style/index.scss";
#include sprity-emojione(20, "/assets/emojione-png-sprites", (2: 48, 3: 64));
This will break the looks of ember-emojione components. The addon contains a mixin that restores the looks:
#import 'node_modules/ember-emojione/app/styles/ember-emojione';
#include ember-emojione-cancel-scale;
Related
I have a phone / iPad application. It would be useful to export text, images, or other data to other apps or other devices.
I can export the colour data as text using UIpasteboard.general.string. This works nicely. The Universal pasteboard lets me paste into other devices.
I can export an image using UIpasteboard.general.image. I have a PNG image in my bundle resources. I can the paste it into Preview or some other image viewer. I would like to be able to paste it as a file but I can't see how to do that at the other end.
I have also a PDF manual in the Bundle. It would be nice to export that too. Like the previous image, it would be nice to paste it as a file but I cannot see how this is done.
Before I get into the code, is UIpasteboard the right way to do this? Or is there some other approach I ought to be using rather than trying to fix this. What do other apps do?
Grid(horizontalSpacing: 3, verticalSpacing:3) {
GridRow {
Text("Text: ").gridColumnAlignment(.trailing).foregroundColor(.gray)
Button {
let pasteboard = UIPasteboard.general
pasteboard.string = toString(sw: sd.mySwatch)
} label: {
Text("Current swatch").lineLimit(1).frame(width:buttonW)
}.buttonStyle(.bordered)
}
GridRow {
Text("Text: ").gridColumnAlignment(.trailing).foregroundColor(.gray)
Button {
var reply: String = ""
for sw in sd.swatches {
reply = reply + toString(sw: sw)
}
UIPasteboard.general.string = reply
} label: {
Text("All swatches").lineLimit(1).frame(width:buttonW)
}.buttonStyle(.bordered)
}
GridRow {
Text("Image: ").gridColumnAlignment(.trailing).foregroundColor(.gray)
Button {
UIPasteboard.general.image = UIImage(contentsOfFile: Bundle.main.path(forResource: "Macbeth", ofType: "png")!)
} label: {
Text("Macbeth.png").lineLimit(1).frame(width:buttonW)
}.buttonStyle(.bordered)
}
GridRow {
Text("PDF: ").gridColumnAlignment(.trailing).foregroundColor(.gray)
Button {
UIPasteboard.general.url = Bundle.main.url(forResource: "ByEye", withExtension: "pdf")!
} label: {
Text("ByEye.pdf").lineLimit(1).frame(width:buttonW)
}.buttonStyle(.bordered)
}
}
That is my code. The first three options work. The last one does not because the URL is a private one for the application. I might be able to copy the file to a public directory so the URL worked but that seems like the wrong way to go about it.
Postscript:
This actually works well enough for now. I can copy stuff to the pasteboard, then paste it into an e-mail or other message to myself. This lets me get stuff out of the app without creating temporary files the I have to clean up.
I did not find a solution for the PDF or other files. I was hoping for something like this...
UIPasteboard.general.file = UIImage(contentsOfFile: Bundle.main.path(forResource: "manual", ofType: "pdf")!)
...but nothing like that exists as far as I can tell.
How to fix the problem of having the navbar as position: fixed in Sitecore 9.3. I saw some solutions on the blogs, but it only fixes the issue on the Sitecore 8 versions.
Basically when I open the partial design in Sitecore Experience Editor, I have set my navbar as position fixed in theme css file, and it shows the navbar below the scWebEditRibbon. I also saw that scWebEditRibbon is now position fixed, still it does not fix my issue since I also have position fixed on my element.
I fixed the issue by using the script provided Richard Szalay, I just changed the variable as you can see here:
Here is the script:
// Repositions a position-fixed header so that it always appears under the SC experience editor ribbon
define(["sitecore"], function (Sitecore) {
return {
priority: 50,
execute: function (context) {
// TODO: Change this CSS selector to suit your application
var FIXED_NAV_SELECTOR = '#navbar';
// the 'cross piece' is a blank div that is sized to match the iframe content (where the actual ribbon is)
var scWebEditRibbon = window.parent.document.getElementById('scWebEditRibbon');
var nav = window.parent.document.querySelector(FIXED_NAV_SELECTOR);
if (scWebEditRibbon && 'MutationObserver' in window) {
var observer = new MutationObserver(function (mutations) {
nav.style.top = scWebEditRibbon.style.height;
});
observer.observe(scWebEditRibbon, { attributes: true, attributeFilter: ['style'] });
}
}
};
});
How to make django-leaflet render with canvas?
I checked on leaflet documentation that it should use preferCanvas but there are no manual in django leaflet that shows how to do it, while var map are hidden somewhere...
Any clue
Even if you don't have access to the preferCanvas option or the renderer option of the L.Map, you can still use the renderer option of individual vector layers.
Using this in django-less, vanilla javascript would look like:
var map = new L.Map('leaflet', { /* map options */ });
var myCanvasRenderer = L.canvas();
var circle = L.circleMarker([0, 0], {
radius: 30,
renderer: myCanvasRenderer
}).addTo(map);
var line = L.polyline([[60, 10],[20, 200]], {
renderer: myCanvasRenderer
}).addTo(map);
Make sure that you're creating the L.Canvas renderer once and reusing it in all your vector layers.
You can confirm this works by using the developer tools of your web browser and noting that there is a <canvas> element inside the Leaflet map container, but there is no <svg> element to be found:
You can see this example live over here.
I am having two problems with KOgrid.
1) I could not get scroll bars in the kogrid .It is very difficult to do data entry without scroll bars.
2) I also could not get kogrid to working wihout specifying hard coded height and width.In my application I can not have a fixed height and width.
Did anybody else had the same issue ?
I tried a workaround suggestion from this thread ( using jQuery fix as last line in my viewmodel).
KO Grid Display Isseues, On resize Gird shows one row. Images also included
that just increased that size of the grid but it did not display any data . However, when I resize the page data shows up.
Below are my HTML and kogrid options ( I tried with and without paging options, Ideally I do not want to use paging )
<div data-bind="koGrid: gridOptions"
style="height: 800px; background-color: none;width: 1850px;">
</div>
self.gridOptions = {
data: self.mydatarray,
footerVisible: true,
displaySelectionCheckbox: true,
afterSelectionChange: self.RowSelectionChange,
rowHeight: 50,
selectWithCheckboxOnly: true,
enableSorting: false,
multiSelect: true,
selectedItems: self.SelectedRows,
enableColumnResize: true,
showFilter: false,
canSelectRows: true,
enablePaging: true,
pagingOptions: {
currentPage: ko.observable(1),
pageSize: ko.observable(3),
pageSizes: ko.observableArray([3, 6, 9])
},
rowTemplate: errrowtmpl,
columnDefs: [
{ field: 'Customer', displayName: 'Customer', cellTemplate: Customersddedittmpl, headerCellTemplate: headercelltmpl },
...
...
{ field: 'GenNotes', displayName: 'GenNotes', cellTemplate: simpleedittmpl, headerCellTemplate: headercelltmpl }
]
}
Please let me know if you need any more information
Thanks
Kenner Dev
I found a solution to the problems I am facing.
1) I used Jquery to add scroll bar. I added code line below as last line of my data loading function. I am not sure id this breaks any other KOGrid functionality.In my application I did some basic testing and it seems to be working fine.
$("div.kgViewport").css("overflow", "scroll");
2) I still dont know how to solve this problem 100%. It still does not work unless fixed width and height are mentioned in style. In my app I used vw and vh as opposed fixed width and height to solve the problem of making it work on all screen sizes.
<div data-bind="koGrid: gridOptions"
style="height: 73vh;overflow:scroll;width: 96vw;"></div>
I am trying to build an iOS app using Promotion. It works fine as long
as I use the build in default design. But I want to be able to style for example
the navbar as I want (different colors and different background images).
How can I do this using Promotion?
Thanks!
You can use Teacup to easily customize your views. https://github.com/rubymotion/teacup
Add teacup to your gemfile, create a file appearence.rb in app/styles/appearence.rb and paste the following code:
Teacup::Appearance.new do
style UINavigationBar, {
tintColor: UIColor.blackColor
}
style UIBarButtonItem, {
tintColor: UIColor.blackColor
}
style UITableViewCell, {
layer: { # style the layer!
shadowRadius: 3
},
backgroundView: { # style the background!
backgroundColor: UIColor.blackColor
},
imageView: { # style the imageView!
contentMode: UIViewContentModeScaleAspectFill
}
}
style UISearchBar, {
tintColor: UIColor.colorWithRed(0.733, green:0.733, blue:0.733, alpha:1)
}
end
Add this line to your app delegate before loading your views
Teacup::Appearance.apply
Hope it helps.