I’ve been working on converting my Figma mockups into Vue.js components and I’m wondering if I’m doing it the right way. I created a basic layout in Figma and exported the CSS properties for each element. Now I’m trying to build my first Vue component based on this design.
I decided to use BEM methodology to organize my CSS classes, which has been really helpful for keeping everything structured. For each design element from Figma, I created a corresponding CSS class and wrapped it in a div element.
Here’s what my component looks like:
<template>
<div class="wrapper">
<div class="inventory__banner"></div>
<div class="inventory__title">Inventory</div>
<div class="inventory__content"></div>
<div class="inventory__list-header"></div>
<div class="inventory__column-category">Category</div>
<div class="inventory__column-quantity">Quantity</div>
</div>
</template>
<script>
export default {
name: 'InventoryPanel',
}
</script>
<style scoped>
.inventory__title {
position: absolute;
width: 180px;
height: 40px;
left: 5px;
top: 280px;
font-family: 'Roboto', sans-serif;
font-weight: 600;
font-size: 32px;
line-height: 48px;
color: #222222;
}
.inventory__banner {
position: absolute;
width: 380px;
height: 45px;
left: -5px;
top: 275px;
background: #7A6B4D;
border-radius: 5px 180px 10px 0px;
}
.inventory__column-quantity {
position: absolute;
width: 95px;
height: 25px;
left: 250px;
top: 320px;
font-family: 'Roboto', sans-serif;
font-size: 14px;
line-height: 20px;
text-align: center;
color: #333333;
}
.inventory__column-category {
position: absolute;
width: 80px;
height: 22px;
left: 15px;
top: 320px;
font-family: 'Roboto', sans-serif;
font-size: 14px;
line-height: 20px;
text-align: center;
color: #333333;
}
.inventory__list-header {
position: absolute;
width: 370px;
height: 40px;
left: 0px;
top: 315px;
background: linear-gradient(180deg, rgba(40, 35, 20, 0.3) 65%, rgba(50, 60, 55, 0) 100%);
}
.inventory__content {
position: absolute;
width: 375px;
height: 350px;
left: -5px;
top: 310px;
background: #B8A582;
border: 4px solid #2F3A36;
border-radius: 0px 0px 15px 0px;
}
</style>
The output matches my Figma design perfectly, which is great. But as someone who usually works on backend stuff, I’m not sure if this approach is correct. I feel like just using div elements for everything might not be the best practice.
What’s the proper way to handle this kind of design conversion? Should I be using different HTML elements or is this div-heavy approach actually fine for Vue components?