Coder Social home page Coder Social logo

wordpress / wp-movies-demo Goto Github PK

View Code? Open in Web Editor NEW
162.0 10.0 34.0 5.9 MB

Demo of the Interactivity API

Home Page: https://wpmovies.dev

License: GNU General Public License v2.0

JavaScript 24.80% PHP 47.53% CSS 9.73% HTML 17.94%
frontend-framework gutenberg wordpress

wp-movies-demo's Introduction

Interactivity API Demo - WP Movies

🎥 Live demo: wpmovies.dev

Interactivity.API.-.WP.Movies.demo.mp4

What is this?

This is a demo plugin which shows the features of the Interactivity API.

The plugin is split into:

  • /src/blocks/interactive - Start here to understand how to build interactive blocks with the Interactivity API. The folder contains all the custom interactive blocks used in the demo.

  • /wp-movies-theme - The custom theme used in the demo. Contains some custom styling and the templates for the header & footer as well as the movie & actors pages.

  • /lib - Helpers and support code for this demo. It's not relevant for understanding the Interactivity API.

When will I be able to use the Interactivity API?

The Interactivity API is available in WordPress 6.5.

Setup

  1. Install the required plugins:

    • If you use wp-env, run npx wp-env start to install the plugins automatically and run a local WP instance.

    • Otherwise, install the following plugins:

  2. Install the dependencies and build the plugin:

    npm install && composer install
    npm run build

    If you plan on tinkering with the frontend code, start the webpack server which automatically rebuilds the files when you make any changes:

    npm start
  3. Install & activate the theme:

    You need to install and activate the Movies Demo Theme (/wp-movies-theme in this repo). If you are using wp-env, it is already installed by default and you just have to activate it. You can run:

      npx wp-env run cli "wp theme activate wp-movies-theme"

Note

When running wp-env commands like the one above, it is assumed that the Docker container is called cli on your local machine. If you had previously used wp-env to run other WordPress sites, this name might be different, e.g. cli-1 in which case the full command would be npx wp-env run cli-1 "wp theme activate wp-movies-theme".

  1. Add the movie and actor data to the WordPress database:

    You can import the data manually:

    1. Go to Tools > Import > WordPress and click on Run Importer.
    2. Select the wp_sampledata_movies.xml file.
    3. Select the Download and import file attachments and click on the Upload file and import.
    4. Repeat the process for the wp_sampledata_actors.xml file.
    5. Repeat the process for the wp_sampledata_media.xml file. This one can take up to five minutes.

    If you are using wp-env, you can run the following commands:

      npx wp-env run cli "import wp-content/plugins/wp-movies-demo/wp_sampledata_movies.xml --authors=create"
      npx wp-env run cli "import wp-content/plugins/wp-movies-demo/wp_sampledata_media.xml  --authors=create"
      npx wp-env run cli "import wp-content/plugins/wp-movies-demo/wp_sampledata_actors.xml --authors=create"

    If you run into any problems you can run npx wp-env clean all and start this step over again.

  2. Set the permalinks to use the Post name in Settings > Permalinks.

    If you are using wp-env you can just run this command:

    npx wp-env run cli "wp rewrite structure '/%postname%/'"
  3. Enable the Full client-side navigation in the Gutenberg > Experiments.

Things to try

Client-side Navigations and pagination

When enabled, the lists of movies and actors will paginate without doing a full page refresh. You can enable this behavior in your WordPress admin page in Gutenberg > Experiments. Click around to the next/previous page of the movies or actors. You the list is loaded without a delay. This is because the HTML for that page is prefetched ahead of time, and only the nodes that are different between the current page and the next page are updated.

Add to favourites

When you add a movie to favourites notice how the number of movie likes is preserved when navigating to another page. In addition to client-side navigations, the Interactivity API uses a smart DOM diffing algorithm. This allows the interactive state of blocks on the current page to be preserved!

Instant search

Try searching for movies or actors. The search results are rendered dynamically on the server!

Remove the Search template

Try opening the site editor and removing the "Search" template. You'll notice that the Search experience keeps working but that now the Search results look different. That's because in the absence of the Search template, the Archive template is being used. The Interactivity API is designed to work with the server-rendered markup and Full-site editing.

Play the movie trailers

When you navigate to the page for a movie, you can play its trailer. If you have the client-side navigations enabled, you'll notice that the trailer will keep playing as you keep navigating around the site!

Credits

Powered by WordPress and TMDb.

wp-movies-demo's People

Contributors

cbravobernal avatar dependabot[bot] avatar fabiankaegy avatar github-actions[bot] avatar karstengresch avatar luisherranz avatar michalczaplinski avatar ockham avatar santosguillamot avatar szepeviktor avatar westonruter avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

wp-movies-demo's Issues

Declare required plugins as required plugins

Plugins should be declared as dependencies in composer.json, not links in a readme to zip files. This would allow them to be auto-installed, eliminating at least 3 setup steps

Tracking Issue 🎨

This is a tracking issue for all the tasks that are related to the development of the WP Movies Demo that shows off the features of the Interactivity API

Done

In progress

To Do

Flashes of stale content and inconsistent routing

As I browse the demo site if I don't click slowly I get flashes of stale content that gets replaced several seconds later as the page updates. There are no loading or spinner type interactions during loading.

Likewise if I click on a button, say to visit a genre nothing happens until the new page is loaded, during which I can click on more buttons under the false assumption it failed or wasn't clickable. Then the new genre loads, only to be replaced momentarily with one of the pages I clicked on while I was waiting

Link to block interactivity repo

The plugin is required but the only link is a direct link to a zip file, there's no way to get there from this repo without copy pasting and manually editing the URL and hoping that it works.

If this repo is aimed at developers/engineers make it easy to discover and add a link to the readme

Unable to import dummy data

Hello, thank you for providing this amazing test theme. I attempted to import test data, but unfortunately, it failed.

WP version 6.5

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.