import { Component, createContext, createEffect, createSignal, For } from 'solid-js'; import { LedStripConfig, LedStripPixelMapper } from '../models/led-strip-config'; import { ledStripStore } from '../stores/led-strip.store'; const SorterItem: Component<{ mapper: LedStripPixelMapper }> = (props) => { const [fullLeds, setFullLeds] = createSignal([]); createEffect(() => { const strips = ledStripStore.strips; const totalLedCount = strips.reduce((acc, strip) => acc + strip.len, 0); const fullLeds = new Array(totalLedCount).fill('rgba(255,255,255,0.5)'); for (let i = props.mapper.start, j = 0; i < props.mapper.end; i++, j++) { fullLeds[i] = `rgb(${ledStripStore.colors[i * 3]}, ${ ledStripStore.colors[i * 3 + 1] }, ${ledStripStore.colors[i * 3 + 2]})`; } setFullLeds(fullLeds); }); return (
{(it) => (
)}
); }; const SorterResult: Component = () => { const [fullLeds, setFullLeds] = createSignal([]); createEffect(() => { const strips = ledStripStore.strips; const totalLedCount = strips.reduce((acc, strip) => acc + strip.len, 0); const fullLeds = new Array(totalLedCount).fill('rgba(255,255,255,0.5)'); ledStripStore.mappers.forEach((mapper) => { for (let i = mapper.start, j = 0; i < mapper.end; i++, j++) { fullLeds[i] = `rgb(${ledStripStore.colors[i * 3]}, ${ ledStripStore.colors[i * 3 + 1] }, ${ledStripStore.colors[i * 3 + 2]})`; } }); setFullLeds(fullLeds); }); return (
{(it) => (
)}
); }; export const LedStripPartsSorter: Component = () => { const context = createContext(); return (
{(strip, index) => }
); };