Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vue.material.registerTheme causes an error #1454

Closed
larrymacbarry opened this issue Jan 28, 2018 · 15 comments
Closed

Vue.material.registerTheme causes an error #1454

larrymacbarry opened this issue Jan 28, 2018 · 15 comments
Labels

Comments

@larrymacbarry
Copy link

larrymacbarry commented Jan 28, 2018

Trying to register my theme:

Vue.use(VueMaterial);

Vue.material.registerTheme( 'default', { primary: 'red' } );

And it causes a next error:

Uncaught TypeError: _vue2.default.material.registerTheme is not a function

@Samuell1
Copy link
Member

Samuell1 commented Jan 28, 2018

Do you have Vue in your project? What version of vue-material you using?

@czy1996
Copy link

czy1996 commented Jan 29, 2018

I have the same issue, my vue version is 2.5.2 and vue material version is 1.0.0-beta-7

@VdustR
Copy link
Member

VdustR commented Jan 29, 2018

Vue.material.registerTheme is for old version.

You have to use new API for 1.0.0-beta-7.

@czy1996
Copy link

czy1996 commented Jan 29, 2018

Thanks a lot!

@larrymacbarry
Copy link
Author

If I want use several themes in my app:

@include md-register-theme("yellow", (
primary: md-get-palette-color(yellow, A400), // The primary color of your application
accent: md-get-palette-color(yellow, A200) // The accent or secondary color
))

@include md-register-theme("indigo", (
primary: md-get-palette-color(indigo, A400), // The primary color of your application
accent: md-get-palette-color(indigo, A200) // The accent or secondary color
))

How could I force change theme on my app?
There is no compilied styles for "indigo" and "yellow", only for "default"

@Samuell1
Copy link
Member

Do you using SCSS? @larrymacbarry

@larrymacbarry
Copy link
Author

Yes. I wanna change color themes in app using js methods in a components

@Samuell1
Copy link
Member

@larrymacbarry do you have included theme engine? like is in docs?

@larrymacbarry
Copy link
Author

yes:

@import "~vue-material/dist/theme/engine";

@include md-register-theme("default", (
primary: md-get-palette-color(red, A400), // The primary color of your application
accent: md-get-palette-color(red, A200) // The accent or secondary color
))

@include md-register-theme("yellow", (
primary: md-get-palette-color(yellow, A400), // The primary color of your application
accent: md-get-palette-color(yellow, A200) // The accent or secondary color
))

@include md-register-theme("indigo", (
primary: md-get-palette-color(indigo, A400), // The primary color of your application
accent: md-get-palette-color(indigo, A200) // The accent or secondary color
))

@import "~vue-material/dist/theme/all"; // Apply the theme

It's working as I change colors for "default"

How to apply my 'indigo' theme dynamically in component on emit event callback?

@Samuell1
Copy link
Member

@larrymacbarry you can apply theme to components with md-theme prop

@larrymacbarry
Copy link
Author

larrymacbarry commented Jan 29, 2018

I get it. Thx, It will be fine to include that string to https://vuematerial.io/themes/configuration
with example.

@paraself
Copy link

paraself commented Feb 14, 2018

@Samuell1
Like this?

<md-app md-theme="default">
</md-app>

Tried, but did not work.
Could you demonstrate how to change theme dynamically ? Many thanks!

@Samuell1
Copy link
Member

Samuell1 commented Feb 14, 2018

@paraself yes like that but md-app doesnt have that, only other components or you can change theme globally with

this.$material.theming.theme = 'myTheme'

@paraself
Copy link

this.$material.theming.theme = 'myTheme'

Thanks, this is exactly that I am looking for!

@adityatandon007
Copy link

adityatandon007 commented Oct 4, 2018

@samuel1 I am looking to switch between default theme and dark theme for my entire app and I couldn't figure out how to do this. Here is my App.vue:
<template><div id="app"><md-app><div><md-switch v-model="isDark">Toggle dark theme</mdswitch></div></md-app></div> </template>

and here is the script file
<script> export default { name: 'app', data () { return { isDark: false } } } </script>

I want to use that switch to toggle the theme of <md-app> . How to do this. Any help would be great because I couldn't find in the docs how to do this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants