I read the customisation document, saying that we can change any variable we want in the ionic dist file “_variables.scss”.
It does work like a charm, but is there a simple way not to alter this original file ?
Problem is of course, I need to merge my file when there is a new release
Thanks !
Hello,
I tried that, but you need to override both the variabes and the rules that use the variables … not very effective work Plus, if ever the rule is refactored in a new version, I still have to watch for changes and merge eventually.
What do you think ?
Yeah I wish there was an easy way to override the scss variables, but still have an easy way to upgrade my project as Ionic comes out with new releases. Every time Ionic comes out with a new release, I have to go back and change the _variables.scss file again with the color I want for their default variables like $positive.
As you see here, I’ve customized the positive, calm, and balanced colors. Then at the bottom I import the ionic.scss file. Since I have already defined values using !default my values now override the Ionic values. So I just compile my ionic-custom.scss file with Compass during my build and import the resulting css. For clarity, my index.html looks something like this:
<head>
<!--Import my custom Ionic css -->
<link rel="stylesheet" href='css/ionic-custom.css />
<!-- Now this file is no longer needed! -->
<!-- <link rel="stylesheet" href="assests/vendor/ionic/css/ionic.css" /> -->
</head>
Now I can simply upgrade ionic every time a new release comes out and I don’t have to change anything!
Awesome @adam! That should help a lot of people out.
One thing: the tutorial shows the ionic.scss being imported at the top of the custom app.scss file. When I try this with my setup the colors don’t get customized. I have to import it after my color customization.
So clearly even if I put my own color befor the @import, I cannot override the ionic variable.
What I did is a myapp-variables.sccs containing the variables I want to override. Then in ionic.sccs I import it this way:
you can only overwrite some variables.
Not all variables in the ionic “variables.scss” have the !default flag.
Buuuut you can overwrite only variables with the !default flag in the way “jeff_french” described.
Why does ionic not allow to overwrite all variables? It makes no sense i think.
Nobody has time to make ugly changes directly in the ionic scss files or wants to merge the changes after each upgrade. So it is nice that ionic is written in scss, but the developer has no effort of that…
I am having the same problems after a fresh install on 05/09/2014 through npm.
I am attempting to link the css file generated from the scss directory in my index.html. Then once I have this I plan to override variables above the @import "www/lib/ionic/scss/ionic"; in the ionic.app.scss file as suggested above.
Here’s what I did:
Started a new project with ionic start test-app-1 sidemenu
Updated index.html to link css to css/ionic.app.css" rather than lib/ionic/css/ionic.css
Generated css file from scss provided in start command sass scss/ionic.app.scss:www/css/ionic.app.css from command line.
Got an error:
Syntax error: Invalid CSS after "...ionicons.scss",": expected uri, was "// Variables"
on line 7 of ./test-app-1/www/lib/ionic/scss/ionic.scss
from line 25 of scss/ionic.app.scss
So I guess I was running an older version of ionic. Once I updated to the newest version of ionic sudo npm install -g ionic and created a new project I found the answer in the README.md of the project in the “Using Sass (optional)” section.
Hey all, I know this is pretty old, but here’s the method I’ve used to deal with this. First, I removed the ionic stylesheet from my html file. Then I changed my app.scss file to look like this:
This is an exact copy of the ionic.scss file except I’ve imported my own overrides file and added the font path variable to the top. Now I just put all of my overrides in that file and sass watch it, and it’s all good.