Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vue-sample-test
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Sanga Raju Gupta Bonagiri
vue-sample-test
Commits
cc7960c4
Commit
cc7960c4
authored
Dec 17, 2023
by
Sanga Raju Gupta Bonagiri
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rename files
parent
f3cb4073
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
135 additions
and
36 deletions
+135
-36
README.md
README.md
+2
-0
App.vue
src/App.vue
+9
-30
CategoriesList.vue
src/Views/CategoriesList/CategoriesList.vue
+43
-0
Header.vue
src/components/Header/Header.vue
+32
-0
ProductCard.vue
src/components/ProductCard/ProductCard.vue
+43
-0
main.js
src/main.js
+6
-6
No files found.
README.md
View file @
cc7960c4
# vue-project-poc
To create a shopping cart using fake Json api
This template should help get you started developing with Vue 3 in Vite.
## Recommended IDE Setup
...
...
src/App.vue
View file @
cc7960c4
<
template
>
<nav
class=
"flex items-center justify-between flex-wrap bg-teal-500 p-6 sticky top-0"
>
<div
class=
"flex items-center flex-shrink-0 text-white mr-6"
>
<span
class=
"font-semibold text-xl tracking-tight"
>
Shopping Cart
</span>
</div>
<div
class=
"w-full block flex-grow lg:flex lg:items-center lg:w-auto"
>
<div
class=
"text-sm lg:flex-grow text-white "
>
<router-link
class=
"block mt-4 lg:inline-block lg:mt-0 text-teal-200 hover:text-white mr-4"
to=
"/"
>
Home
</router-link>
<router-link
class=
"block mt-4 lg:inline-block lg:mt-0 text-teal-200 hover:text-white mr-4"
to=
"/about"
>
About
</router-link>
<router-link
class=
"block mt-4 lg:inline-block lg:mt-0 text-teal-200 hover:text-white mr-4"
to=
"/contact"
>
Contact
</router-link>
</div>
<div>
<router-link
class=
"inline-block text-sm px-4 py-2 leading-none border rounded text-white border-white hover:border-transparent hover:text-teal-500 hover:bg-white mt-4 lg:mt-0"
to=
"/cart"
>
Cart
{{
$store
.
state
.
cart
.
length
>
0
?
$store
.
state
.
cart
.
length
:
""
}}
</router-link>
</div>
</div>
</nav>
<Header></Header>
<div
class=
"content"
>
<router-view
class=
"content"
/>
</div>
</
template
>
<
script
>
import
Header
from
'../src/components/Header/Header.vue'
export
default
{
name
:
"App"
,
created
(){
name
:
"App"
,
components
:
{
Header
},
created
()
{
this
.
$store
.
dispatch
(
'getProductsAction'
)
}
}
</
script
>
<
style
scoped
>
</
style
>
<
style
scoped
></
style
>
src/
components/Categories/Categories
.vue
→
src/
Views/CategoriesList/CategoriesList
.vue
View file @
cc7960c4
...
...
@@ -4,26 +4,8 @@
<div>
<!-- Display products catelog -->
<div
class=
"grid grid-cols-4 gap-8"
>
<div
class=
"card"
v-for=
"product in products"
:key=
"product.id"
>
<div
class=
"max-w-sm rounded overflow-hidden shadow-lg"
>
<img
class=
"w-full card-img p-10"
:src=
"product.image"
alt=
"Sunset in the mountains"
>
<div
class=
"px-6 py-4 config"
>
<ul
class=
"text-gray-700 text-base"
>
<li
class=
"text-xl"
>
{{
product
.
title
}}
</li>
<li>
Price:$
{{
product
.
price
}}
</li>
<li>
Category:
{{
product
.
category
}}
</li>
</ul>
<router-link
:to=
"`/categories/$
{product.category}/${product.id}`">
<button
class=
"bg-blue-500 my-2 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded"
>
More
Details
</button>
</router-link>
</div>
</div>
</div>
<!-- Rendering product card by passing prop -->
<ProductCard
v-for=
"product in products"
:key=
"product.id"
:product=
"product"
></ProductCard>
</div>
</div>
</
template
>
...
...
@@ -31,9 +13,10 @@
<
script
>
import
ProductCard
from
'../../components/ProductCard/ProductCard.vue'
;
export
default
{
name
:
"Categories"
,
name
:
"CategoriesList"
,
components
:{
ProductCard
},
data
()
{
return
{
products
:
[],
...
...
@@ -57,16 +40,4 @@ export default {
</
script
>
<
style
lang=
"scss"
scoped
>
.card
{
min-height
:
35rem
;
.card-img
{
height
:
20rem
;
width
:
100%
;
}
.config
{
min-height
:
15rem
;
}
}
</
style
>
\ No newline at end of file
src/components/Header/Header.vue
0 → 100644
View file @
cc7960c4
<
template
>
<nav
class=
"flex items-center justify-between flex-wrap bg-teal-500 p-6 sticky top-0"
>
<div
class=
"flex items-center flex-shrink-0 text-white mr-6"
>
<span
class=
"font-semibold text-xl tracking-tight"
>
Shopping Cart
</span>
</div>
<div
class=
"w-full block flex-grow lg:flex lg:items-center lg:w-auto"
>
<div
class=
"text-sm lg:flex-grow text-white "
>
<router-link
class=
"block mt-4 lg:inline-block lg:mt-0 text-teal-200 hover:text-white mr-4"
to=
"/"
>
Home
</router-link>
<router-link
class=
"block mt-4 lg:inline-block lg:mt-0 text-teal-200 hover:text-white mr-4"
to=
"/about"
>
About
</router-link>
<router-link
class=
"block mt-4 lg:inline-block lg:mt-0 text-teal-200 hover:text-white mr-4"
to=
"/contact"
>
Contact
</router-link>
</div>
<div>
<router-link
class=
"inline-block text-sm px-4 py-2 leading-none border rounded text-white border-white hover:border-transparent hover:text-teal-500 hover:bg-white mt-4 lg:mt-0"
to=
"/cart"
>
Cart
{{
$store
.
state
.
cart
.
length
>
0
?
$store
.
state
.
cart
.
length
:
""
}}
</router-link>
</div>
</div>
</nav>
</
template
>
<
script
>
export
default
{
name
:
"Header"
}
</
script
>
\ No newline at end of file
src/components/ProductCard/ProductCard.vue
0 → 100644
View file @
cc7960c4
<
template
>
<div
class=
"card"
>
<div
class=
"max-w-sm rounded overflow-hidden shadow-lg"
>
<img
class=
"w-full card-img p-10"
:src=
"product.image"
alt=
"Sunset in the mountains"
>
<div
class=
"px-6 py-4 config"
>
<ul
class=
"text-gray-700 text-base"
>
<li
class=
"text-xl"
>
{{
product
.
title
}}
</li>
<li>
Price:$
{{
product
.
price
}}
</li>
<li>
Category:
{{
product
.
category
}}
</li>
</ul>
<router-link
:to=
"`/categories/$
{product.category}/${product.id}`">
<button
class=
"bg-blue-500 my-2 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded"
>
More
Details
</button>
</router-link>
</div>
</div>
</div>
</
template
>
<
script
>
export
default
{
name
:
"ProductCard"
,
props
:[
'product'
],
}
</
script
>
<
style
lang=
"scss"
scoped
>
.card
{
min-height
:
35rem
;
.card-img
{
height
:
20rem
;
width
:
100%
;
}
.config
{
min-height
:
15rem
;
}
}
</
style
>
\ No newline at end of file
src/main.js
View file @
cc7960c4
...
...
@@ -6,11 +6,11 @@ import App from './App.vue'
import
{
createRouter
,
createWebHistory
}
from
'vue-router'
;
import
store
from
'./store/index.js'
import
Home
from
'../src/
V
iews/Home/Home.Vue'
import
About
from
'../src/
V
iews/About/About.vue'
import
Contact
from
"../src/
V
iews/Contact/Contact.vue"
import
Categories
from
"../src/components/Categories/Categories
.vue"
import
ProductDetail
from
"../src/
V
iews/ProductDetail/ProductDetail.vue"
import
Home
from
'../src/
v
iews/Home/Home.Vue'
import
About
from
'../src/
v
iews/About/About.vue'
import
Contact
from
"../src/
v
iews/Contact/Contact.vue"
import
Categories
List
from
"../src/views/CategoriesList/CategoriesList
.vue"
import
ProductDetail
from
"../src/
v
iews/ProductDetail/ProductDetail.vue"
import
Cart
from
"../src/views/Cart/Cart.vue"
...
...
@@ -22,7 +22,7 @@ const router = createRouter({
{
name
:
"Home"
,
path
:
'/'
,
component
:
Home
},
{
name
:
"About"
,
path
:
'/about'
,
component
:
About
},
{
name
:
"Contact"
,
path
:
'/contact'
,
component
:
Contact
},
{
name
:
"Categories"
,
path
:
'/categories/:product'
,
component
:
Categories
},
{
name
:
"Categories"
,
path
:
'/categories/:product'
,
component
:
Categories
List
},
{
name
:
"ProductDetail"
,
path
:
'/categories/:product/:id'
,
component
:
ProductDetail
},
{
name
:
"Cart"
,
path
:
"/cart"
,
component
:
Cart
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment