Using Font awesome in Kendo grid - css

I use Font awesome in Kendo grid. I expect to work without problems , it shows as good as possible , Actually if I click on icon (each icon has parent) it will jump. Any idea about fixing this issue?
Here is my code:
<kendogrid
entity_id='restaurantId'
fields="{restaurantId: {editable: false, nullable: true},rgn: {required: true},type: {required: true},url: {editable: false, nullable: true}}"
controller="restaurant"
tools='false'
colmns='[
{
field: "restaurantId",
title: "id",
width: "100px",
locked: true,
lockable: true,
},
{
field: "type",
title:"type ",
width: "120px",
lockable: true,
minScreenWidth: 500,
sortable :false
},
{
field:"restaurantRateAverage" ,
title:"average ",
width: "80px",
lockable: true
},
{
title: "operation",
width: "110px",
lockable: true,
template: "
<a class=\"warning-color knd-custom-action-btn\" href=\"\\#/foods/add/${restaurantId}\" ><i class=\"fa fa-cutlery\"></i></a>
<a class=\"primary2-color knd-custom-action-btn\" href=\"\\#/delivery-zones/add/${restaurantId}/${restaurantCityId}\" ><i class=\"fa fa-map-marker\"></i></a>
<a class=\"danger-color knd-custom-action-btn k-grid-delete show-${restaurantId}\" href=\"\\#\"><span class=\"fa fa-times\"></span></a>
"
}
]'
hard-delete="true"
></kendogrid>
EDITED :
After reading this link I changed my code :
css :
#font-face {
font-family: "FontAwesome";
/*public/app/admin/assets/fonts/fontawesome-webfont.woff */
src: url("../fonts/fontawesome-webfont.woff") format("woff"),
url("../fonts/fontawesome-webfont.woff") format("truetype");
}
.km-icon:after,
.km-icon:before
{
font: 1em/1em "FontAwesome";
}
html:
{
field:"restaurantRateAverage" ,
title:"average ",
width: "80px",
lockable: true,
template: "<div data-role=\"tabstrip\">
<a data-icon=\"fa fa-check\"> </a></div>"
}
Actually it print fa fa-check and doesn't show fontawesome.

To display font-icons you need not only the font but also the correct CSS to display the correct icon. The "correct CSS" is not the same for everyone, since there are many ways to get the font.
You can get it from http://fontello.com and only select icons you really need (there are also some other services like fontello, I would advise to use on of them to only select the icons you really need)
After you get your font you have to implement it in your site. You already did this step, you declared a #font-face and used the font on your km-icon (font: 1em/1em "FontAwesome";)
Finally you need to say which icon to display for your km-icon, if you get the icons from fontello, you get a demo.html where all the unicode-codes for your CSS are stored, if you get it from the fontawesome site use this cheat sheet. You can either copy-paste the icon directly from there with the developer-tools, but since you don't have the font in your css-editor it will show up as . (or a ? or something similar, depending on what program you use)
Another way to specify it in the CSS is with the -notation, for example:
.icon-example::before{
content: '\e83e';
font-family: "Font Awesome";
}
The last way to add it is to do it like they did it on the fontawesome-site, to add the icon directly into the html, have a look at the font-awesome cheat-sheet site i linked earlier to see what I mean.

Related

Styling Mailchimp sign up form in React

I am trying to use the NPM React module for Mailchimp: https://www.npmjs.com/package/react-mailchimp-form. It works great and gives you all the forms that you may need but I am struggling to style it.
It says that you can add a personalized class for CSS styling, but how will that contain styles for all elements on the form?
Currently the form looks like this:
function MailchimpForm() {
return (
<div>
<Mailchimp
action=
fields={[
{
name: 'EMAIL',
placeholder: 'Email',
type: 'email',
required: true
},
{
name: 'COMPANY',
placeholder: 'name',
type: 'text',
required: true
}
]}
// Change predetermined language
messages={
{
sending: "Sending...",
success: "Thank you for subscribing!",
error: "An unexpected internal error has occurred.",
empty: "You must write an e-mail.",
duplicate: "Too many subscribe attempts for this email address",
button: "Subscribe!"
}
}
// Add a personalized class
className='MailchimpStyle'
/>
</div>
)
}
Where MailchimpStyle is my CSS style class. Is there a way to have multiple CSS styles in a class?
The current class looks like:
.MailchimpStyle {
clear: left;
font: 200px Helvetica, Arial, sans-serif;
}
You should be able to access the elements by specifying the elements after the className in the css sheet. Example for button:
.MailchimpStyle button {
clear: left;
color: black;
background-color: white;
margin: 2px;
}

wicked_pdf (with wkhtmltopdf) doesn’t render Font Awesome icons

I’m trying to convert an existing html document with Font Awesome icons included in pdf. I use wicked_pdf for this task. But obviously is creating a pdf some very hard task.
All Font Awesome Icons are replaced with blanks. I need some advise to make things work.
My configuration:
wicked_pdf (1.1.0)
wkhtmltopdf-binary-edge (0.12.4.0)
The generated html looks like this:
<p>
<i class="fa fa-phone"></i> +49 123 4567890
</p>
The controller action for creating the pdf:
def create_pdf
#presenter = PortfolioPDFPresenter.new(#portfolio, self)
html = render_to_string(template: 'portfolios/pdf_templates/portfolio',
layout: 'pdf_layout')
footer_html = render_to_string(template: 'portfolios/pdf_templates/footer',
layout: 'pdf_layout')
title = ActionView::Base.full_sanitizer.sanitize(#portfolio.heading.html_safe, tags: [])
pdf = WickedPdf.new.pdf_from_string(html,
title: title,
author: current_user.fullname,
page_size: 'A4',
margin: { top: 20, bottom: 40 },
print_media_type: true,
dpi: 600,
zoom: 1,
no_pdf_compression: false,
lowquality: false,
outline: { outline: true, outline_depth: 4 },
footer: { content: footer_html },
extra: '--encoding UTF8 --disable-smart-shrinking')
send_data(pdf,
filename: "#{t('activerecord.models.portfolio.one')}-#{current_user.fullname}.pdf",
disposition: 'attachment',
type: :pdf)
end # create_pdf
And finally the layout:
!!!
%html{lang: "#{I18n.locale.to_s}"}
%head
%meta{ content: 'text/html; charset=UTF-8', 'http-equiv': 'Content-Type' }
%meta{ name: 'viewport', content: 'width=device-width, initial-scale=1, shrink-to-fit=no' }
%meta{ 'http-equiv': 'Accept-CH', content: 'DPR, Viewport-Width, Width' }
%title
= t('app_title')
= csrf_meta_tags
= stylesheet_link_tag 'https://fonts.googleapis.com/css?family=Exo+2:400,700'
= stylesheet_link_tag wicked_pdf_asset_base64("pdf_styles"), media: 'print'
= stylesheet_link_tag wicked_pdf_asset_base64("pdf_styles")
= stylesheet_link_tag 'http://maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css'
%body
#main-content
= yield
Faced a similar issue myself. First I wasn't getting any icons and then subsequently, I started getting a weird W-on-top-of-M kind of icon.
Not getting any icons
Was resolved once I added the absolute CDN path to Font awesome to my pdf layout file.
https://github.com/brunzino/wpdf-icon-debug/pull/1/files?diff=split
Getting a weird W-on-top-of-M icon
This wasn't a problem on the server (Ubuntu 16.04). As in, the icon showed correctly on the production site. However on my Mac all icons were replaced by this strange icon. Never really resolved it but read somewhere that this gets resolved by installing the ttf font on the Mac.
Hope this helps

Can't get the glyph code when using gulp-iconfont

I'm trying to use gulp-iconfont to build an icon font from a set of svg images.
I've created my gulp task and there're no errors when I run it. But neither can I get the code for each icon, which is what I need to use the icons on css pseudoelements.
The console output shows strange characters where the unicode is supposed to be:
Here's my gulp task:
gulp.task('iconfont', function(){
gulp.src(['assets/icons/*.svg'])
.pipe(iconfont({
fontName: 'icon-font', // required
appendUnicode: true, // recommended option
normalize: true,
centerHorizontally: true,
fontHeight: 100,
formats: ['ttf', 'eot', 'woff'],
}))
.on('glyphs', function(glyphs, options) {
console.log(glyphs, options);
})
.pipe(gulp.dest('assets/fonts/'));
});
As the appendUnicode option is set to true, I can see it at the beggining of my svg file name, for example uEA02-calendar.svg.
However, if I try to use it on my css file:
.calendar:before {
content: "uEA02";
speak: none;
font-style: normal;
font-weight: normal;
font-family: "icon-font"; }
what I see is the text uEA02 instead of my icon. I've checked and the font is loading, I don't know what could I be missing here?
I usually pair gulp-iconfont with gulp-iconfont-css. This additional package exports a stylesheet with the appropriate entities binded to a class. You can export pre-processed css or vanilla css.
Here's my gulp task.
var iconfont = require('gulp-iconfont');
var iconfontCss = require('gulp-iconfont-css');
var glyphFontName = 'icon';
var stream = gulp.src('resources/assets/glyph/*.svg')
.pipe(iconfontCss({
fontName: glyphFontName,
path: 'node_modules/gulp-iconfont-css/templates/_icons.scss',
targetPath: '../../resources/sass/generated/' + glyphFontName + '.scss',
fontPath: '../fonts/',
cssClass: 'i',
centerHorizontally: true
}))
.pipe(iconfont({
fontName: glyphFontName,
formats: [
'ttf',
'eot',
'woff',
'woff2'
],
}))
.pipe(gulp.dest('public/fonts/'));
return stream;
You simply need to escape the unicode string with a backslash (\).
In your CSS just write:
.calendar:before {
content: "\EA02";
speak: none;
font-style: normal;
font-weight: normal;
font-family: "icon-font";
}
You need to reformat the unicode from within the function you're passing to the "on glyphs" event. Otherwise the unicode will be lost in templating.
I'd suggest something like this:
.on('glyphs', function(glyphs, options) {
glyphs = glyphs.map((glyph) => {
...glyph,
unicode: glyph.unicode[0].codePointAt(0).toString(16).toUpperCase()
});
console.log(glyphs, options);
})
Can't take credit for this solution - found the answer in this post

Style a button in EXTJS

I have a button. and i need to align it to the right, make the font size increase and bold etc. When i googled it says i should use CSS.
How can i use CSS, to style the button that i added ?
My Question :
Where should i add the CSS file in my application, and how can i use it to style the button ?
items: [
{
xtype: 'button',
align: 'right',
text:'Assign'
}
]
items: [
{
xtype: 'button',
align: 'right',
text:'Assign',
cls : 'foo'
}
]
And in a CSS file:
.foo { background:black; }
This adds a CSS class to the outer most element of the Button. There may be many elements involved in the DOM markup, so use Firebug to figure out which elements you want to style.
More details in Ext docs: http://docs.sencha.com/ext-js/4-0/#!/api/Ext.button.Button-cfg-cls

Yahoo.widget.Editor - How to configure font size of text

I am using the YUI Rich Text Editor (YAHOO.widget.Editor), and I got it working fine, except for one thing. I cannot figure out how to configure the font size of the text that I type in the editor box (input type="textarea"). I want that text to be 150%. I know that I need a CSS rule of the form:
some-YUI-related-selector {
font-size: 150%;
}
but I cannot figure out the identity of "some-YUI-related-selector".
I'd appreciate any help I can get.
Thanks, Jay
More information:
I want my web to display large fonts, so I used a CSS style for the div in question as follows:
div.newsform {
font-size:120%;
}
div.newsform input {
font-size:120%;
}
input#newsgoals {
font-size:150%;
}
The HTML page snippet in question is:
<div class="newsform">
<p>Some text</p>
<form>
<input type="text" name="sname" style="width:353px"/>
<input type="textarea" id="newsgoals" name="newsgoals" ></input><br/>
<input type="submit" value="Add" />
</form>
</div>
I bind the YUI Editor in a Javascript snippet at the bottom of the web page as follows:
<script>
var myNewSEditor = new YAHOO.widget.Editor('newsgoals', {
height: '300px',
width: '440px',
dompath: false,
animate: true,
css: YAHOO.widget.SimpleEditor.prototype._defaultCSS, // + 'html { font-size:130%; }',
// { css: YAHOO.widget.SimpleEditor.prototype._defaultCSS + 'ADD MYY CSS HERE' }
toolbar: {
titlebar: 'Write Your Goals Here',
buttons: [
{ group: 'textstyle', // label: 'Font Style',
buttons: [
{ type: 'push', label: 'Bold', value: 'bold' },
{ type: 'push', label: 'Italic', value: 'italic' },
{ type: 'push', label: 'Underline', value: 'underline' },
{ type: 'separator' },
{ type: 'select', label: 'Arial', value: 'fontname', disabled: true,
menu: [
{ text: 'Arial', checked: true },
{ text: 'Arial Black' },
{ text: 'Comic Sans MS' },
{ text: 'Courier New' },
{ text: 'Lucida Console' },
{ text: 'Tahoma' },
{ text: 'Times New Roman' },
{ text: 'Trebuchet MS' },
{ text: 'Verdana' }
]
},
{ type: 'spin', label: '22', value: 'fontsize', range: [ 9, 75 ], disabled: true },
{ type: 'separator' },
{ type: 'color', label: 'Font Color', value: 'forecolor', disabled: true },
{ type: 'push', label: 'HTML Link CTRL + SHIFT + L', value: 'createlink', disabled: true }
]
}
]
}
});
myNewSEditor.render();
</script>
The everything inside the div (class="newsform") renders the fonts at 120% large except the YUI Editor, which continues to render very small. If I used the web page without the YUI editor, the text area (input#newsgoals) renders properly at 150%.
I was able to configure colours and font sizes in the tool bar of the YUI Editor, but not in the text area box.
I even tried configuring the 'css:" attribute in the toolbar and then adding my CSS rule to _defaultCSS (as per the YUI Editor documents), but it didn't work.
Jay,
Dav Glass, the author of this component, provides great help to his users over at the YUI Library forums: http://yuilibrary.com/forum/
If you don't get an answer here, definitely try posting over there.
-Eric
Woohoo! Thanks Eric Miraglia. The pointer to Dav Glass' forum got me where I needed to go.
For some reason, I had found the css: configuration parameter which was correct, but I had done something else wrong and that caused it to fail. The correct answer is to put the following line where I have the css: when I call "new Yahoo.widget.Editor()" :
css: YAHOO.widget.SimpleEditor.prototype._defaultCSS + 'body { font-size:130%; background-color:red;color:white;}'
That was enough to get the font-size and editor background changed to what I want.

Resources