How to Create a Dark Ext JS Theme (part 2)

Posted on in CSS Sass

I’ve been showing you how to develop a fancy dark theme, which kind of looks like Spotify. In Part 1 of the article, you learned about Fashion, Sencha Inspector, Themes, and variables. In Part 2, I’ll focus on more advanced concepts including: making unique components with Ext JS UIs, CSS overrides, and how to incorporate custom fonts or icons.

You can use this tutorial to help you build your theme for the Sencha Application Theming Contest.
The first prize winner gets $2,500!

Sign up now

Custom CSS Rules and Mixins

There are a few more things I did in my Spotifext theme to make it look awesome. I wrote some CSS rules to animate the button hovers, used custom fonts, and created my own button and tab panel variants to give it a unique look.

With the variables I described earlier, you can change the overall look and feel of the application and all its components. But sometimes, you just want to make certain components unique. See the image below of my working Spotifinder app. You can see that the tab panel doesn’t look like the default Ext JS tabs. The buttons can be square or round, in the colors green or gray. I’m using Ext JS UIs, which are Sass mixins under the hood. A mixin is a block of CSS rules that can be re-used throughout an app.

Here’s an example Sass mixin:

@mixin my-border-radius($radius) {
  -webkit-border-radius: $radius;
     -moz-border-radius: $radius;
      -ms-border-radius: $radius;
          border-radius: $radius;
}

The above Sass mixin can be used to create rounded corners. I need to write experimental browser prefixes, so I can support this CSS3 feature across all browsers. Instead of writing every CSS rule myself, I can just include the my-border-radius mixin and pass in an argument, so all the CSS rules will be available after compilation:

.box { @include border-radius(10px); }

In the compiled CSS, it will look like this (but minified):

.box {
-webkit-border-radius: 10px;
     -moz-border-radius: 10px;
      -ms-border-radius: 10px;
          border-radius: 10px;
}

Sass mixins are a great concept that can be used in Ext JS as well. We call them UIs, and they’re basically skins. Ext JS includes out-of-the-box UIs. For example, in the modern toolkit, we have UIs for back buttons, round buttons, and more, and it provides UIs you can reuse with your own parameters.

You can find these mixins in the Sencha API Docs. For example, look at Ext.button.Button, you’ll see Sass Mixins in all different states for buttons. To implement these mixins, you’ll use @include, then the mixin name in Ext JS, and then pass in the arguments.

Ext.button.Button

To create the nice rounded buttons, take a look here.

I used the below mixin code to create a new “scale: small” button. For arguments, I passed in the UI name: “round”, which I used in my view as ui: ‘round’), a font-weight, padding and a background color:

@include extjs-button-small-ui(
    $ui: 'round',
    $font-weight: bold,
    $padding: 5px,
    $background-color: $highlight-color 
);

You might have noticed that the buttons are animated, and the tab panel that looks like Spotify is a lot different from the provided Ext JS mixins. Take a look at my sass/src folder. In this directory, I’ve written all Ext JS mixins and custom Sass rules.

Buttons

Unique Buttons

As you can see in my application, my buttons are more custom than the configuration provided by the API. My app contains code to make smooth animations. On every rollover, the button slowly lights ups. I did this by using custom Sass / CSS code.

Take a look:

.x-btn-round-large,
.x-btn-round-medium,
.x-btn-round-small {
    &:hover {
      background-color: $highlight-color2;
      -webkit-transition: background-color 2s ease-out;
      -moz-transition: background-color 2s ease-out;
      -o-transition: background-color 2s ease-out;
      transition: background-color 2s ease-out;
    }
}

The CSS class names come from the mixin. I gave my small button the ui name: “round”. After I wire up this UI to my view code, I see in my browser DOM that the UI gave the component this class name: .x-btn-‹ui-name›-small.

All Sencha components get CSS class names by default with the .x- prefix. After that, it names the component (btn), then the UI name. For a button, it will also include the scale – or, if it’s in a toolbar. See mixin extjs-button-toolbar-small-ui.

The custom code I provided listens to the button hover. When I roll my mouse over the button, it will transition the background-color from the default background color (in my case black) to a new color (the green that I set in the background-color rule).

Unique Tabs

Sometimes you don’t want to use custom CSS code to add more functionality but instead to override the default look and feel. For example, when the UI mixin doesn’t provide the configuration you are looking for.

I did this to create unique-looking tabs. See the screenshot:

The code I used can be found here. Take a look at the .x-tab-bar-alternative CSS class.

You may be wondering when to use UI mixins versus mixins. UI mixins are great because they style the full application and contain code that supports every browser supported by Ext JS. The disadvantage is that your stylesheet code will grow. This is why I typically use UI mixins for styling, and rules that are re-used throughout my application.

CSS rules and overrides are great because they can be a quick solution. The disadvantage is that it’s complicated because you’ll need to test across browsers, and you really need to understand the generated DOM. I use CSS overrides and rules in case the UI mixin doesn’t provide the configuration, or when I need the CSS rule in only a few places.

Incorporating Fonts

The last thing I did in my custom theme was incorporate custom fonts and icons (which are icon fonts). Please take a look at this file.

I included two custom fonts. One google font (from the Google font provider), and one icon font called Spotifinder that I created on this website. I selected my own icon set, and I generated a font out of it.

Both fonts are @font-face fonts, so you have to include the different font extensions for various browsers in your stylesheet. For the icon font, I had to put them in manually. See the four font extensions. Usually when you create a custom icon font on an icon website like icomoon, you’ll be able to download the stylesheet that goes with it. In my case, I could just copy & paste it, but in some cases you’ll have to write it yourself.

The google font was really easy because Sencha provides a global UI mixin. This mixin puts the code for all the extensions in your compiled CSS code by importing the code from Google. See the docs. Please note that using custom fonts from a font provider (like Google Font) requires an additional request to the font. An alternative way to do it is to download an @font-face font yourself (from a website such as http://www.fontsquirrel.com/) and provide the full import code yourself. Just like I did for the icon font.

Once your font is correctly imported, you can start using it. I’m using the Google font by pointing the $font-family variable to it here.

Conclusion
That’s it! Now, I’ve explained everything you need to know to create an awesome theme, such as the Spotifext theme. Check out the screenshot below to see how it might look in a real-life application.

Don’t forget to sign up for the Sencha Application Theming Contest. The first prize winner gets $2,500!

Spotifext theme

Resources:

Ext JS Theming Guide
My SenchaCon Presentation
Tutorial Demo Files

Create an amazing Sencha Touch theme with SASS

Posted on in CSS Sass Sencha Touch

This tutorial shows you how to build an amazing Sencha Touch 2.1 theme: Like this one.

Prerequisites:
generate your application with Sencha CMD, so you have the MVC folder structure:
[project]
- app
- - model
- - store
- - view
- - profile
- - controller
- resources
- - css
- - sass

  1. Open [project] /resources/ folder
  2. Create the following (new) folders:

- default
- spidey
- - sass
- - css
- - fonts
- - images

Download the zip file below. It contains the full theme including all the asets:
Spidey Theme.

Copy all the assets over from my attached zip; incase your default assets have no subfolder default, copy the original sass, css... folders
over to default. Note for fonts, you will need a fontface kit: .eot, svg, .ttf, .woff)

  1. Create 2 new files in the resources/spidey/sass/ folder: spidey.scss and config.rb
  2. Change the content of the config.rb file to:
# Get the directory that this configuration file exists in
dir = File.dirname(__FILE__)

# Load the sencha-touch framework automatically.
load File.join(dir, '..', '..', '..', 'touch', 'resources', 'themes')

# Compass configurations
sass_path = dir

# Require any additional compass plugins here.
relative_assets = true

fonts_path = File.join(dir, "..", "fonts")
images_path = File.join(dir, "..", "images")
css_path = File.join(dir, "..", "css")

#output settings
output_style = :compressed
environment = :production

Actually what we are doing in this config file, is setting the paths to all your Sencha Touch framework folder and relative paths to your asset folders and CSS folder.
Last but not least there are some settings, to setup the production output of the generated CSS file. In this case the code will be minified.

  1. Incase you changed the folder structure of the default style files, you will need to make sure that it's pointing to the framework folder.
    Since now you are one extra level deep, you will need the sencha-touch framework dir:
load File.join(dir, '..', '..', '..', 'touch', 'resources', 'themes')

Read more on the next page about how to setup your SASS file.

Installing SASS + Compass for Windows & OS X

Posted on in CSS Sass

I'm getting a lot of hits on this topic, on my old blog; and since I will close this blog down soon; I will copy over the content, to host it here...

Sass = Awesome.
It stands for Syntactically Awesome Stylesheets.
Basically it's CSS on Redbull. Or CSS but with tricks.
It’s an extension on CSS3 and you will also use Compass. (that’s a SASS framework that streamlines the creation of css)

You will need a .scss file and you can compile this to production ready css.

It's very easy to install Sass and Compass on your Mac. Sass is included with HAML.
To get Sass working, you'll need an installation of Ruby. On your Mac this is already done.

On your Windows environment, you'll need to install Ruby via the installer:
http://rubyinstaller.org/about/contributors/
(Make sure you will at Ruby to your class path!)

After running the setup open the commandline: (Windows run > type: CMD)
Check if ruby is installed, navigate to the Ruby bin folder, and type:

ruby -v

If you receive a prompt with the installed version number of Ruby back, then the installation went good.
You can go further...

Now type in your console the following commando's:

sudo gem install haml
sudo gem install haml-edge
sudo gem install compass

(on Windows machine it's almost the same but without the sudo command.)

check if compass is running:

compass -v

Now you can write your SASS (.scss) file.
Create in an editor style.scss or even better: start a compass project:

compass create projectname

This will create:
- A desktop stylesheet
- Print stylesheet
- A configuration file: config.rb

Interested in BluePrint? A framework for implementing CSS3?
http://www.blueprintcss.org
It will automatically deploy together with the above project files. Use this command:

compass create projectname --using blueprint/basic

To convert your SASS (development) file back to .css (production ready code) just type in your console:

sass --watch style.scss:style.css

Or to watch the whole folder:

compass watch . 

And on windows:

C:Rubybin> sass -trace D:Sassdefault.scss:D:Sassdefault.css

Or to watch the whole folder:

compass watch . 

For more info's check these links:
http://sass-lang.com/
http://compass-style.org

Start theming Sencha with SASS Compass on MAC OSX

Posted on in Sass

Install Chunky_PNG

sudo gem install chunky_png

Install Compass

sudo gem install compass

Download Sencha Touch Framework, and open in an editor

/sencha-touch-1.1.0/resources/sass/

You can edit this file now, for example add in sencha-touch.scss the following line, to add music masking icons:

@include pictos-iconmask(music1);

All icons you can create can be found in the following folder:
/sencha-touch-1.1.0/resources/themes/images/default/pictos/

Compile your Compass stylesheet to a normal .css file, to include in your page
Navigate with your terminal to sencha-touch-1.1.0/resources/sass/
Type:

compass compile

Now you can copy over the sencha-touch.css file to your project folder, with new icons.

amoxycillin viagra government funded viagra coupons 75 off cialis sample viagra samples cost of cialis viagra cost stendra vs viagra what is amoxicillin utilisation viagra does the government fund viagra amoxicillin for cats cyalis viagra coupons amox-clav 875-125 mg tablet cialis for sale online viagra axolotls otc viagra viagra pill viagra for women sildenafil vs viagra viagra pills amoxicilina cost of viagra side effects of cialis what is viagra viagra without a doctor prescription is viagra covered by insurance canadian viagra cealis amox-clav 875-125 price cialis cialis price viagra 100mg tablets retail price cialis coupons from manufacturer erectile dysfunction cialis free cialis buy cialis online generic for cialis liquid cialis cialis savings card cialis website amox clav 875 cialis tadalafil cialis free trial what does viagra do over the counter viagra amoxicillin 500 mg for sinus infection amoxicillin 875 mg axolot augmentin 875-125 cialis generic tadalafil side effects of viagra cialis coupon 20 mg cialis voucher viagra prices without insurance what is cialis cialis dosage recommendations cialis alternative walgreens viagra substitute viagra best price is viagra federally funded what is anoxia female viagra pills amox clav 875-125 natural viagra cialis coupons 2017 viagra prices viamedic cialis cialis for women mexican walking fish cialis on line sex viagra for women women viagra amoxicillin cialis daily amox cialis medication pfizer viagra how does viagra work viagra from amazon viagra on line cialis patent expiration 2017 cialis canadian pharmacy levitra vs viagra non prescribed viagra generic viagra cialis 10 mg cialis online amovil viagra without prescription cialis canada viagra patent expiration discount cialis viagra online amoxicillin uti amoxillin pfizer viagra coupons viagra without a doctor prescription usa cialis vs viagra cialis for bph cialis 20mg how much does cialis cost viagra vs cialis vs levitra cialis vs viagra cialis dosage how does cialis work cialis testimonials what is amoxicillin used for amoxicillin and clavulanate potassium 875 125 viagra pharmacy cialis or viagra sophia viagra viagra activate viagra costs cialis dosage strengths cialas cialis for daily use viagra single packs cost female viagra viagra girls amoxicillin uses viagra cialis augmentin drug class viagra sex cialis generic availability cialis pharmacy prices cialis professional how long does viagra last cialis side effects viagra coupon cialis coupons generic cialis cialis 20mg directions axlotl cilias amoxil dosage viagra porn viagra on line no prec generic cialis at walmart cialis discount viagra for sale lowest cialis prices cialis cheap amoxicillin tablets wholesale cialis online cialis buy viagra viagra viagra savings offer cialis pricing viagra price cialis 5 mg herbal viagra cialis amoxicillin 500mg capsules amoxicillian amoxil 500 mg cialis otc natural viagra alternatives that work xolotl cheap viagra cialis samples axolotyl viagra side effects trial viagra sample buy viagra online amoxicillin side effects in women buy cialis amoxicillin 500 mg cialis 5mg is viagra funded by government cialis coupons printable viagra dosage viagra alternatives where to buy viagra cialis coupon axolotl generic for viagra viagra vs cialis amoxcillin cialis pills for sale amoxicillin side effects in men canadian cialis moxil cialis patent expiration dosage of amoxicillin cialis 30 day trial coupon amoxicillin 250mg 200 cialis coupon canada cialis amoxicillin dosage axoloti generic viagra available in usa is viagra government funded viagra pills for sale viagra from canada viagra substitute how to take cialis cialis cost trimox cialis or viagra order online viagra cheap cialis amoxicillan cialis prices cialis 20 mg cialis samples overnight side effects of amoxicillin cialis 5mg daily viagra ingredients cialis pills inexpensive viagra pills side effect of amoxicillin amoxicillin dosing viagra dose amoxi cialis trial amoxil viagra generic cialis coupon print cialis for men does viagra work amoxicillin 500 mg and alcohol viagra coupons from pfizer generic viagra 100mg amoxicillin medscape augmentin 500 amox-clav 875-125 mg viagra canada cialis patent expiration date extended is viagra government funded in america amoxicillin 500mg cialis 30 day sample amoxicillin side effects tamoxifen amoxacilin daily cialis cvs pharmacy viagra coupons revatio vs viagra amox/k clav 875-125 cialis without a doctor's prescription cialis reviews amoxicillin 500 generic cialis tadalafil viagra vs cialis when will cialis go generic best price viagra anadrol mexican salamander cialis from canada free viagra cialis copay card amoxicillin rash viagra 100mg price walmart canada viagra amoxicillin trihydrate 500mg amoxicillin/clavulanic acid healthy man viagra amoxicillin clavulanate viagra single packs amoxicilin side effects of amoxicillin 500 mg cialis effects how much does viagra cost axoltl amoxin viagra government funding augmentin dosage cialis generic amoxidal discount viagra