The button background is red, when it should be green
i.e. the conditional styling controlled by :host-context is not activated?
Child component styles commander.scss
commander {
button {
background-color: red;
}
:host-context(.enough-space) .btn-theme {
background-color: green;
}
}
Child component template commander.html
<button class="btn-theme" (click)="demand()">{{requestText}}</button>
Host component template front.html
...
<commander (command)="requestPage()" [requestText]="requestText"></commander>
Host component code front.ts
#Component({
selector: "page-front",
templateUrl: "front.html",
host: {'class': 'enough-space'}
})
export class FrontPage {
...
}
Much of this is based on https://blog.angular-university.io/angular-ngclass-ngstyle/ so it should work - the only real differences I can see is that I have separate files for the templates and styles and I am using Angular within Ionic.
Packages used
"#angular/common": "5.0.0",
"#angular/compiler": "5.0.0",
"#angular/compiler-cli": "5.0.0",
"#angular/core": "5.0.0",
"#angular/forms": "5.0.0",
"#angular/http": "5.0.0",
"#angular/platform-browser": "5.0.0",
"#angular/platform-browser-dynamic": "5.0.0",
"ionic-angular": "3.9.0",
Works in different environment
Here is the same code in stackblitz, and it is working fine, the button is green as it should be: https://stackblitz.com/edit/ionic-host-context
The only differences I can see is that stackblitz uses Angular 4.1.3 and Ionic 3.5.2? Although I am not sure how exactly they have set up the rest of their environment.
Related
I installed storybook by using npx tsdx create
and selected react-with-storybook to make style component library.
while developing, I got 'This story is not configured to handle controls. ' error.
tsdx automatically installs all the essential addons include storybook controls.
So there's no reason to get this error.
After searching about this, I found this post.
Long story short, This error is about storybook dependency version.
They said, If I downgrade version under 6.0.9, it would works find.
So I tried, and this time I couldn't even start the project. (build failed or something).
This is my devDependencies from package.json
"devDependencies": {
"#babel/core": "^7.17.2",
"#size-limit/preset-small-lib": "^7.0.8",
"#storybook/addon-essentials": "^6.4.13",
"#storybook/addon-info": "^5.3.21",
"#storybook/addon-links": "^6.4.13",
"#storybook/addons": "^6.4.13",
"#storybook/react": "^6.4.13",
"#types/react": "^17.0.39",
"#types/react-dom": "^17.0.11",
"babel-loader": "^8.2.3",
"husky": "^7.0.4",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-is": "^17.0.2",
"size-limit": "^7.0.8",
"tsdx": "^0.14.1",
"tslib": "^2.3.1",
"typescript": "^4.5.5"
}
and What I changed were
"devDependencies": {
"#babel/core": "^7.17.2",
"#size-limit/preset-small-lib": "^7.0.8",
"#storybook/addon-essentials": "6.0.9", <<=
"#storybook/addon-info": "^5.3.21",
"#storybook/addon-links": "6.0.9", <<=
"#storybook/addons": "6.0.9", <<=
"#storybook/react": "6.0.9", <<=
"#types/react": "^17.0.39",
"#types/react-dom": "^17.0.11",
"babel-loader": "^8.2.3",
"husky": "^7.0.4",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-is": "^17.0.2",
"size-limit": "^7.0.8",
"tsdx": "^0.14.1",
"tslib": "^2.3.1",
"typescript": "^4.5.5"
}
If you know any workaround, please share! Thanks!
In my case this error was caused from another story, which had a control that had incorrect options, here is the web component
export default {
title: 'Buttons/HTMLButton',
argTypes: {
sizeClass: {
control: { type: 'select' },
options: { '': '', Huge: 'huge-size' }
},
},
};
As soon as I fixed the options to { 'Default': '', Huge: 'huge-size' } it fixed this issue.
Even though this story was completely different, but it was causing controls to disappear in a different story, at the same time the controls are available and working in the Docs tab, but in the main Canvas you will see no controls and with error This story is not configured to handle controls..
To debug this issue, I had to move all stories to a different location, bring back stories one-by-one to see which is causing the problem.
Not too often but sometimes I have faced this funny behaviour of storybook, where an issue will lead to a completely different and misleading error.
In my project, I have two scss empty login component files.
If the component loads the CSS:
styleUrls: ["./login-common.css", "./login.css"]
when I run ns run ios the compiler would throw a CSS not found error.
If I change it to SCSS
styleUrls: ["./login-common.scss", "./login.scss"]
I don't have any errors but the login screen on the simulator is blank
If I comment the styleUrls line, the login screen would be rendered.
I think I should use the .css version, and probably add/remove some dependency and probably change some config files. Any idea?
My package.json :
"devDependencies": {
"#angular/compiler-cli": "~11.2.7",
"#nativescript/ios": "8.0.0",
"#nativescript/types": "~8.0.0",
"#nativescript/webpack": "beta",
"#ngtools/webpack": "~11.2.6",
"sass-loader": "^12.1.0",
"typescript": "~4.0.0",
"webpack": "^5.49.0"
},
My webpack.config.js:
const webpack = require("#nativescript/webpack");
module.exports = (env) => {
webpack.init(env);
webpack.chainWebpack(config => {
config.module
.rule('scss')
.use('sass-loader')
.options({ sassOptions: { indentedSyntax: false } })
})
return webpack.resolveConfig();
};
You need to run
npm i sass
That will install the sass interpreter.
And add a test to your webpack config
config.module
.rule('scss')
.test( /\.s[ac]ss$/i)
.use(
// Compiles Sass to CSS
"sass-loader"
)
I cannot seem to get Firebase/Analytics to work with Nuxt.js. I don't get any errors, but when I use the I don't get any images loading.
I could use, and it loads fine. Seems to be a conflict with Nuxt/Vuetify/FirebaseAnalytics
nuxt.config.js
firebase: {
services: {
analytics: true
}
}
This creates the images to render blank. If I turn it to false, then items load as expected.
These are my dependencies
"dependencies": {
"#capacitor/cli": "^3.1.1",
"#capacitor/core": "^3.1.1",
"#capacitor/network": "^1.0.2",
"#nuxtjs/auth": "^4.9.1",
"#nuxtjs/firebase": "^7.6.1",
"#nuxtjs/pwa": "^3.3.5",
"#nuxtjs/universal-storage": "^0.5.9",
"core-js": "^3.9.1",
"firebase": "8.6.5",
"nuxt": "^2.15.3",
"vue-lodash": "^2.1.2"
},
Has anyone encounter this issue? Perhaps someone could expand if they know more? Would like to use Firebase Analytics in my setup.
Here is my file structure in sapper a project (only relevant files):
src/
-routes/
-_layout.svelte
-index.svelte
-other.svelte
-styles/
-index.css
-other.css
I import the css files by this method:
<script>
import '../styles/index.css'
</script>
I use header selector in both css files. When I route from index to other page the index.css's header styles also applied in the other.svelte page. But if I refresh in /other page in my browser it looks okay.
I want to scope my styles in a specific page. How to restrict my styles for other pages?
Here is my dependencies from package.json:
"dependencies": {
"compression": "^1.7.1",
"polka": "next",
"sirv": "^1.0.0"
},
"devDependencies": {
"sapper": "^0.28.0",
"svelte": "^3.17.3",
"#babel/core": "^7.0.0",
"#babel/plugin-syntax-dynamic-import": "^7.0.0",
"#babel/plugin-transform-runtime": "^7.0.0",
"#babel/preset-env": "^7.0.0",
"#babel/runtime": "^7.0.0",
"#rollup/plugin-babel": "^5.0.0",
"#rollup/plugin-commonjs": "^14.0.0",
"#rollup/plugin-node-resolve": "^8.0.0",
"#rollup/plugin-replace": "^2.2.0",
"#rollup/plugin-url": "^5.0.0",
"rollup": "^2.3.4",
"rollup-plugin-svelte": "^6.0.0",
"rollup-plugin-terser": "^7.0.0"
}
The simplest way to define route-specific styles is to write your css directly in the <style></style> section of your Sapper route files (in your case, index.svelte and other.svelte).
These styles will have precedence over the global.css stylesheet which is loaded from template.html (if you use the Sapper template app).
I'm struggling a lot with how to include Vuetify a default Vue.js project created using WebStorm. It's really to do with how the default Vue.js projects are set up in WebStorm rather than the editor itself as it seems to use an approach different to others I can find. I get errors of "Unknown custom element <v-alert>" (for example). I'm failing to find answers on how to do this because WebStorm's default set-up is different from all the how-tos I can find.
My App.vue file is as follows:
<template>
<div id="app">
<img alt="Vue logo" src="../../assets/logo.png">
<HelloWorld msg="Welcome to your Vue.js app"/>
<v-alert dismissible>Why does this show as an unknown custom element?</v-alert>
</div>
</template>
<script>
import HelloWorld from './components/HelloWorld.vue'
export default {
name: 'App',
components: {
HelloWorld,
}
}
</script>
<style>
#app {
font-family: Avenir, Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 60px;
}
</style>
My main.js file is as follows:
import Vue from 'vue'
import App from './App.vue'
// eslint-disable-next-line no-unused-vars
import Vuetify from "vuetify";
Vue.config.productionTip = false
new Vue({
render: h => h(App),
}).$mount('#app')
My package.json file is like so:
{
"name": "my-vue-app",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
"dependencies": {
"core-js": "^3.6.4",
"deepmerge": "^4.2.2",
"sass": "^1.26.3",
"sass-loader": "^8.0.2",
"vue": "^2.6.11",
"vuetify": "^2.2.18"
},
"devDependencies": {
"#vue/cli-plugin-babel": "~4.2.0",
"#vue/cli-plugin-eslint": "~4.2.0",
"#vue/cli-service": "~4.2.0",
"babel-eslint": "^10.0.3",
"eslint": "^6.7.2",
"eslint-plugin-vue": "^6.1.2",
"vue-template-compiler": "^2.6.11"
},
"eslintConfig": {
"root": true,
"env": {
"node": true
},
"extends": [
"plugin:vue/essential",
"eslint:recommended"
],
"parserOptions": {
"parser": "babel-eslint"
},
"rules": {}
},
"browserslist": [
"> 1%",
"last 2 versions"
]
}
I ran npm install vuetify which seemed to proceed correctly and I get no errors when building or serving it. But I don't know how to get my Vue app to import the Vuetify components.
All the documentation I can find talks about either instantiating the Vue app directly, which I'm not doing, or else if it talks about single component .vue files the examples all have module.exports which again, I don't have in the project built by WebStorm.
I've tried adding Vuetify as one of the imports in the script section of the App.vue and I've also tried setting Vuetify and v-alert as components in the components section of the App.vue file but can't get either to work. Thanks for any help.
I'm struggling a lot with how to include Vuetify a default Vue.js project created using Webstorm
Just follow the instructions from https://vuetifyjs.com/en/getting-started/quick-start/:
create a new project by either running vue create in terminal or using New > Project > Vue.js in IDE (use the default project setup)
in terminal, run vue add vuetify
My main.js file is as follows:
you didn't register Vuetify (Vue.use(Vuetify); if you don't like to follow the standard way (i.e. use vue add), try the instructions from https://vuetifyjs.com/en/getting-started/quick-start/#webpack-install