alt
속성이나, figcaption
사용하면 좀더 시멘틱하고 화면에서 숨기는 처리가 verbose해지지 않는 장점이 있으면서 접근성도 만족할 수 있다.수정전
const desc = ['[댑]무료반품+10%+12%댑 여름 잠옷세트/바지~70%', '[백설]포도씨유 5병(900ml 5)', ...]
const price = ['13,900', '34,210', '12,800', '17,500', ...]
const createItems = (i) => {
const bestItem = document.createElement('li')
bestItem.classList.add('swiper-slide', 'best__item')
bestItem.innerHTML = `
<a href="/" class="best__link">
<div class="product">
<figure class="product__card">
<div class="image--dimmed-layer"><img src="./images/bestProduct${i+1}.jpeg" alt="${desc[i]}" class="product__image" width="100%" />
</div>
<figcaption class="product__caption">
${desc[i]}
</figcaption>
</figure>
<div class="product__rank">
<span class="sr-only">순위</span>
<span class="rank">${i+1}</span>
</div>
<div class="product__price">
<span class="sr-only">판매가</span>
<em class="price" role="text">${price[i]} <span class="currencyUnit">원</span></em>
</div>
</div>
</a>
`
return bestItem;
}
export const renderItem = () => {
$bestList.innerHTML = ''
for(let i=0; i<15; i++) {
const item = createItems(i)
$bestList.appendChild(item)
}
}
수정후
const items = [
{
desc: '[댑]무료반품+10%+12%댑 여름 잠옷세트/바지~70%',
price: '13,900'
},
...restItems,
]
const createItem = (item, index) => {
const bestItem = document.createElement('li')
bestItem.classList.add('swiper-slide', 'best__item')
bestItem.innerHTML = `
<a href="/" class="best__link">
<div class="product">
<figure class="product__card">
<div class="image--dimmed-layer">
<img src="./images/bestProduct${index+1}.jpeg" alt="${item.desc}" class="product__image" width="100%" />
</div>
<figcaption class="product__caption">
${item.desc}
</figcaption>
</figure>
<div class="product__rank">
<span class="sr-only">순위</span>
<span class="rank">${index+1}</span>
</div>
<div class="product__price">
<span class="sr-only">판매가</span>
<em class="price" role="text">${item.price} <span class="currencyUnit">원</span></em>
</div>
</div>
</a>
`
return bestItem;
}
export const renderItems = () => {
$bestList.innerHTML = '';
items.forEach((item, index) => {
const itemChild = createItem(item, index);
$bestList.appendChild(itemChild);
})
}
수정전
const categorydepth = document.querySelectorAll('.category__depth2')
수정 후
const categoryDepth = document.querySelectorAll('.category__depth2')
수정전
.service__title {
font-size: 2.4rem;
font-weight: normal;
margin: 0;
}
.service__content {
margin: 30px -12px 0 -12px;
}
수정후
&__title {
font-size: 2.4rem;
font-weight: normal;
margin: 0;
}
&__content {
margin: 30px -12px 0 -12px;
}