- Vue.js 2 Web Development Projects
- Guillaume Chau
- 250字
- 2021-07-02 22:34:34
The overlays
The last UI elements we need are the overlays. The following are three of them:
- The 'new turn' overlay shows the name of the current player when it is their turn. Clicking on the 'new turn' player switches to the 'last play' overlay.
- The 'last play' overlay shows the player what their opponent did just before. It displays either of the following:
- The card played by the opponent during the preceding turn
- A reminder that their turn was skipped
- The 'game over' overlay shows whenever a player or both players lose. It displays the names of the players with the phrase "is victorious" or "is defeated". Clicking on the 'game over' overlay reloads the game.
All of these overlays have two things in common--they do something when the user clicks on them, and they have a similar layout design. So, we should be smart here and structure our components to reuse code as much as we can where it makes sense. The idea here is to create a generic overlay component, which will take care of the click event and the layout and three specific overlay-content components for each one of the overlays we need.
Before starting, add a new activeOverlay property to the app state in the state.js file:
// The consolidated state of our app
var state = {
// UI
activeOverlay: null,
// ...
}
This will hold the name of the currently displayed overlay or will be null if no overlay is shown.
推薦閱讀
- Angular UI Development with PrimeNG
- Practical Data Science Cookbook(Second Edition)
- MATLAB應用與實驗教程
- Wireshark Network Security
- Rust Cookbook
- Data Analysis with IBM SPSS Statistics
- Oracle數(shù)據(jù)庫從入門到運維實戰(zhàn)
- Monitoring Elasticsearch
- SQL Server 2016數(shù)據(jù)庫應用與開發(fā)習題解答與上機指導
- ArcGIS By Example
- D3.js 4.x Data Visualization(Third Edition)
- Building Microservices with .NET Core
- 零基礎學HTML+CSS第2版
- 基于GPU加速的計算機視覺編程:使用OpenCV和CUDA實時處理復雜圖像數(shù)據(jù)
- 黑莓(BlackBerry)開發(fā)從入門到精通