Problem compiling SASS with Laravel Mix and Tailwind - laravel

I am trying to compile SASS files in my mix.config.js, but I have not succeeded.
talwind.config.js
const primaryColors = require("./colors");
module.exports = {
purge: [
'./resources/**/*.blade.php',
'./resources/**/*.js',
'./resources/**/*.vue',
],
darkMode: "class",
theme: {
borderColor: theme => ({
...theme("colors"),
DEFAULT: primaryColors.gray["300"]
}),
extend: {
colors: {
...primaryColors,
theme: {
1: "#1C3FAA",
2: "#F1F5F8",
3: "#2E51BB",
4: "#274AB7",
5: "#DEE7EF",
6: "#D32929",
7: "#365A74",
8: "#D2DFEA",
9: "#91C714",
10: "#3160D8",
11: "#F78B00",
12: "#FBC500",
13: "#7F9EB9",
14: "#E6F3FF",
15: "#8DA9BE",
16: "#607F96",
17: "#FFEFD9",
18: "#D8F8BC",
19: "#2449AF",
20: "#395EC1",
21: "#C6D4FD",
22: "#E8EEFF",
23: "#1A389F",
24: "#163296",
25: "#C7D2FF",
26: "#15329A",
27: "#203FAD",
28: "#BBC8FD",
29: "#284EB2",
30: "#98AFF5"
}
},
fontFamily: {
roboto: ["Roboto"]
},
container: {
center: true
},
maxWidth: {
"1/4": "25%",
"1/2": "50%",
"3/4": "75%"
},
screens: {
sm: "640px",
md: "768px",
lg: "1024px",
xl: "1280px",
xxl: "1600px"
},
strokeWidth: {
0.5: 0.5,
1.5: 1.5,
2.5: 2.5
}
}
},
variants: {
extend: {
zIndex: ["responsive", "hover"],
position: ["responsive", "hover"],
padding: ["responsive", "last"],
margin: ["responsive", "last"],
borderWidth: ["responsive", "last"],
backgroundColor: ["last", "first", "odd", "responsive", "hover", "dark"],
borderColor: ["last", "first", "odd", "responsive", "hover", "dark"],
textColor: ["last", "first", "odd", "responsive", "hover", "dark"],
boxShadow: ["last", "first", "odd", "responsive", "hover", "dark"],
borderOpacity: ["last", "first", "odd", "responsive", "hover", "dark"],
backgroundOpacity: ["last", "first", "odd", "responsive", "hover", "dark"]
}
}
};
webpack.config.js
const path = require('path');
module.exports = {
resolve: {
alias: {
'#': path.resolve('resources/js'),
},
}
};
webpack.mix.js
const mix = require('laravel-mix');
require('laravel-mix-postcss-config');
const tailwindcss = require('tailwindcss')
mix.js('resources/js/app.js', 'public/dist/js')
.sass('resources/js/assets/sass/app.scss', 'public/dist/css', {}, [
require('tailwindcss')
])
.options({
processCssUrls: false,
postCss: [
tailwindcss('./tailwind.config.js'),
]
})
.autoload({ 'cash-dom': ['$', 'cash'] })
.copyDirectory('resources/js/assets/images', 'public/dist/images')
.copyDirectory('node_modules/summernote/dist/font/summernote.woff', 'public/dist/fonts/summernote')
.browserSync({
proxy: 'evpiu.test',
files: ['resources/**/*.*']
}).webpackConfig(require('./webpack.config'));
if (mix.inProduction()) {
mix.version();
}
I'm getting the following error. Does anyone have an idea how to fix this? I have not been able to get it to work in any way. I am not a Laravel mix Expert, so it is a big problem for me.

From what the error says, I think you are not suppose to add "dark" to the variants -> extend.

Related

create slider animation with multiple traces in plotly js

I want to make create a slider animation with multiple traces in plotly js like the image below but it shows only trace 1.
when I click on the play button it only shows the first trace lines without any warning or error in the console.
I used version plotly-2-12.1.
enter image description here
let myArr = new Array(35).fill(0).map((d, i) => i + 1);
`Plotly.plot("graph", {
trace1: {
x: myArr,
y: [0, -5, 2, 5, 15, 1, 2, 5, 15, , 20, 5, 17],
type: "scatter",
id: myArr,
mode: "lines+markers",
text: "Asas",
name: "rex",
marker: {
color: "rgb(128, 0, 128)",
size: 8,
},
line: { simplify: false },
transforms: [
{
type: "filter",
operation: "<=",
target: myArr,
value: 0.0,
},
],
},
trace2: {
x: myArr,
y: [0, 10, 20, 5, 17, 80, 3, , 20, 5, 17],
text: "Asas",
name: "rex",
type: "scatter",
id: myArr,
mode: "lines+markers",
text: "as",
marker: {
color: "rgb(0, 0, 128)",
size: 8,
},
line: { simplify: false },
transforms: [
{
type: "filter",
operation: "<=",
target: myArr,
value: 0.0,
},
],
},
data: [trace1, trace2],
layout: {
xaxis: { autorange: false, range: [1, 35] },
yaxis: { autorange: false, range: [0, 100] },
updatemenus: [
{
type: "buttons",
xanchor: "left",
yanchor: "top",
direction: "right",
x: 0,
y: 0,
pad: { t: 60 },
showactive: false,
buttons: [
{
label: "Play",
method: "animate",
args: [
null,
{
transition: { duration: 500 },
frame: { duration: 500, redraw: false },
mode: "immediate",
fromcurrent: true,
},
],
},
{
label: "Pause",
method: "animate",
args: [
[null],
{
transition: { duration: 500 },
frame: { duration: 500, redraw: false },
mode: "immediate",
},
],
},
],
},
],
sliders: [
{
currentvalue: {
prefix: "t = ",
xanchor: "right",
},
pad: { l: 130, t: 30 },
transition: {
duration: 500,
},
steps: myArr.map((t) => ({
label: t,
method: "animate",
args: [
[t],
{
transition: { duration: 500 },
frame: { duration: 500, redraw: false },
mode: "immediate",
},
],
})),
},
],
},
frames: myArr.map((t) => ({
name: t,
data: [{ "transforms[0].value": t }],
})),
});`
enter image description here

chartJS not showing the data

I am new to Laravel and ChartJS. Working on home project for farm management. I need to show annual milk generation ( monthwise) in chart. While Trying to show data in chartJS but not able to show the same.
The code is as below.
Data for Chart
var buffalototalmilkannual = JSON.parse('{!! json_encode($annualmilkrecord) !!}');
var monthsforbuffalototalmilkannual = JSON.parse('{!! json_encode($getmonths) !!}'); // Annual dates on x axis
//console.log(buffalototalmilkannual);
Chart
$(function () {
'use strict'
var annualbuffaloidmilkCanvas = $('#buffaloidmilkchartforyear').get(0).getContext('2d')
var annualbuffaloidmilkdata = {
labels: monthsforbuffalototalmilkannual,
datasets: [
{
label: 'Total Milk Prodcued',
backgroundColor: 'rgba(40, 167, 69, 0.9)',
borderColor: 'rgba(40, 167, 69, 0.8)',
pointRadius: false,
pointColor: '#3b8bba',
pointStrokeColor: 'rgba(40, 167, 69, 1)',
pointHighlightFill: '#fff',
pointHighlightStroke: 'rgba(40, 167, 69, 1)',
fill: false,
tension: 0.1,
pointRadius: 3,
data: 'buffalototalmilkannual',
},
]
}
var annualbuffaloidmilkOptions =
{
maintainAspectRatio: false,
responsive: true,
legend: { display: true },
scales:
{
xAxes: [{
gridLines: {
display: true,
},
type: 'time',
time: {
unit: 'month',
tooltipFormat: 'M Y'
}
}],
yAxes: [{
gridLines: {
display: true,
},
scaleLabel: {
display: true,
labelString: 'Milk in Liter'
},
ticks: {
suggestedMin: 0,
suggestedMax: 50
}
}],
},
tooltips: {enabled: true},
}
// This will get the first returned node in the jQuery collection.
// eslint-disable-next-line no-unused-vars
var salesChart = new Chart(annualbuffaloidmilkCanvas,
{
type: 'line',
data: annualbuffaloidmilkdata,
options: annualbuffaloidmilkOptions
}
)
})
Console.log file
Array(12)
0: "12.00"
1: "11.75"
2: 0
3: 0
4: 0
5: 0
6: 0
7: 0
8: 0
9: 0
10: 0
11: 0
length: 12
Did i miss something. Same code is working in another blade file for other data.
Thanks in Advance

Laravel Mix and Tailwind CSS

I installed Tailwind using a tutorial and tried working around with a custom tailwind config file, but when I try to add first, last, or group pseudo-classes, it doesn't affect the CSS. I also previously noticed this with inset, and I added the inset section manually. Am I missing anything in config or Mix?
Tailwind config file
const { rotate } = require('tailwindcss/defaultTheme');
const defaultTheme = require('tailwindcss/defaultTheme');
module.exports = {
purge: [
'./vendor/laravel/jetstream/**/*.blade.php',
'./storage/framework/views/*.php',
'./resources/views/**/*.blade.php',
],
purge: [],
darkMode: false, // or 'media' or 'class'
theme: {
cursor: {
'none': 'none'
},
opacity: {
'0': '0',
'25': '.25',
'50': '.5',
'75': '.75',
'10': '.1',
'20': '.2',
'30': '.3',
'40': '.4',
'50': '.5',
'60': '.6',
'70': '.7',
'80': '.8',
'90': '.9',
'100': '1',
},
zIndex: {
'-1' : -1,
'0': 0,
'10': 10,
'20': 20,
'30': 30,
'40': 40,
'50': 50,
'25': 25,
'50': 50,
'75': 75,
'100': 100,
'auto': 'auto',
},
inset: (theme, { negative }) => ({
auto: 'auto',
...theme('spacing'),
...negative(theme('spacing')),
'1/2': '50%',
'1/3': '33.333333%',
'2/3': '66.666667%',
'1/4': '25%',
'2/4': '50%',
'3/4': '75%',
full: '100%',
'-1/2': '-50%',
'-1/3': '-33.333333%',
'-2/3': '-66.666667%',
'-1/4': '-25%',
'-2/4': '-50%',
'-3/4': '-75%',
'-full': '-100%',
}),
colors: {
white:'#ffffff',
gray: {
100: "#D2D2D2",
200: "#BCBCBC",
300: "#A5A5A5",
400: "#8F8F8F",
500: "#797979",
600: "#626262",
700: "#4C4C4C",
800: "#353535",
900: "#1F1F1F",
},
orange: {
100: "#FFDFCC",
200: "#FFCFB3",
300: "#FFBF99",
400: "#FFB080",
500: "#FFA066",
600: "#FF904D",
700: "#FF8033",
800: "#FF701A",
900: "#FF6000",
},
},
rotate:{
'-180': '-180deg',
'-90': '-90deg',
'-45': '-45deg',
'0': '0',
'45': '45deg',
'90': '90deg',
'135': '135deg',
'180': '180deg',
'270': '270deg',
'360': '360deg'
},
borderWidth: {
DEFAULT: '1px',
'0': '0',
'2': '2px',
'3': '3px',
'4': '4px',
'6': '6px',
'8': '8px',
'10': '10px',
'12': '12px',
'14': '14px',
'16': '16px'
},
extend: {
height:{
'5.5/6': '91.6667%'
},
fontFamily: {
sans: ['Arial', ...defaultTheme.fontFamily.sans],
},
transitionDuration: {
'2000': '2000ms',
'3000' : '3000ms',
},
transitionProperty: {
'top': 'top',
'left': 'left',
},
lineHeight:{
12 : '3rem',
13: '3.25rem',
14: '3.5rem'
},
},
},
variants: (theme) => ({
...theme('variants'),
padding: ['first','last'],
margin: ['first','last'],
backgroundColor: ['first'],
textColor: ['first'],
outline: ['active','focus'],
position: ['first','last'],
opacity: ['responsive', 'hover', 'focus', 'disabled'],
borderRadius: ['hover', 'focus'],
width:['group-hover']
}),
plugins: [
require('#tailwindcss/ui'),
],
};
Laravel Mix File
const mix = require('laravel-mix');
const atImport = require('postcss-import');
const tailwindcss = require('tailwindcss');
mix.browserSync('localhost:8000');
/*
|--------------------------------------------------------------------------
| Mix Asset Management
|--------------------------------------------------------------------------
|
| Mix provides a clean, fluent API for defining some Webpack build steps
| for your Laravel applications. By default, we are compiling the CSS
| file for the application as well as bundling up all the JS files.
|
*/
mix.js('resources/js/app.js', 'public/js')
.js('resources/js/admin.js','public/js')
.sass('resources/scss/app.scss', 'public/css')
.sass('resources/scss/admin.scss','public/css')
.options({
processCssUrls: false,
postCss: [
atImport(),
tailwindcss('./tailwind.config.js')
],
})
.webpackConfig(require('./webpack.config'));
I am not an expert in this but have used Tailwind CSS from pre V1. I notice that you are trying to use features from V2, (eg darkmode).
Several issues:
purge: [
'./vendor/laravel/jetstream/**/*.blade.php',
'./storage/framework/views/*.php',
'./resources/views/**/*.blade.php',
],
purge: [],
does the second purge: [ ] clear the first array?
My tailwind.config.js file does not have the first 2 lines ending with require('tailwindcss/defaultTheme');
I have no idea what these are referencing, but do you not have your source folders for js included in the purge list. Add this line to the purge list if your javascript adds classes
.resources/js/**/*.js
As for the webpack.mix.js file my last lines are
.options({
processCssUrls: false,
postCss: [ tailwindcss('./tailwind.config.js') ],
});
Sorry but I am not an expert

How to pass data in Laravel with Chart.js

I want to display total of men and woman from learnings table in chart using Chartjs in Laravel.
My controller
public function index()
{
$men_learning = DB::table('learnings')->where('active', 1)->whereYear('created_at', $year)->sum('men');
$women_learning = DB::table('learnings')->where('active', 1)->whereYear('created_at', $year)->sum('women');
$learning = $men_learning + $women_learning ;
return view('home', compact('learning'));
}
My script in blade view.
<script>
var ctx = document.getElementById('myChart').getContext('2d');
var myChart = new Chart(ctx, {
type: 'bar',
data: {
labels: ['total'],
datasets: [{
label: '# of Votes',
data: [12],
backgroundColor: [
'rgba(255, 99, 132, 0.2)',
],
borderColor: [
'rgba(255, 99, 132, 1)',
],
borderWidth: 1
}]
},
options: {
scales: {
yAxes: [{
ticks: {
beginAtZero: true
}
}]
}
}
});
</script>
How can I propagate loaded statistic from my script to the chart?
public function index()
{
$men_learning = DB::table('learnings')->where('active', 1)->whereYear('created_at', $year)->sum('men');
$women_learning = DB::table('learnings')->where('active', 1)->whereYear('created_at', $year)->sum('women');
return view('home', compact('men_learning', 'women_learning'));
}
<script type="text/javascript">
$(function(){
var ctx = document.getElementById("myChart").getContext('2d');
var myChart = new Chart(ctx, {
type: 'bar',
data: {
labels: ['Men', 'Women'],
datasets: [{
label: 'Men',
data: [{!!$men_learning!!}],
borderWidth: 2,
backgroundColor: 'rgba(40,167,69,1)',
borderWidth: 0,
borderColor: 'transparent',
pointBorderWidth: 0 ,
pointRadius: 3.5,
pointBackgroundColor: 'transparent',
pointHoverBackgroundColor: 'rgba(254,86,83,.8)',
},
{
label: 'Women',
data: [{!!$women_learning!!}],
borderWidth: 2,
backgroundColor: 'rgba(220,53,69,.8)',
borderWidth: 0,
borderColor: 'transparent',
pointBorderWidth: 0,
pointRadius: 3.5,
pointBackgroundColor: 'transparent',
pointHoverBackgroundColor: 'rgba(63,82,227,.8)',
}]
},
options: {
legend: {
display: false
},
scales: {
yAxes: [{
gridLines: {
display: true,
drawBorder: false,
color: '#f2f2f2',
},
ticks: {
beginAtZero: true,
stepSize: 100,
callback: function(value, index, values) {
return value;
}
}
}],
xAxes: [{
gridLines: {
display: false,
tickMarkLength: 15,
}
}]
},
}
});
});
</script>

Kendo bar chart- plot band in both the panes

I have a bar chart with 2 panes. I want to add plot bands in both the panes but with different color. How can this be done?
And i want to display the categories labels at the bottom of the graph. how can this be done?
Here is the jsfiddle example: http://jsfiddle.net/An59E/27/
HTML code:
<div id="chart"></div>
JS code:
var series1= [70, 60, 40, 90, -10, 50];
var series2= [-50, 40, 20, -80, 70, 80];
var series3= [70, 60, -40, 90, 10, 50];
var series4= [-50, 40, 20, -80, 70, 80];
$("#chart").kendoChart({
series:
[
{
data: series1,
color: "#00CC00",
negativeColor: "#CC0000"
},
{
data: series2,
color: "#CCCCCC"
},
{
data: series3,
axis: "bottom" ,
color: "#00CC00",
negativeColor: "#CC0000"
},
{
data: series4,
axis: "bottom" ,
color: "#CCCCCC"
}
],
categoryAxis:
[
{
pane: "top-pane",
color: "#0099FF",
majorGridLines:
{
visible: true,
},
line: {
width: 3,
},
plotBands:
[
{from: 0, to:1, color: "#CCCCCC"},
]
},
{
pane: "bottom-pane",
color: "#0099FF",
majorGridLines:
{
visible: true
},
line: {
width: 3,
},
labels:
{
margin:
{
top: 80,
bottom: 0
}
},
categories: [2005, 2006, 2007, 2008, 2009],
}
],
seriesDefaults:
{
type: "column",
labels:
{
visible: true,
color: "green"
},
},
valueAxis: [
{
pane: "top-pane",
title:
{
text: "Availability"
},
majorGridLines:
{
visible: false
},
labels:
{
visible: false,
},
line:
{
visible: false
}
},
{
pane: "bottom-pane",
name: "bottom",
title:
{
text: "Occupancy"
},
majorGridLines:
{
visible: false
},
labels:
{
visible: false,
},
line:
{
visible: false
}
}
],
panes:
[
{
name: "top-pane",
border: {
color: "#C0C0C0",
width: 1
},
},
{
name: "bottom-pane",
border: {
color: "#C0C0C0",
width: 1
}
}
],
tooltip: {
visible: true,
format: "{0}"
}
});
Thanks.
To add plot bands in both the panes:
plotBands: [
{
from: 95,
to: 100,
color: "#2082c8"
//color: "url(#pattern2)",
},
{
from: 125,
to: 130,
color: "#c82020"
}

Resources