script til farver senere:
<!-- ===== Deepal S07 Farve-viewer ===== -->
<section id="color-viewer" aria-label="Se Deepal S07 i forskellige farver">
<div class="cv-wrap">
<div class="cv-stage">
<img id="cv-image" src="" alt="Deepal S07" />
<div class="cv-progress" id="cv-progress" aria-live="polite">Indlæser…</div>
</div>
<!-- Farveprikker (centreret) -->
<div class="cv-colors" id="cv-colors" aria-label="Vælg farve"></div>
<div class="cv-color-label" id="cv-color-label" aria-live="polite"></div>
</div>
</section>
<style>
#color-viewer{
margin:0; padding:0; background:#fff;
font-family:system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif;
}
#color-viewer .cv-wrap{
max-width:1100px; margin:0 auto; background:#fff;
}
#color-viewer .cv-stage{
position:relative; background:#fff; overflow:hidden;
aspect-ratio:16/9; display:grid; place-items:center; line-height:0;
}
#color-viewer #cv-image{
display:block; width:100%; height:100%; object-fit:contain;
transition: opacity .35s ease;
}
#color-viewer #cv-image.loading{ opacity:0; }
#color-viewer .cv-progress{
position:absolute; left:10px; bottom:10px;
background:rgba(255,255,255,.95);
padding:6px 10px; border-radius:999px; font-size:12px;
display:none;
}
/* Farveprikker */
#color-viewer{ --dot:36px; --ring:2px; --gap:4px; --ringColor:#111; }
#color-viewer .cv-colors{
display:flex; flex-wrap:wrap; gap:12px;
justify-content:center; align-items:center; margin:10px 0 0;
}
#color-viewer .cv-color{
box-sizing:border-box; width:var(--dot); height:var(--dot); aspect-ratio:1/1;
display:grid; place-items:center; border-radius:999px; background:#fff;
border:1px solid rgba(0,0,0,.06); padding:var(--gap);
box-shadow:0 1px 6px rgba(0,0,0,.08); cursor:pointer; flex:none;
transition: box-shadow .2s ease, border-color .2s ease;
}
#color-viewer .cv-color[data-active="true"]{
box-shadow:0 0 0 var(--ring) var(--ringColor), 0 1px 6px rgba(0,0,0,.08);
border-color:transparent;
}
#color-viewer .cv-swatch{
width:100%; height:100%; border-radius:inherit;
box-shadow:inset 0 0 0 1px rgba(0,0,0,.15);
}
#color-viewer .cv-color-label{
text-align:center; font-size:14px; margin:8px 0 0;
color:#111; opacity:.85; min-height:20px;
}
@media(max-width:600px){
#color-viewer{ --dot:30px; --ring:2px; --gap:3px; }
#color-viewer .cv-stage{ aspect-ratio:16/10; }
#color-viewer .cv-colors{ gap:8px; margin:8px 0 0; }
#color-viewer .cv-color-label{ font-size:13px; margin-top:6px; }
}
</style>
<script>
(function(){
const BASE = 'https://deepal.com.pk/upload/';
const COLORS = [
{
name: 'Eclipse Black',
sw: 'linear-gradient(135deg,#0a0a0a 0%,#1a1a1a 50%,#0a0a0a 100%)',
src: BASE + 'deepal%20s7%20color%20black290424071001-drive.png'
},
{
name: 'Lunar Gray',
sw: 'linear-gradient(135deg,#5a6166 0%,#70787d 50%,#5a6166 100%)',
src: BASE + 'deepal%20s7%20color%20gray290424071028-drive.png'
},
{
name: 'Comet White',
sw: 'linear-gradient(135deg,#fafafa 0%,#f3f3f3 50%,#e9e9e9 100%)',
src: BASE + 'deepal%20s7%20color%20white290424071155-drive.png'
},
{
name: 'Nebula Green',
sw: 'linear-gradient(135deg,#7ab3bd 0%,#93c5ce 50%,#7ab3bd 100%)',
src: BASE + 'deepal%20s7%20color%20cyan290424071130-drive.png'
},
{
name: 'Cosmic Yellow',
sw: 'linear-gradient(135deg,#afc05e 0%,#c3d277 50%,#afc05e 100%)',
src: BASE + 'deepal%20s7%20color%20yellow290424071205-drive.png'
},
{
name: 'Sunset Orange',
sw: 'linear-gradient(135deg,#c06050 0%,#d47566 50%,#c06050 100%)',
src: BASE + 'deepal%20s7%20color%20orange290424071145-drive.png'
}
];
const DEFAULT_COLOR = 1; // Lunar Gray
const imgEl = document.getElementById('cv-image');
const progressEl = document.getElementById('cv-progress');
const colorsEl = document.getElementById('cv-colors');
const labelEl = document.getElementById('cv-color-label');
let activeIndex = DEFAULT_COLOR;
/* Preload alle billeder */
function preloadAll(){
COLORS.forEach(c => { const img = new Image(); img.src = c.src; });
}
/* Skift farve */
function switchColor(index){
if(index === activeIndex) return;
activeIndex = index;
imgEl.classList.add('loading');
progressEl.style.display = 'block';
progressEl.textContent = 'Indlæser…';
const newImg = new Image();
newImg.src = COLORS[index].src;
newImg.onload = () => {
imgEl.src = COLORS[index].src;
imgEl.alt = 'Deepal S07 – ' + COLORS[index].name;
imgEl.classList.remove('loading');
progressEl.style.display = 'none';
};
newImg.onerror = () => {
imgEl.src = COLORS[index].src;
imgEl.classList.remove('loading');
progressEl.textContent = 'Kunne ikke indlæse';
setTimeout(() => progressEl.style.display = 'none', 1500);
};
updateButtons();
updateLabel();
}
function updateButtons(){
colorsEl.querySelectorAll('.cv-color').forEach((btn, i) => {
btn.dataset.active = (i === activeIndex);
});
}
function updateLabel(){
labelEl.textContent = COLORS[activeIndex].name;
}
function renderColorButtons(){
colorsEl.innerHTML = '';
COLORS.forEach((c, i) => {
const btn = document.createElement('button');
btn.type = 'button';
btn.className = 'cv-color';
btn.dataset.active = (i === activeIndex);
btn.setAttribute('aria-label', c.name);
btn.innerHTML = '<span class="cv-swatch" style="background:' + c.sw + '"></span>';
btn.addEventListener('click', () => switchColor(i));
colorsEl.appendChild(btn);
});
}
/* Init */
renderColorButtons();
imgEl.src = COLORS[activeIndex].src;
imgEl.alt = 'Deepal S07 – ' + COLORS[activeIndex].name;
updateLabel();
preloadAll();
imgEl.onload = () => { progressEl.style.display = 'none'; };
})();
</script>
<!-- ===== /Deepal S07 Farve-viewer ===== -->