Modifying vuetify theme with laravel - laravel

I'm having trouble with updating the color of my vuetify theme. I tried this method but it is not updating my button color.
App.js
require('./bootstrap');
window.Vue = require('vue');
import Vue from 'vue';
import Vuetify from 'vuetify';
import 'vuetify/dist/vuetify.min.css'
Vue.use(Vuetify, {
theme: {
primary: '#ff0000',
secondary: '#ff0000',
accent: '#ff0000',
error: '#ff0000'
}
});
// components here
const app = new Vue({
el: '#app',
vuetify: new Vuetify()
});
Component.vue
<template v-slot:activator="{ on }">
<v-btn color="primary" dark class="mb-2" v-on="on">Add Department</v-btn>
</template>
Main.blade.php
<div id="content-wrapper" class="d-flex flex-column">
<div id="content" class="bg-white" style="background-color:white!important;">
#include('layouts.topbar')
<div class="container-fluid">
<v-app id="app">
#yield('content') //This is where my components are located
</v-app>
</div>
</div>
#yield('DashboardView-main-footer')
</div>

You should use v-app vuetify tag like
Component.vue
<template v-slot:activator="{ on }">
<v-app>
<v-btn color="primary" dark class="mb-2" v-on="on">Add Department</v-btn>
</v-app>
</template>

That's because you have to change the light theme, which I assume you're using since you haven't put dark to true.
Vue.use(Vuetify, {
theme: {
themes: {
light: {
primary: '#ff0000',
secondary: '#ff0000',
accent: '#ff0000',
error: '#ff0000'
}
}
}
});

Related

How to show ajax result in v-menu content on mouse over?

I have v-menu attached icons on my page.
I want to show detail info on mouse over of any icon (like tooltip).
But, content should be dynamically get with ajax request.
How can I trigger ajax request on mouse over and show result on v-menu content?
[UPDATE]
using v-menu with open-on-hover shall be enough for that purpose
new Vue({
el: '#app',
vuetify: new Vuetify(),
data: () => ({
items: [{name: 'php', menu: false, url: 'https://api.mocki.io/v1/b043df5a' }, {name: 'mysql', menu: false, url: 'https://api.mocki.io/v1/b043df5a'}, {name: 'vuejs', menu: false, url: 'https://api.mocki.io/v1/b043df5a'}],
fav: true,
message: false,
hints: true,
serverTooltips: []
}),
watch: {
items: {
deep: true,
handler: function (val) {
console.log(val)
val.map((item) => {
if (item.menu === true) {
axios.get(item.url).then(({data}) => {
this.serverTooltips = data
})
}
})
},
}
},
})
<head>
<link href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/#mdi/font#4.x/css/materialdesignicons.min.css" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/vuetify#2.x/dist/vuetify.min.css" rel="stylesheet">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, minimal-ui">
</head>
<body>
<div id="app">
<v-app>
<div class="text-h4">Please mouse over those buttons to see events in Cities</div>
<p>Main code is copied from <a href='https://vuetifyjs.com/en/components/menus/#popover-menu'>vuetify popover-menu example</a></p>
<div class="mb-2" v-for="item in items">
<v-menu v-model="item.menu"
:close-on-content-click="false"
:open-on-hover="true"
:nudge-width="200"
offset-x>
<template v-slot:activator="{ on, attrs }">
<v-btn
color="indigo"
dark
v-bind="attrs"
v-on="on">
Mouse over to see {{ item.name }} events
</v-btn>
</template>
<v-card v-if="serverTooltips.length">
<v-list>
<v-list-item>
<v-list-item-avatar>
<img src="https://cdn.vuetifyjs.com/images/john.jpg" alt="John">
</v-list-item-avatar>
<v-list-item-content>
<v-list-item-title>Detail for {{ item.name }}</v-list-item-title>
<v-list-item-subtitle>Detail subtitle</v-list-item-subtitle>
</v-list-item-content>
<v-list-item-action>
<v-btn :class="fav ? 'red--text' : ''" icon #click="fav = !fav">
<v-icon>mdi-heart</v-icon>
</v-btn>
</v-list-item-action>
</v-list-item>
</v-list>
<v-divider></v-divider>
<v-list>
<v-list-item>
<v-list-item-action>
<v-switch v-model="message" color="purple"></v-switch>
</v-list-item-action>
<v-list-item-title>Enable messages</v-list-item-title>
</v-list-item>
<v-list-item>
<v-list-item-action>
<v-switch v-model="hints" color="purple"></v-switch>
</v-list-item-action>
<v-list-item-title>Enable hints</v-list-item-title>
</v-list-item>
</v-list>
<div v-if="serverTooltips.length">
{{ item.name }} located in cities:
<v-list>
<v-list-item v-for="(tooltip, index) in serverTooltips" :key="index">
<v-list-item-title>{{ tooltip.city }}</v-list-item-title>
</v-list-item>
</v-list>
</div>
<p v-else>Fetching data, please wait!</p>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn text #click="menu = false">
Cancel
</v-btn>
<v-btn color="primary" text #click="menu = false">
Save
</v-btn>
</v-card-actions>
</v-card>
</v-menu>
</div>
</v-app>
</div>
<script src="https://cdn.jsdelivr.net/npm/vue#2.x/dist/vue.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vuetify#2.x/dist/vuetify.js"></script>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
</body>
Anyway I advise you to cache your json information because hover event may be a little aggressive, specially if you're using mobile data.

Vuetify How add <br> to v-text-field error-messages

I want to display new line, I use tag but not work.
The original idea was to new a component, and then customize error-messages to div, But it’s too much trouble, so come to ask if there is an easy way
Vue.use(Vuetify);
var vm = new Vue({
el: "#app",
methods: {
},
data: {
}
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.4.3/vue.js"></script>
<script src="https://unpkg.com/vuetify#0.14.8/dist/vuetify.min.js"></script>
<link rel=stylesheet type="text/css" href="https://unpkg.com/vuetify#0.14.8/dist/vuetify.min.css">
<div id="app">
<v-app dark>
<v-text-field
label="Field"
error-messages="aaa<br>bbb"
></v-text-field>
</v-app>
</div>
This is a possible solution.
https://jsfiddle.net/ue9rqcwk/
HTML:
<div id="app">
<v-app dark>
<v-text-field
class="multiline"
label="Field"
error-messages="aaa
bbb"
></v-text-field>
</v-app>
</div>
css:
.multiline {
white-space: pre-line;
}
EDIT: Corrected URL

Change default font color for navigation-drawer and toolbar

I would like to define the default font-color for the navigation-drawer and toolbar.
I looked at changing colors through theming: https://vuetifyjs.com/en/customization/theme
Aswell as overriding scss defaults: https://vuetifyjs.com/en/customization/sass-variables
But nowhere can i find changing the needed setting.
Playground: codepen io/timar/pen/WNvxOYB
The Vuetify CSS has multiple color classes for background as well as text. The format for the text color classes are in the format of: .[color]--text. There is also various flavoring for lighten, darken and accent in the format of: .text--lighten-2, for example. The naming of colors and such can be found at the Vuetify Colors page.
What I have shown below, essentially forking the codepen in the OP, illustrates a method, customColor, to return a CSS class to set the text color based on the item.title value that is called on v-list-item-title.
Vue.config.productionTip = false;
new Vue({
el: '#app',
vuetify: new Vuetify(),
data () {
return {
items: [
{ title: 'Dashboard', icon: 'mdi-view-dashboard' },
{ title: 'Photos', icon: 'mdi-image' },
{ title: 'About', icon: 'mdi-help-box' },
],
right: null,
}
},
methods: {
customColor(text) {
return (text === 'Photos') ? 'green--text' : '';
}
}
})
<link href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900" rel="stylesheet"/>
<link href="https://cdn.jsdelivr.net/npm/#mdi/font#4.x/css/materialdesignicons.min.css" rel="stylesheet"/>
<link href="https://fonts.googleapis.com/css?family=Material+Icons" rel="stylesheet"/>
<link href="https://cdn.jsdelivr.net/npm/vuetify#2.1.14/dist/vuetify.min.css" rel="stylesheet"/>
<script src="https://cdn.jsdelivr.net/npm/vue#2.x/dist/vue.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vuetify#2.x/dist/vuetify.js"></script>
<div id="app">
<v-app id="inspire">
<v-card
height="400"
width="256"
class="mx-auto"
>
<v-navigation-drawer permanent>
<v-list-item>
<v-list-item-content>
<v-list-item-title class="title">
Application
</v-list-item-title>
<v-list-item-subtitle>
subtext
</v-list-item-subtitle>
</v-list-item-content>
</v-list-item>
<v-divider></v-divider>
<v-list
dense
nav
>
<v-list-item
v-for="item in items"
:key="item.title"
link
>
<v-list-item-icon>
<v-icon>{{ item.icon }}</v-icon>
</v-list-item-icon>
<v-list-item-content>
<v-list-item-title
:class="customColor(item.title)"
>{{ item.title }}</v-list-item-title>
</v-list-item-content>
</v-list-item>
</v-list>
</v-navigation-drawer>
</v-card>
</v-app>
</div>

Cannot read property 't' of undefined using Vuetify and Laravel

Getting this error when attempting to use a Vuetify component out of the box. Perhaps just my lack of understanding how to implement Vuetify components in Laravel.
Laravel v5.8.35, Vue v2.6.10, Vuetify v2.0.18.
error:
[Vue warn]: Error in render: "TypeError: Cannot read property 't' of
undefined"
found in
---> < VSelect >
< Test > at resources/js/components/Test.vue
< Root >
app.js
require('./bootstrap');
window.Vue = require('vue');
Vue.component('example-component', require('./components/ExampleComponent.vue').default);
import Vuetify from 'vuetify';
Vue.use(Vuetify);
Vue.component('test', require('./components/Test.vue').default);
const app = new Vue({
el: '#app',
});
layouts/vue.blade.php
<!DOCTYPE html>
<html>
<head>
<title>Vue Examples</title>
<meta name="csrf-token" content="{{ csrf_token() }}">
</head>
<body>
<div id="app">
#yield("content")
</div>
<script src="{{ asset('/js/app.js') }}"></script>
</body>
</html>
test.blade.php
#extends('layouts.vue')
#section('content')
<test></test>
#endsection
components/Test.vue
<template>
<v-container fluid>
<v-row align="center">
<v-col class="d-flex" cols="12" sm="6">
<v-select
:items="items"
label="Standard"
></v-select>
</v-col>
<v-col class="d-flex" cols="12" sm="6">
<v-select
:items="items"
filled
label="Filled style"
></v-select>
</v-col>
<v-col class="d-flex" cols="12" sm="6">
<v-select
:items="items"
label="Outlined style"
outlined
></v-select>
</v-col>
<v-col class="d-flex" cols="12" sm="6">
<v-select
:items="items"
label="Solo field"
solo
></v-select>
</v-col>
</v-row>
</v-container>
</template>
<script>
export default {
data: () => ({
items: ['Foo', 'Bar', 'Fizz', 'Buzz'],
}),
}
</script>
As you can see, the vue file is exactly the source from Vuetify for the v-select component. Components that don't include this works:
export default {
data: () => ({
All other components (e.g. ExampleComponent) work fine.
You need to create an instance of Vuetify. e.g.:
new Vue({
el: '#app',
vuetify: new Vuetify()
})
This is documented here, though they do hide it quite a long way down the page.

How to implement vuetify in laravel?

I'm new with vuetify and i trying to implement it in laravel.
Does someone have already implement vuetify in laravel and could tell me how?
i have already install with
npm install vuetify
and try this in App.scss
#import '~vuetify/dist/vuetify.min.css';
This is my app.js file
import Vue from 'vue'
import VueRouter from 'vue-router'
import Vuetify from 'vuetify'
Vue.use(Vuetify)
Vue.use(VueRouter)
// parents componenets
Vue.component('example-component', require('./components/ExampleComponent.vue'));
Vue.component('example', require('./components/example.vue'));
import App from './views/App'
import Hello from './views/Hello'
import Home from './views/Home'
const router = new VueRouter({
mode: 'history',
routes: [
{
path: '/',
name: 'home',
component: Home
},
{
path: '/hello',
name: 'hello',
component: Hello,
},
],
});
but when i try to use some vuetify components it doesn't work.
This is my component.
<template>
<v-app id="inspire" dark>
<v-navigation-drawer
clipped
fixed
v-model="drawer"
app
>
<v-list dense>
<v-list-tile #click="">
<v-list-tile-action>
<v-icon>dashboard</v-icon>
</v-list-tile-action>
<v-list-tile-content>
<v-list-tile-title>Dashboard</v-list-tile-title>
</v-list-tile-content>
</v-list-tile>
<v-list-tile #click="">
<v-list-tile-action>
<v-icon>settings</v-icon>
</v-list-tile-action>
<v-list-tile-content>
<v-list-tile-title>Settings</v-list-tile-title>
</v-list-tile-content>
</v-list-tile>
</v-list>
</v-navigation-drawer>
<v-toolbar app fixed clipped-left>
<v-toolbar-side-icon #click.stop="drawer = !drawer"></v-toolbar-side-icon>
<v-toolbar-title>Application</v-toolbar-title>
</v-toolbar>
<v-content>
<v-container fluid fill-height>
<v-layout justify-center align-center>
<v-tooltip right>
<v-btn icon large :href="source" target="_blank" slot="activator">
<v-icon large>code</v-icon>
</v-btn>
<span>Source</span>
</v-tooltip>
</v-layout>
</v-container>
</v-content>
<v-footer app fixed>
<span>© 2017</span>
</v-footer>
</v-app>
</template>
<script>
export default {
data: () => ({
drawer: null
}),
props: {
source: String
}
}
</script>
and try this in App.scss
#import '~vuetify/dist/vuetify.min.css';
but when i try to use some vuetify components it doesn't work.
I will give you all steps to implement vuetify in laravel
-1 run npm command to install vuetify in your laravel project
npm install vuetify
-2 go to app.js file and add this code
import Vuetify from 'vuetify';
Vue.use(Vuetify);
const app = new Vue({
el: '#app',
vuetify: new Vuetify(),
});
-3 go to app.scss file and add this code
#import "~vuetify/dist/vuetify.min.css";
-4 and finally you can add this code in app.scss for vuetify fonts because if you do not add the following code you can not use vuetify fonts and it will not be displayed
#import url('https://fonts.googleapis.com/css?family=Material+Icons');
#import url('https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900');
#import url('https://cdn.jsdelivr.net/npm/#mdi/font#5.x/css/materialdesignicons.min.css');
hope this can be helpful for you
I too had the same problem which solve with this
<body>
<div id="admin" dark>
<v-app id="inspire">
....
</v-app>
</div>
<script src="{{ asset('js/app.js') }}"></script>
</body>`
in the javascript
const app = new Vue({
el: '#admin'
...
});

Resources