-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add category view, component, update router, negelect multi-word-comp…
…onent-names checks
- Loading branch information
Showing
4 changed files
with
124 additions
and
1 deletion.
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
58 changes: 58 additions & 0 deletions
58
ShoppingCart/Frondend/ecommerce-ui/src/components/Category/CategoryBox.vue
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,58 @@ | ||
<template> | ||
<div class="card h-100 w-100"> | ||
<div class="embed-responsive embed-responsive-16by9"> | ||
<img class="card-img-top embed-responsive-item" :src="category.imageUrl" alt="Category Image"> | ||
</div> | ||
|
||
<div class="card-body"> | ||
<h5 class="card-title">{{category.categoryName}}</h5> | ||
<p class="card-text font-italic">{{category.description.substring(0,65)}}...</p> | ||
<router-link id="edit-category" :to="{ name: 'EditCategory', params: { id : category.id } }" > | ||
Edit | ||
</router-link> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
name : "CategoryBox", | ||
props : ["category"], | ||
methods : { | ||
} | ||
} | ||
</script> | ||
|
||
<style scoped> | ||
.card{ | ||
width : 20rem; | ||
height : 24rem; | ||
} | ||
.embed-responsive .card-img-top { | ||
object-fit: cover; | ||
} | ||
a { | ||
text-decoration: none; | ||
} | ||
.card-title { | ||
color: #484848; | ||
font-size: 1.1rem; | ||
font-weight: 400; | ||
} | ||
.card-title:hover { | ||
font-weight: bold; | ||
} | ||
.card-text { | ||
font-size: 0.9rem; | ||
} | ||
#edit-category { | ||
float: right; | ||
} | ||
</style> |
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
57 changes: 57 additions & 0 deletions
57
ShoppingCart/Frondend/ecommerce-ui/src/views/Category/Category.vue
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,57 @@ | ||
<template> | ||
<div class="container"> | ||
<div class="row"> | ||
<div class="col-12 text-center"> | ||
<h4 class="pt-3">Our Categories</h4> | ||
<router-link id="add-category" :to="{name : 'AddCategory'}" v-show="$route.name=='AdminCategory'"> | ||
<button class="btn">Add a new Category</button> | ||
</router-link> | ||
</div> | ||
</div> | ||
<div class="row"> | ||
<div v-for="category of categories" :key="category.id" class="col-md-6 col-xl-4 col-12 pt-3 justify-content-around d-flex"> | ||
<CategoryBox :category="category"> | ||
</CategoryBox> | ||
</div> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import CategoryBox from '../../components/Category/CategoryBox'; | ||
var axios = require('axios'); | ||
export default { | ||
name: 'Category', | ||
components : {CategoryBox}, | ||
data() { | ||
return { | ||
baseURL : "https://limitless-lake-55070.herokuapp.com/", | ||
categories : null, | ||
} | ||
}, | ||
methods: { | ||
async getCategories() { | ||
//fetch categories | ||
await axios.get(this.baseURL + "category/") | ||
.then(res => this.categories = res.data) | ||
.catch(err => console.log(err)) | ||
} | ||
}, | ||
mounted(){ | ||
this.getCategories(); | ||
} | ||
} | ||
</script> | ||
|
||
<style scoped> | ||
h4 { | ||
font-family: 'Roboto', sans-serif; | ||
color: #484848; | ||
font-weight: 700; | ||
} | ||
#add-category { | ||
float: right; | ||
font-weight: 500; | ||
} | ||
</style> |