<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: José Francisco</title>
    <description>The latest articles on DEV Community by José Francisco (@xtreme2020).</description>
    <link>https://dev.to/xtreme2020</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F147078%2F59bba49f-d0f6-47bc-a465-17b8e07746a9.jpg</url>
      <title>DEV Community: José Francisco</title>
      <link>https://dev.to/xtreme2020</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/xtreme2020"/>
    <language>en</language>
    <item>
      <title>Laravel pagination Links to HTMX, app example repo included</title>
      <dc:creator>José Francisco</dc:creator>
      <pubDate>Fri, 16 Feb 2024 03:10:58 +0000</pubDate>
      <link>https://dev.to/xtreme2020/laravel-pagination-links-to-htmx-bii</link>
      <guid>https://dev.to/xtreme2020/laravel-pagination-links-to-htmx-bii</guid>
      <description>&lt;p&gt;Laravel with HTMX infinite scroll and Laravel Pagination, also include live search Example,also with browser view transition api&lt;/p&gt;

&lt;p&gt;This is the Javascript use to convert Laravel existings pagination links to HTMX&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1qqlc8960kzoyafmi4c5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1qqlc8960kzoyafmi4c5.png" alt="Javascript Example" width="800" height="584"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here a link to full app repo&lt;br&gt;
&lt;a href="https://github.com/xtreme2020/laravel-htmx-examples"&gt;https://github.com/xtreme2020/laravel-htmx-examples&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Add PrimeVue Theme to Laravel InertiaJS</title>
      <dc:creator>José Francisco</dc:creator>
      <pubDate>Mon, 01 Jan 2024 22:45:56 +0000</pubDate>
      <link>https://dev.to/xtreme2020/add-primevue-theme-to-laravel-inertiajs-1n7b</link>
      <guid>https://dev.to/xtreme2020/add-primevue-theme-to-laravel-inertiajs-1n7b</guid>
      <description>&lt;p&gt;For this example i,m using a fresh Laravel 10.39 latest at this moment Install with InertiaJs starter Kit using Vue &lt;a href="https://laravel.com/docs/10.x/starter-kits"&gt;https://laravel.com/docs/10.x/starter-kits&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So after we have our Laravel install and InertiaJs setup, let's work we our downloaded theme from primevue in my case i'm using sakai theme which is free, this the link to download the theme &lt;a href="https://github.com/primefaces/sakai-vue"&gt;https://github.com/primefaces/sakai-vue&lt;/a&gt; and the theme preview &lt;a href="https://sakai.primevue.org/"&gt;https://sakai.primevue.org/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--2UZPvYiT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7y6krqrioh9mk4vr4dck.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2UZPvYiT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7y6krqrioh9mk4vr4dck.png" alt="Theme screenshot" width="800" height="371"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now that we got our laravel app setup and our theme downloaded, let's start integrating the theme.&lt;/p&gt;

&lt;p&gt;The folder structure of the theme is:&lt;/p&gt;

&lt;p&gt;src/layout: Main layout components&lt;/p&gt;

&lt;p&gt;src/views: Demo pages&lt;/p&gt;

&lt;p&gt;public/demo: Assets used in demos&lt;/p&gt;

&lt;p&gt;public/layout: Assets used in layout&lt;/p&gt;

&lt;p&gt;src/assets/demo: Styles used in demos&lt;/p&gt;

&lt;p&gt;src/assets/sass: SCSS files of the main layout and PrimeVue components&lt;/p&gt;

&lt;p&gt;_ &lt;strong&gt;the folder structure info was taken from the theme documentation.&lt;/strong&gt; _&lt;/p&gt;

&lt;p&gt;Create a folder and called primevue in your laravel app in the following path resources/js/ or name it whatever you want to identify that there is going to be locate theme files ,now in the new location of our laravel app &lt;strong&gt;resources/js/primevue&lt;/strong&gt; we are going to copy all the content of src folder of theme to this path and then copy all the content of the public folder to the Laravel public folder located at the root of the app not in storage.&lt;/p&gt;

&lt;p&gt;After we got all the files copied now we going edit somes files to complete the integration&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Add theme dependencies&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The first file to edit is package.json, here we are going to add theme dependencies , copy the complete dependencies key, except vue, the file is going to look like this &lt;a href="https://github.com/xtreme2020/laraprimevue/blob/main/package.json"&gt;link&lt;/a&gt; to file in github, after that run npm install, to install all the needed dependencies&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Add Tailwind CSS compatibility with Primevue themes and components&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Edit the file app.css located in resources/css/app.css should look like &lt;a href="https://github.com/xtreme2020/laraprimevue/blob/main/resources/css/app.css"&gt;link&lt;/a&gt; to file then in talwind.config.js file look for the content array and add the following at the end of the line './node_modules/primevue/**/*.{vue,js,ts,jsx,tsx}', the file shoud look like &lt;a href="https://github.com/xtreme2020/laraprimevue/blob/main/resources/css/app.css"&gt;link&lt;/a&gt; to github file&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Add theme styles&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now let's add the theme main style sheet to resources/view/app.blade.php which is the main file of our Laravel InertiaJs where the main root element is located , is the equivalent to index.html o main.html of any vue app, in the head tag add this&lt;/p&gt;

&lt;p&gt;&amp;lt;link id="theme-css" rel="stylesheet" type="text/css" href="/themes/lara-light-indigo/theme.css"&amp;gt;&lt;/p&gt;

&lt;p&gt;this option came from index.html of sakai theme and it's use to change themes on the fly with the right side panel, in case you don't want this functionality you can skip this step and import your desire theme style sheet in app.js of the Laravel Inertiajs app, Primevue got many themes style sheets that can be found in &lt;a href="https://primevue.org/theming/"&gt;https://primevue.org/theming/&lt;/a&gt; go to Built-in Themes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Register / Integrate Primevue with InertiaJs&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Go to resources/js/app.js here we going to add Primevue UI library and theirs most commons components use in the app, I don't use the approach of define all the components globally cause that add an unneeded overhead in the app and larger chunk sizes, so I only import needed theme component per Vue SFC, the final file should look like this &lt;a href="https://github.com/xtreme2020/laraprimevue/blob/main/resources/js/app.js"&gt;link&lt;/a&gt; app.js after this step Primevue UI library is fully integrate in our Laravel InertiaJs app.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Replace VueRouter with InertiaJs Link component&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Main theme layout is located in the root of our previouly created folder of primevue in the path resources/js/primevue/layout , as normal Vue template it will use VueRouter for their links, so let start editing the file called AppMenuItem.vue, here we need to change router-link to InertiaJs NavLink component, which I made a little modification removing the class attributes to allow only use Primevue Active class and the file should looks like &lt;a href="https://github.com/xtreme2020/laraprimevue/blob/main/resources/js/primevue/layout/AppMenuItem.vue"&gt;link&lt;/a&gt; to the file, after this modification we got InertiaJs links integration in the theme menu.&lt;/p&gt;

&lt;p&gt;For the menu list we need to edit AppMenu.vue there we can add app routes links as shown here &lt;a href="https://github.com/xtreme2020/laraprimevue/blob/main/resources/js/primevue/layout/AppMenu.vue"&gt;link&lt;/a&gt; to repo file, you can also create an api endpoint to build the menu dynamically( if you want an example ask in the comments) .&lt;/p&gt;

&lt;p&gt;In AppLayout.vue we need to replace router view component from with &amp;lt;slot&amp;gt;&amp;lt;slot/&amp;gt; this way InertiaJs will load component there, &lt;a href="https://github.com/xtreme2020/laraprimevue/blob/main/resources/js/primevue/layout/AppLayout.vue"&gt;link&lt;/a&gt; to file and in AppTopbar.vue you got vue-router links we also need to remove it, look edited file &lt;a href="https://github.com/xtreme2020/laraprimevue/blob/main/resources/js/primevue/layout/AppTopbar.vue"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;To see the final result of the integrated theme I've created 4 InertiaJs pages, located at resources/js/Pages and there you will find PrimevueDashboard.vue, PrimevueMedia.vue, PrimevueChart.vue and PrimvueTable.vue, as we changed the main root of the original theme and put it in a sub-folder you will see that those examples got the new path of theirs respective imports changed&lt;/p&gt;

&lt;p&gt;The most important folders of the src directories to keep are assets and layout these 2 are the main layout, all others folders are examples on how to use theirs components with example data, so you can keep until you got your own components working, for the public directory you only need themes and layout, in this case demo is not needed if you start using real data.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/xtreme2020/laraprimevue"&gt;Link to github repo of the fully working project&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Bonus if you want to set a default layout in InertiaJs go to this link &lt;a href="https://inertiajs.com/pages#default-layouts"&gt;https://inertiajs.com/pages#default-layouts&lt;/a&gt;&lt;/p&gt;

</description>
      <category>laravel</category>
      <category>inertiajs</category>
      <category>primevue</category>
    </item>
  </channel>
</rss>
