Palms-on with the Svelte JavaScript framework

Learn extra at:


<script>
  const mindBendingMovies = [
    { id: 1, title: "Inception", director: "Christopher Nolan", year: 2010, themes: ["dream manipulation", "layered reality", "subconscious trauma"] },
    { id: 2, title: "Time Bandits", director: "Terry Gilliam", yr: 1981, themes: ["time travel", "chaos vs order", "childhood imagination"] },
    { id: 3, title: "Improbable Planet", director: "René Laloux", yr: 1973, themes: ["alien societies", "subjugation", "transcendence"] },
    { id: 4, title: "Bare Lunch", director: "David Cronenberg", yr: 1991, themes: ["hallucination", "addiction", "subversion of reality"] },
    { id: 5, title: "Waking Life", director: "Richard Linklater", yr: 2001, themes: ["lucid dreaming", "philosophy", "existentialism"] }
  ];
</script>

<fashion>
  /* Kinds hidden for brevity */
</fashion>

<div class="container">
  <h1>Bizarre Film Listing</h1>

  <ul class="movie-list">
    {#every mindBendingMovies as film (film.id)}
      <li class="movie-item">
        <div class="movie-title">{film.title}</div>
        <div class="movie-director">Directed by {film.director} ({film.yr})</div>
        <div class="movie-themes">
          {#every film.themes as theme}
            <span>{theme}</span>
          {/every}
        </div>
      </li>
    {/every}
  </ul>
</div>

The very first thing to note in regards to the web page is how minimalist it’s. The three sections—script, fashion, and markup—signify every important side of the UI. This web page will change into a Svelte element, with these components driving its habits.

Right here’s a have a look at the web page to date:

Matthew Tyson

The one script we’d like proper now’s the definition of the mindBendingMovies array. We loop over the array within the markup: {#every mindBendingMovies as film (film.id)}. The related contents are displayed utilizing the uncovered iterator variable, film.

Turn leads into sales with free email marketing tools (en)

Leave a reply

Please enter your comment!
Please enter your name here