Headless Ui vue scripts not working on my end - laravel-mix-vue3

So I stumbled upon headless ui since tailwind ui uses this for their functionality but my code isn't working..I have successfully installed vue 3 which is a requirement for headlessui/vue but I can't get it to work on my end. This is the code I'm talking about
<template>
<div class="w-full max-w-md px-2 py-16 sm:px-0">
<TabGroup>
<TabList class="flex p-1 space-x-1 bg-blue-900/20 rounded-xl">
<Tab
v-for="category in Object.keys(categories)"
as="template"
:key="category"
v-slot="{ selected }"
>
<button
:class="[
'w-full py-2.5 text-sm leading-5 font-medium text-blue-700 rounded-lg',
'focus:outline-none focus:ring-2 ring-offset-2 ring-offset-blue-400 ring-white ring-opacity-60',
selected
? 'bg-white shadow'
: 'text-blue-100 hover:bg-white/[0.12] hover:text-white',
]"
>
{{ category }}
</button>
</Tab>
</TabList>
<TabPanels class="mt-2">
<TabPanel
v-for="(posts, idx) in Object.values(categories)"
:key="idx"
:class="[
'bg-white rounded-xl p-3',
'focus:outline-none focus:ring-2 ring-offset-2 ring-offset-blue-400 ring-white ring-opacity-60',
]"
>
<ul>
<li
v-for="post in posts"
key="post.id"
class="relative p-3 rounded-md hover:bg-coolGray-100"
>
<h3 class="text-sm font-medium leading-5">
{{ post.title }}
</h3>
<ul
class="flex mt-1 space-x-1 text-xs font-normal leading-4 text-coolGray-500"
>
<li>{{ post.date }}</li>
<li>·</li>
<li>{{ post.commentCount }} comments</li>
<li>·</li>
<li>{{ post.shareCount }} shares</li>
</ul>
<a
href="#"
:class="[
'absolute inset-0 rounded-md',
'focus:z-10 focus:outline-none focus:ring-2 ring-blue-400',
]"
/>
</li>
</ul>
</TabPanel>
</TabPanels>
</TabGroup>
</div>
</template>
<script>
import { ref } from 'vue'
import { TabGroup, TabList, Tab, TabPanels, TabPanel } from '#headlessui/vue'
export default {
components: {
TabGroup,
TabList,
Tab,
TabPanels,
TabPanel,
},
setup() {
let categories = ref({
Recent: [
{
id: 1,
title: 'Does drinking coffee make you smarter?',
date: '5h ago',
commentCount: 5,
shareCount: 2,
},
{
id: 2,
title: "So you've bought coffee... now what?",
date: '2h ago',
commentCount: 3,
shareCount: 2,
},
],
Popular: [
{
id: 1,
title: 'Is tech making coffee better or worse?',
date: 'Jan 7',
commentCount: 29,
shareCount: 16,
},
{
id: 2,
title: 'The most innovative things happening in coffee',
date: 'Mar 19',
commentCount: 24,
shareCount: 12,
},
],
Trending: [
{
id: 1,
title: 'Ask Me Anything: 10 answers to your questions about coffee',
date: '2d ago',
commentCount: 9,
shareCount: 5,
},
{
id: 2,
title: "The worst advice we've ever heard about coffee",
date: '4d ago',
commentCount: 1,
shareCount: 2,
},
],
})
return { categories }
},
}
</script>
and here's my package.json with the dependencies
"devDependencies": {
"#tailwindcss/ui": "^0.3",
"#vue/compiler-sfc": "^3.2.4",
"autoprefixer": "^9.6",
"axios": "^0.21",
"bootstrap": "^4.6.0",
"jquery": "^3.6",
"laravel-mix": "^6.0.27",
"lodash": "^4.17.19",
"popper.js": "^1.16.1",
"postcss": "^8.1.14",
"postcss-import": "^12.0",
"postcss-nested": "^4.2",
"resolve-url-loader": "^3.1.2",
"sass": "^1.32.11",
"sass-loader": "^11.0.1",
"tailwindcss": "^1.8",
"vue": "^2.6.12",
"vue-loader": "^16.5.0",
"vue-template-compiler": "^2.6.12"
},
"dependencies": {
"#headlessui/vue": "^1.4.0",
"#heroicons/vue": "^1.0.4",
"#popperjs/core": "^2.9.3",
"#tailwindcss/forms": "^0.3.3",
"vue": "^3.2.4"
}
then my app.js where I handle my vue components
require('./bootstrap');
import { createApp } from 'vue'
import example from './components/ExampleComponent.vue'
import test from './components/test.vue'
createApp({
components:{
example,
test,
}
}).mount('#app')
I really hope anyone can help me if I understand how this structure works it would be a great help moving forward on my career

So I reviewed my code and the problem is that I put 2 script tags in the header and footer so I just removed the footer script and it works perfectly

Related

Tailwind not applying background image to tag

Related:
Tailwind css backgroundImage doesn't work for me
tailwind.config.js:
module.exports = {
theme: {
...
extend: {
...
backgroundImage: {
"footer-sierpinski": "url('/bg.svg')",
},
Layout.astro:
...
<main class="flex-1 px-4">
<slot />
</main>
<!-- <img src="/bg.svg" /> --> <---- works
<!-- <div style="background-image: url('/apple-touch-icon.png');"></div> --> <--- doesn't work
<div class="text-slate-600 bg-footer-sierpinski"> <--- doesn't work
</div>
...
The image does not show regardless of format.
Tried different variations in the config file of tailwind:
/bg.svg
./bg.svg
../../public/bg.svg
/public/bg.svg
dependencies:
"devDependencies": {
"#astrojs/tailwind": "^1.0.0",
"astro": "1.1.1",
"autoprefixer": "^10.3.7",
"feed": "^4.2.2",
"prettier-plugin-astro": "^0.5.3",
"tailwindcss": "^3.1.8"
},
"dependencies": {
"#tailwindcss/aspect-ratio": "^0.4.0",
"#tailwindcss/typography": "^0.5.8",
"moment": "^2.29.4",
"rehype-autolink-headings": "^6.1.1",
"rehype-slug": "^5.0.1",
"twitter-api-client": "^1.6.1"
}
If you need to use a one-off background-image value that doesn’t make sense to include in your theme, use square brackets to generate a property on the fly using any arbitrary value.
<div class="bg-[url('/img/hero-pattern.svg')]">

alpinejs image slider first slide repeating twice and last slide not defined

I image slide on homepage http://steklo.gq/ made using alpine and there are two strange things:
First slide design-5.jpg is repeating twice on the page
It gives me error in console Uncaught ReferenceError: slide is not defined on the last slide. However image exists and last slide defined the same way as all other slides. So I cannot understand what is the problem.
Alpine Error: "ReferenceError: slide is not defined"
Expression: "slide.img"
Element: <img x-bind:src=​"slide.img" class=​"h-148 w-full lg:​h-224 object-cover" src=​"/​storage/​thumbs_xl/​slider/​1912501_1600x1200.jpg">​
handleError # app.js:18
tryCatch # app.js:18
saferEval # app.js:19
evaluateReturnExpression # app.js:187
handleAttributeBindingDirective # app.js:67
(anonymous) # app.js:186
resolveBoundAttributes # app.js:186
initializeElement # app.js:180
(anonymous) # app.js:178
(anonymous) # app.js:177
walk # app.js:16
walk # app.js:16
walk # app.js:16
walk # app.js:16
walk # app.js:16
walkAndSkipNestedComponents # app.js:176
initializeElements # app.js:178
(anonymous) # app.js:192
(anonymous) # app.js:191
attributes (async)
addClass # app.js:926
Slick.init # app.js:2702
Slick # app.js:2646
$.fn.slick # app.js:2798
(anonymous) # app.js:367
<x-slot name="mainslider">
<div class="mainslider_container absolute w-full h-full top-0" id="main_slider"
x-data="{
slides: [
{ id:1, img: '/storage/thumbs_xl/slider/design-5.jpg', text: 'Офисные перегородки <br> в стиле LOFT', textclass: 'top-1/4 text-white', buttonclass: '' },
{ id:2, img: '/storage/thumbs_xl/slider/design-7.jpg', text: 'Межкомнатные раздвижные <br> перегородки', textclass: 'bottom-1/4 text-white', buttonclass: 'text-white' },
{ id:3, img: '/storage/thumbs_xl/slider/img_20171230_191642.jpg', text: 'Лестничные ограждения <br> из закалённого стекла', textclass: 'top-1/3 text-white', buttonclass: 'text-white' },
{ id:4, img: '/storage/thumbs_xl/slider/2018-03-09-20-29-24.jpg', text: 'Цельностеклянные перегородки', textclass: 'bottom-1/4 text-white', buttonclass: 'text-white' },
{ id:5, img: '/storage/thumbs_xl/slider/peregorodka-47.jpg', text: 'Пескоструйные рисунки <br> на стекле', textclass: 'bottom-52 text-white', buttonclass: 'text-white' },
{ id:6, img: '/storage/thumbs_xl/slider/dsc_0003.jpg', text: 'Стеклянные ограждения <br> балконов и террас', textclass: 'top-28', buttonclass: '' },
{ id:7, img: '/storage/thumbs_xl/slider/1912501_1600x1200.jpg', text: 'Стеклянные перегородки для ресторанов', textclass: 'top-28 text-white', buttonclass: '' },
]
}"
x-effect="console.log(slide)"
>
<template x-for="slide in slides" :key="slide.id">
<div class="mainslider_item relative">
<img x-bind:src="slide.img" class="h-148 w-full lg:h-224 object-cover">
<div class="mainslider_item_text absolute w-full flex justify-center py-4 text-3xl font-bold" x-bind:class="slide.textclass" x-html="slide.text">
</div>
<div class="mainslider_item_button absolute top-12 right-0 w-1/2 flex justify-center" x-bind:class="slide.buttonclass">
<x-modules.link-button
link="#" text="Заказать звонок" icon="phone-ringing-outline"
style="black-outline" class="w-48 p-1.5"
#click.prevent="contactForm()"
/>
</div>
</div>
</template>
</div>
</x-slot>
resources/js/app.js
require('./includes/script.js');
resources/js/bootstrap.js
window.carousel = require('slick-carousel');
resources/js/includes/script.js
window.addEventListener('DOMContentLoaded', function(){
/*===== slick carousel modal plugin =====*/
/*============= main slider =============*/
$('#main_slider').slick({
arrows: true,
adaptiveHeight: true,
dots: true,
infinite: true,
autoplay: true,
nextArrow: '<div class="main__arrow arrow-next"></div>',
prevArrow: '<div class="main__arrow arrow-prev"></div>',
responsive: [
{
breakpoint: 768,
settings: {
arrows: false
}
}
]
});
/*===== FINISH slick carousel modal plugin =====*/
});

tailwind certain custom color not taking effect in laravel 8 welcome page

I am trying to add a custom color to tailwind.config.js and use it as a background or text color but it is not taking effect. What is odd is I have added other custom color before into tailwind config, those are working fine only anything new that I try to add does not work.
Here is my tailwind.config.js
const defaultTheme = require('tailwindcss/defaultTheme');
module.exports = {
theme: {
extend: {
colors:{
salmon: {
th1: '#B03060',
},
tuna: {
th1: '#393B3E',
},
wildblueyonder: {
th1: '#768DAE',
},
xanadu: {
th1: '#798578',
},
napa: {
th1: '#AC9F8F',
},
cararra: {
th1: '#F6F7F4',
},
kimberly: {
th2: '#7A81A8',
},
shakespeare: {
th2: '#53A7CE',
},
jordyblue: {
th2: '#8CCBF3',
},
softpeach: {
th2: '#FAF7F6',
},
softr: {
th2: '#FAF7F6',
},
},
fontFamily: {
sans: ['Nunito', ...defaultTheme.fontFamily.sans],
},
},
},
variants: {
extend: {
opacity: ['disabled'],
},
},
plugins: [require('#tailwindcss/forms')],
};
Here is my view blade file code where I am using the color(text-salmon-th1) for text in the login a href tag.
<div class="flex lg:justify-center">
<label class="bg-tuna-th1">test</label>
<a href="{{ route('login') }}"
class="inline-flex px-6 py-2 text-2xl font-semibold text-salmon-th1 transition duration-500 ease-in-out transform rounded-lg hover:bg-red-700 hover:to-red focus:shadow-outline focus:outline-none focus:ring-2 ring-offset-current ring-offset-2">#lang("Login")</a>
<a href="{{ route('register') }}"
class="inline-flex items-center text-2xl px-6 py-2 ml-4 font-semibold text-white transition duration-500 ease-in-out transform bg-red-800 rounded-lg shadow-xl hover:to-red hover:bg-red-700 hover:text-white focus:shadow-outline focus:outline-none focus:ring-2 ring-offset-current ring-offset-2">#lang("Register")</a>
</div>
I have tried clearing the cache of browser, clearing laravel view cache.
Every time I change something in the tailwind config file I have tried "npm run watch" or "npm run dev".
And I know tailwindcss is included in page because the other colors tuna, wildblueyonder e.t.c work only the new ones that I am adding including "salmon" does not work.
I have exhausted searching the reason for this.. .Any help will be greatly appreciated.
Ok , I feel stupid but I figured out why it was not working. It was because the public folder was one step above the current framework folder. And while I ran the "npm run dev" it created the public folder with app.css file inside wrong folder.
To fix this issue I had to change the code in webpack.mix.js and add the following line.
my path
/public_folder_name/
/framework_folder_name/
added this line to the webpack.mix.js file
mix.setPublicPath('../public_folder_name/');

Increase the height of Dropdown menu when using mat-expansion-panel

I have ng-select wrapped inside mat-expansion-panel. I would like to be able to increase the height of the dropdown list to go beyond the height of mat-expansion-panel but I cannot get that effect. I have tried to play around with z-index but still not working.
Stackblitz Example here for list of countries
My code:
HTML
<mat-accordion>
<mat-expansion-panel class="shadow">
<mat-expansion-panel-header>
<mat-panel-title>
<b>Location</b>
</mat-panel-title>
</mat-expansion-panel-header>
<div class="location">
Country
<ng-select class="m-t-10" [(ngModel)]="selectedCountry">
<ng-option *ngFor="let country of countries" value="country.value">
<div class="famfamfam-flags {{country?.value.toLowerCase()}}"></div>
{{country?.label}}
</ng-option>
</ng-select>
</div>
<mat-divider></mat-divider>
<div class="location">
Province
<ng-select class="m-t-10" [(ngModel)]="selectedProvince">
<ng-option *ngFor="let province of provinces" value="country.value">
{{province?.label}}
</ng-option>
</ng-select>
</div>
<mat-divider></mat-divider>
<div class="location">
District
<ng-select class="m-t-10" [(ngModel)]="selectedDistrict">
<ng-option *ngFor="let district of districts" value="district.value">
{{district?.label}}
</ng-option>
</ng-select>
</div>
</mat-expansion-panel>
</mat-accordion>
import { Component,ViewEncapsulation} from "#angular/core";
import { CountryListService } from "./../country.service";
#Component({
selector: "app-location",
templateUrl: "./location.component.html",
styleUrls: ["./location.component.css"],
encapsulation: ViewEncapsulation.None,
providers: [CountryListService]
})
export class LocationComponent {
constructor(private countryList: CountryListService) {}
selectedCountry = "Select";
selectedProvince = "Select";
selectedDistrict = "Select";
countries = this.countryList.getCountries();
provinces = [{ label: "province1", value: "province1" }];
districts = [{ label: "Dist1", value: "District1" }];
}
Countries Service
import {Injectable} from '#angular/core';
#Injectable()
export class CountryListService{
constructor(){}
getCountries(){
return CountryListService.COUNTRIES;
}
private static readonly COUNTRIES = [
{value: 'AF', label: 'Afghanistan'},
{value: 'AX', label: 'Åland Islands'},
{value: 'AL', label: 'Albania'},
{value: 'DZ', label: 'Algeria'},
{value: 'AS', label: 'American Samoa'},
{value: 'AD', label: 'Andorra'},
{value: 'AO', label: 'Angola'},
{value: 'AI', label: 'Anguilla'},
{value: 'AQ', label: 'Antarctica'},
{value: 'AG', label: 'Antigua and Barbuda'},
{value: 'AR', label: 'Argentina'}
];
}
I'm not sure about what your are trying to do but I think what you are looking for is :
.ng-dropdown-panel {
position: relative !important;
}
To expand the height of the mat-expansion-panel when you display the dropdown list options.

TreeSelect is hidden behind when using it in a Modal and trying to open it to see it's elements

I tried using the Ant Design TreeSelect component withing a Modal, but when opening that TreeSelect the values of the tree is hidden behind the Modal.
I tried using a higher value of z-index but it didn't help! Any ideas?
import React from "react";
import ReactDOM from "react-dom";
import { version } from "antd";
import { TreeSelect } from "antd";
import {
Button,
ComposedModal,
ModalBody,
ModalFooter,
ModalHeader
} from "carbon-components-react";
import "antd/dist/antd.css";
import "./index.css";
const treeData = [
{
title: "Node1",
value: "0-0",
key: "0-0",
children: [
{
title: "Child Node1",
value: "0-0-1",
key: "0-0-1"
},
{
title: "Child Node2",
value: "0-0-2",
key: "0-0-2"
}
]
},
{
title: "Node2",
value: "0-1",
key: "0-1"
}
];
function treeSelectChange(e, value) {
console.log(e);
//e.preventDefault()
}
ReactDOM.render(
<div className="App">
<h1>antd version: {version}</h1>
{/* <p>
Please <b>fork</b> this sandbox to reproduce your issue.
</p> */}
<ComposedModal
open={true}
// onClose={(e) => this.closeRuleEditorModal(e) }
className=""
>
<ModalHeader title="Rule Editor" className="HeaderToolbar White" />
<ModalBody>
<TreeSelect
// className="on-front"
style={{
width: "100%"
}}
// value={element.Value}
dropdownStyle={{
maxHeight: 400,
overflow: "auto",
zIndex: 10000
// position: "absolute"
}}
treeData={treeData}
// placeholder={element.Name}
treeDefaultExpandAll
onChange={treeSelectChange}
/>
</ModalBody>
<ModalFooter>
<Button
kind="secondary"
size="small"
// onClick={(e) => this.closeRuleEditorModal(e) }
>
Cancel
</Button>
<Button
kind="primary"
id="btnSave"
size="small"
// onClick={() => this.fabricateCustomizedProject()}
>
Save
</Button>
</ModalFooter>
</ComposedModal>
</div>,
document.getElementById("root")
);
To reproduce issue, you may also use
https://codesandbox.io/s/antd-reproduction-template-ci559
Update
It worked for me when I used a z-index with value 10000 (have no idea why I had to set so high value, seems one of the css that I used for other components -Modal- is using a big z-index inside).
dropdownStyle={{ maxHeight: 400, overflow: 'auto',zIndex:"100000" }}
It works for me

Resources