Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div id="root"></div>
              
            
!

CSS

              
                * {
  line-height: 1.5;
  margin: .15rem;
  padding: 0;
}
body {
  padding: 80px 0;
  font-family: 'IBM Plex Sans', sans-serif;
}
ul,
ol {
  list-style: none;
}
.container {
  max-width: 1280px;
  margin-right: auto;
  margin-left: auto;
  padding: 0 20px;
}
ul.card-list {
  li.card-item {
    border: 1px solid #ddd;
    padding: 15px;
    &:not(last-of-type) {
      margin-bottom: 30px;
    }
  }
}

ul.cast {
  li {
    border-top: 1px solid rgba(#ddd, .5);
    padding: 5px;
    &:last-of-type {
      border-bottom: 1px solid rgba(#ddd, 5);
    }
    span {
      display: block;
    }
  }
}
blockquote {
  padding: 40px 25px;
  position: relative;
  color: #707070;
    margin: 0;
  &::before,
  &::after {
    content: "\f10d";
    position: absolute;
    font: {
      family: "Font Awesome 6 Free";
      weight: 900;
      size: 28px;
    }
  }

  &::before {
    top: 0;
    left: 0;
  }

  &::after {
    bottom: 0;
    right: 0;
    transform: scale(-1, 1);
  }
  cite {
    display: block;
    text-align: right;
    color: #888;
    font-size: 0.9em;
  }
}
              
            
!

JS

              
                const foreignMovies = [
  {
    title: "Chocolat",
    director: "Lasse Hallström",
    releaseYear: 2000,
    genre: ["Drama", "Romance"],
    rating: 7,
    cast: [
      { name: "Juliette Binoche", role: "Vianne Rocher" },
      { name: "Johnny Depp", role: "Roux" },
    ],
    plotSummary:
      "A woman and her daughter open a chocolate shop in a small French village, which shakes up the rigid morality of the community.",
  },
  {
    title: "Good Will Hunting",
    director: "Gus Van Sant",
    releaseYear: 1997,
    genre: ["Drama"],
    rating: 8.5,
    cast: [
      { name: "Matt Damon", role: "Will Hunting" },
      { name: "Robin Williams", role: "Sean Maguire" },
    ],
    plotSummary:
      "A young janitor at MIT has a gift for mathematics but needs help from a psychologist to find direction in his life.",
  },
  {
    title: "Her",
    director: "Spike Jonze",
    releaseYear: 2013,
    genre: ["Drama", "Romance", "Sci-Fi"],
    rating: 9.1,
    cast: [
      { name: "Joaquin Phoenix", role: "Theodore Twombly" },
      { name: "Scarlett Johansson", role: "Samantha (voice)" },
    ],
    plotSummary:
      "In a future where technology has advanced, a lonely writer develops an unlikely relationship with an operating system designed to meet his every need.",
  },
  {
    title: "Trainspotting",
    director: "Danny Boyle",
    releaseYear: 1996,
    genre: ["Drama", "Crime"],
    rating: 6.5,
    cast: [
      { name: "Ewan McGregor", role: "Mark Renton" },
      { name: "Jonny Lee Miller", role: "Sick Boy" },
    ],
    plotSummary:
      "Renton, deeply immersed in the Edinburgh drug scene, tries to clean up and get out, despite the allure of the drugs and influence of friends.",
  },
];

const MovieItem = ({
  title,
  director,
  releaseYear,
  genre,
  rating,
  cast,
  plotSummary,
}) => (
  <ul className="card-list">
    <li className="card-item">
      <h3>{title}</h3>
      <div className="star-rating">
        {[...Array(Math.floor(rating))].map((_, i) => (
          <i key={i} className="fa-solid fa-star"></i>
        ))}
        {rating % 1 !== 0 && <i className="fa-solid fa-star-half-stroke"></i>}
        {[...Array(10 - Math.ceil(rating))].map((_, i) => (
          <i key={i} className="fa-regular fa-star"></i>
        ))}
      </div>
      <p>Director: {director}</p>
      <p>Release: {releaseYear}</p>

      <div className="genre-list">
        {genre.map((genreItem, i) => (
          <span key={i}>#{genreItem}</span>
        ))}
      </div>
      <ul className="cast">
        {cast.map((castMember, i) => (
          <li key={i}>
            <span>{castMember.name}</span>
            <span>role: {castMember.role}</span>
          </li>
        ))}
      </ul>
      <blockquote>{plotSummary}</blockquote>
    </li>
  </ul>
);

const MovieList = ({ title, movies }) => (
  <div className="container">
    <h1>{title}</h1>
    <div className="movie">
      {movies.map((movie, i) => (
        <MovieItem key={i} {...movie} />
      ))}
    </div>
  </div>
);

ReactDOM.render(
  <MovieList movies={foreignMovies} title="Movie List" />,
  document.getElementById("root")
);

              
            
!
999px

Console