Featured Movie

The Featured Movie component, much like the Movie Card, presents similar requirements for field collections, which we will address pretty much the same way we did for the Movie card.
Let's start by creating the usual files for building the component:
Inside
nitflex_dev_theme/src/_patterns/01-patterns/create a new directory called featured-movieInside the featured-movie directory create these files:
featured-movie.yml,featured-movie.scss, andfeatured-movie.twig
Add the following code snippet into featured-movie.yml:
Add the following code to featured-movie.twig:
Finally, Add the following code to featured-movie.scss:
Featured Movie Library
Be sure to create the featured-movie library and attach it to the component.
Breaking it down
By now you should have a good understanding of what we are doing here.
First we built an object in YML in which we outlined each of the fields the featured movie component needs. These fields include the movie title, average rating, MPAA rating, add to favorites button as well as a watch movie button.
Next we wrote the markup in twig which makes use of the data from the YML object. Most of this data is being passed to the component in the way of twig includes which makes use of previously built components such as heading, eyebrow and button.
Finally we wrote the css styles to give the featured movie component the look and feel we want.
Compiling the style-guide
Now that we have written all the necessary code to build the Featured Movie component, it's time to see the component in the style-guide. Let's compile our project first.
In your terminal or command line, navigate to
/themes/custom/nitflex_dev_themeand run the following command:
Viewing the component
Open your Drupal site and point to the URL below: http://nitflex.lndo.site/themes/custom/nitflex_dev_theme/dist/style-guide/?p=viewall-patterns-featured-movie
Under the Components category you should see the new Featured Movie component.
Last updated
Was this helpful?