forked from bagisto/bagisto
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request bagisto#7691 from devansh-webkul/pr/amit-webkul/7679
Refined carousel and added the category carousel
- Loading branch information
Showing
9 changed files
with
238 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
packages/Webkul/Shop/src/Http/Resources/CategoryResource.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
namespace Webkul\Shop\Http\Resources; | ||
|
||
use Illuminate\Http\Resources\Json\JsonResource; | ||
|
||
class CategoryResource extends JsonResource | ||
{ | ||
/** | ||
* Transform the resource into an array. | ||
* | ||
* @param \Illuminate\Http\Request $request | ||
* @return array | ||
*/ | ||
public function toArray($request) | ||
{ | ||
return [ | ||
'id' => $this->id, | ||
'parent_id' => $this->parent_id, | ||
'name' => $this->name, | ||
'slug' => $this->slug, | ||
'url_path' => $this->url_path, | ||
'status' => $this->status, | ||
'position' => $this->position, | ||
'display_mode' => $this->display_mode, | ||
'description' => $this->description, | ||
'images' => [ | ||
'base_url' => $this->image_url, | ||
'banner_url' => $this->banner_url, | ||
'category_icon_url' => $this->category_icon_url, | ||
], | ||
'meta' => [ | ||
'title' => $this->meta_title, | ||
'keywords' => $this->meta_keywords, | ||
'description' => $this->meta_description, | ||
], | ||
'translations' => $this->translations, | ||
'additional' => $this->additional, | ||
]; | ||
} | ||
} |
114 changes: 114 additions & 0 deletions
114
packages/Webkul/Shop/src/Resources/views/components/categories/carousel.blade.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
<v-categories-carousel | ||
src="{{ $src }}" | ||
title="{{ $title }}" | ||
navigation-link="{{ $navigationLink ?? '' }}" | ||
> | ||
<x-shop::shimmer.categories.carousel :navigation-link="$navigationLink ?? false"></x-shop::shimmer.categories.carousel> | ||
</v-categories-carousel> | ||
|
||
@pushOnce('scripts') | ||
<script type="text/x-template" id="v-categories-carousel-template"> | ||
<div class="container mt-[60px] max-lg:px-[30px] max-sm:mt-[20px]" v-if="! isLoading && categories?.length"> | ||
<div class="bs-item-carousal-wrapper relative"> | ||
<div | ||
ref="swiperContainer" | ||
class="flex gap-10 overflow-auto scroll-smooth scrollbar-hide" | ||
> | ||
<div | ||
class="grid grid-cols-1 justify-items-center gap-[15px] font-medium min-w-[120px]" | ||
v-for="category in categories" | ||
> | ||
<a | ||
:href="category.url_path" | ||
class="" | ||
> | ||
<div class="bg-[#F5F5F5] rounded-full w-[110px] h-[110px]"> | ||
<img | ||
class="w-[110px] h-[110px] rounded-full" | ||
:src="category.images.base_url" | ||
v-if="category?.images?.base_url" | ||
/> | ||
</div> | ||
|
||
<p | ||
class="text-black text-[20px] font-medium" | ||
v-text="category.name" | ||
> | ||
</p> | ||
</a> | ||
</div> | ||
</div> | ||
|
||
<span | ||
class="bs-carousal-next flex border border-black items-center justify-center rounded-full w-[50px] h-[50px] bg-white absolute top-[37px] -left-[41px] cursor-pointer transition icon-arrow-left-stylish text-[25px] hover:bg-black hover:text-white max-lg:-left-[29px]" | ||
@click="swipeLeft" | ||
> | ||
</span> | ||
|
||
<span | ||
class="bs-carousal-prev flex border border-black items-center justify-center rounded-full w-[50px] h-[50px] bg-white absolute top-[37px] -right-[22px] cursor-pointer transition icon-arrow-right-stylish text-[25px] hover:bg-black hover:text-white max-lg:-right-[29px]" | ||
@click="swipeRight" | ||
> | ||
</span> | ||
</div> | ||
</div> | ||
|
||
<!-- category carousel shimmer --> | ||
<template v-if="isLoading"> | ||
<x-shop::shimmer.categories.carousel | ||
:count="7" | ||
:navigation-link="$navigationLink ?? false" | ||
> | ||
</x-shop::shimmer.categories.carousel> | ||
</template> | ||
</script> | ||
|
||
<script type="module"> | ||
app.component('v-categories-carousel', { | ||
template: '#v-categories-carousel-template', | ||
props: [ | ||
'src', | ||
'title', | ||
'navigationLink', | ||
], | ||
data() { | ||
return { | ||
isLoading: true, | ||
categories: [], | ||
}; | ||
}, | ||
mounted() { | ||
this.getCategories(); | ||
}, | ||
methods: { | ||
getCategories() { | ||
this.$axios.get(this.src) | ||
.then(response => { | ||
this.isLoading = false; | ||
this.categories = response.data.data; | ||
}).catch(error => { | ||
console.log(error); | ||
}); | ||
}, | ||
swipeLeft() { | ||
const container = this.$refs.swiperContainer; | ||
container.scrollLeft -= 720; | ||
}, | ||
swipeRight() { | ||
const container = this.$refs.swiperContainer; | ||
container.scrollLeft += 720; | ||
}, | ||
}, | ||
}); | ||
</script> | ||
@endPushOnce |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
packages/Webkul/Shop/src/Resources/views/components/shimmer/categories/carousel.blade.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
@props(['count' => 0]) | ||
|
||
<div class="container mt-[60px] max-lg:px-[30px] max-sm:mt-[20px]"> | ||
<div class="bs-item-carousal-wrapper relative"> | ||
<div class="flex gap-10 overflow-auto scrollbar-hide"> | ||
@for ($i = 0; $i < $count; $i++) | ||
<div class="grid grid-cols-1 justify-items-center gap-[15px] min-w-[120px]"> | ||
<div class="relative overflow-hidden rounded-full w-[110px] h-[110px] bg-[#E9E9E9] shimmer"> | ||
<img | ||
class="rounded-sm bg-[#F5F5F5]" | ||
src="" | ||
alt="" | ||
> | ||
</div> | ||
|
||
<p class="w-[90px] h-[32px] rounded-[18px] shimmer"></p> | ||
</div> | ||
@endfor | ||
</div> | ||
|
||
<span class="flex rounded-full w-[50px] h-[50px] absolute top-[37px] -left-[41px] shimmer"></span> | ||
|
||
<span class="flex rounded-full w-[50px] h-[50px] absolute top-[37px] -right-[22px] shimmer"></span> | ||
</div> | ||
</div> |
8 changes: 6 additions & 2 deletions
8
packages/Webkul/Shop/src/Resources/views/components/shimmer/products/cards/grid.blade.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters