{namespace neos=Neos\Neos\ViewHelpers}
{namespace tb=Newland\Toubiz\Weather\Neos\ViewHelpers}
{namespace vh=Newland\NeosViewHelpers\ViewHelpers}

<f:layout name="Default" />

<f:section name="Content">
    <ul class="tb-weather-list tb-weather-list--border">
        <f:for each="{forecast}" as="dayWeather" iteration="dayIterator">
            <li class="tb-weather-list__item">
                <div class="tb-weather-date">
                    <strong class="tb-weather-date__main">
                        <f:switch expression="{dayIterator.index}">
                            <f:case value="0">
                                <f:translate 
                                    id="word.today"
                                    package="Newland.Toubiz.Weather.Neos"
                                    source="Views/Shared" />

                            </f:case>

                            <f:case value="1">
                                <f:translate 
                                    id="word.tomorrow"
                                    package="Newland.Toubiz.Weather.Neos"
                                    source="Views/Shared" />

                            </f:case>

                            <f:defaultCase>
                                <f:format.date 
                                    date="{dayWeather.date}"
                                    cldrFormat="EEEE"
                                    forceLocale="{node.context.dimensions.language.0}" />

                            </f:defaultCase>
                        </f:switch>
                    </strong>
                    <span class="tb-weather-date__additional">
                        <f:format.date 
                            date="{dayWeather.date}"
                            cldrFormat="d. MMMM y"
                            forceLocale="{node.context.dimensions.language.0}" />

                    </span>
                </div>

                <div class="tb-weather mt-2">
                    <f:format.raw>
                        <tb:icon.weather 
                            id="{dayWeather.symbol}"
                            source="meteotest"
                            class="tb-weather-icon tb-weather__icon" />

                    </f:format.raw>

                    <div class="tb-weather__text">
                        <strong class="tb-weather__temperature">
                            {dayWeather.maximumTemperature -> vh:math.round()}°C

                            <small class="tb-weather__condition">
                                <f:translate 
                                    id="weather.symbol.{dayWeather.symbol}"
                                    package="Newland.Toubiz.Weather.Neos"
                                    source="Views/Shared" />

                            </small>
                        </strong>

                        <strong class="tb-weather__temperature">
                            {dayWeather.minimumTemperature -> vh:math.round()}°C
                        </strong>
                    </div>
                </div>
            </li>
        </f:for>
        <f:if condition="{copyrightInfo.name}">
            <div class="tb-weather-copyright">
                <span>&copy; <a href="{copyrightInfo.url}" target="_blank">{copyrightInfo.name}</a></span>
            </div>
        </f:if>
    </ul>

    <f:if condition="{targetNode}">
        <neos:link.node node="{targetNode}" class="block mt-4">
            <f:translate 
                id="targetNode.label"
                package="Newland.Toubiz.Weather.Neos"
                source="Views/ForecastWidget" />

        </neos:link.node>
    </f:if>

</f:section>
