Comments (6)
Hello @VerburgtJimmy if you could provide a minimal reproduction with the same base stylesheets you have described, that would help the team diagnose more.
In v8, we updated the selectors and default variable definitions and recommended that developers move their custom variables stylesheet to be imported/referenced after the primary global styles that import Ionic's global stylesheets.
You have done that with the example snippets you provided, however I would callout a few things:
- You are importing the variables stylesheet twice in your
angular.json
. - You either need to add the stylesheet references for Ionic's global styles in
angular.json
or import it with a CSS import in a global stylesheet. You do not need to do both, which you are showing in the code snippets provided.
If you can provide more information or a minimal reproduction of variables not being customizable, the team would be happy to assist further.
Thanks!
from ionic-framework.
Thanks for the response.
- they are both different files. One is scss and one is css. But the css one is empty. I can remove it just to be sure, but this changes nothing in the app.
- What is recommended to do with the global styles? Should I remove them from the global.css or from angular.js. Or doesn't this really matter?
If you can give me some time I will create a new ionic project where I will copy my own config files in there and of course my own css files to see if it also happens in a new project. If this is the case I will drop the link for the public repo here so you can reproduce the issue I am having.
from ionic-framework.
Either approach for global styles is an acceptable pattern in Angular and with Angular libraries, like Ionic Framework. They both result in similar outcomes, however the angular.json
enables developers additional customization techniques for bundling: https://angular.io/guide/workspace-config#styles-and-scripts-configuration
Here are two reproduction templates that you can review and experiment with:
- Using CSS imports: https://stackblitz.com/edit/angular-dawl1f?file=src%2Ftheme%2Fvariables.css
- Use
angular.json
: https://stackblitz.com/edit/angular-dawl1f-vwkffm?file=angular.json
In both examples the customized primary colors from your provided snippet are applied correctly.
from ionic-framework.
Sean already gave you some good examples to go by, but I will just add a few notes here, kind of a free code review based on some things I have noted working with our Enterprise customers as well as maintaining our demos.
- Having a
src/theme/variables.scss
andsrc/theme/variables.css
file is going to cause confusion for other developers on your team or for future you. Since you say thesrc/theme/variables.css
file is empty, I suggest just removing it. - According to the rules of CSS, when all else is equal the last thing specified wins. In your case, you have
src/theme/variables.scss
specified first in yourangular.json
, which means anything specified there that is specified in a later file with the same selector will get the value in the later file. - having the Ionic supplied SCSS files specified in the
global.scss
and then also in thestyles
array of theangular.json
is not only redundant, but makes the final output even harder to reason about.
My suggestions:
- reduce your
styles
specified in theangular.json
to the variables and the globals files like this: https://github.com/ionic-enterprise/tutorials-and-demos-ng/blob/main/demos/tea-taster/angular.json#L33 - make sure the variables file is last in the list as it is overriding things brought in from the globals file
- keep your global files mostly as-is, but perhaps add the appropriate dark theme handling CSS https://github.com/ionic-enterprise/tutorials-and-demos-ng/blob/main/demos/tea-taster/src/global.scss#L28
More on dark mode here: https://ionicframework.com/docs/theming/dark-mode
The other thing I always find helpful for stuff like this is to generate a new app from one of the starters and study the appropriate files.
from ionic-framework.
Just wanted to follow up on the issue. Some suggestions were shared to help address the problem. Since there hasn't been a response, I'm assuming everything's sorted out.
Feel free to reopen this if needed or start a new one if anything else comes up.
from ionic-framework.
Yes sorry. The following fixed my issue. My angular.json imported my files like this:
"styles": [
{
"input": "src/theme/variables.scss",
"inject": true
},
{
"input": "src/global.scss",
"inject": true
},
{
"input": "node_modules/@ionic/angular/css/normalize.css",
"inject": true
},
{
"input": "node_modules/@ionic/angular/css/structure.css",
"inject": true
},
{
"input": "node_modules/@ionic/angular/css/typography.css",
"inject": true
},
{
"input": "node_modules/@ionic/angular/css/core.css",
"inject": true
},
{
"input": "node_modules/@ionic/angular/css/padding.css",
"inject": true
},
{
"input": "node_modules/@ionic/angular/css/float-elements.css",
"inject": true
},
{
"input": "node_modules/@ionic/angular/css/text-alignment.css",
"inject": true
},
{
"input": "node_modules/@ionic/angular/css/text-transformation.css",
"inject": true
},
{
"input": "node_modules/@ionic/angular/css/flex-utils.css",
"inject": true
},
{
"input": "src/theme/variables.css",
"inject": true
}
],
Changing this to the following fixed my issue:
"styles": [
"src/global.scss".
"src/theme/variables.scss"
]
from ionic-framework.
Related Issues (20)
- bug: empty screen when URI is malformed HOT 3
- bug: (ionChange) event of ion-picker-column not fired on iOS devices HOT 3
- bug: Custom css in ion-datetime HOT 1
- bug: HTML Elements added via [innerHTML] to ion-label are hidden HOT 1
- bug: input navigation buttons not working in they keyboard toolbar
- bug: ion-item-sliding update error
- bug: Placeholder doesn't clear in input HOT 2
- feat: ion-select centering option HOT 2
- feat: ion-item-sliding auto close HOT 2
- bug: backdrop not shown when IonDatetime is used in IonModal HOT 3
- feat: Add shadow dom parts to ion-header, ion-toolbar HOT 6
- bug: InputInputEventDetail is not exported from ionic react HOT 3
- feat: statistic example use card HOT 3
- bug: ion-segment scrollable IOS animation bug
- ion-alert got blurred after focus on input HOT 3
- bug: Issue in Ion Title on Angular Nested Routes HOT 1
- feat: Ion-Header Styling During Astro View Transitions
- bug: Sorry, you have been blocked, You are unable to access ionicframework.com HOT 1
- bug: Ion Select, attribute : interface popover same choice displayed multiple times HOT 2
- bug: clicking the link inside the ion-checkbox toggles checkbox
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ionic-framework.