LoginSignup
1
5

More than 3 years have passed since last update.

余計なフレームワーク、ライブラリ抜きの Vanilla Web Project 20本でHTML5、CSS、JSを楽しくお得に学ぶ

Posted at

Vanilla Web Project。

HTML5、CSS、JavaScriptのみで構築された20 (+増量予定と書いてある) のミニプロジェクトらしい。GitHubから引用。

# Project Live Demo
01 Form Validator Live Demo
02 Movie Seat Booking Live Demo
03 Custom Video Player Live Demo
04 Exchange Rate Calculator Live Demo
05 DOM Array Methods Project Live Demo
06 Menu Slider & Modal Live Demo
07 Hangman Game Live Demo
08 Mealfinder App Live Demo
09 Expense Tracker Live Demo
10 Music Player Live Demo
11 Infinite Scrolling Live Demo
12 Typing Game Live Demo
13 Speech Text Reader Live Demo
14 Memory Cards Live Demo
15 LyricsSearch App Live Demo
16 Relaxer App Live Demo
17 Breakout Game Live Demo
18 New Year Countdown Live Demo
19 Sortable List Live Demo
20 Speak Number Guessing Game Live Demo

Vanilla Web Project とは

このコースは、純粋で、実用的で、楽しいプロジェクトベースのコースです。すべてのプロジェクトは異なり、繰り返し行われるプラクティスを使用しますが、それらはそれぞれ新しいことを学ぶためのものです。フレームワークやライブラリは使用しません。HTML、CSS、JavaScriptを含むすべてのプロジェクトをゼロから構築します。

プロジェクトは将来的に更新・追加される予定です。最終的には、「50のWebプロジェクト」というタイトルで、より高度なプロジェクトも含めたコースにしたいと考えています。

とのこと。初心者から中級者までを対象に作られており、HTML、CSSとJavaScriptの基本的な知識があれば楽しめる。

  • HTML/CSSによるレイアウトやUIの作成
  • 基本的なJSを実際のプロジェクトで使う
  • CSS アニメーションと JS トリガー
  • DOMの選択と操作
  • JavaScriptイベント
  • 配列メソッド - map()、filter()、reduce()など
  • データの取得とサードパーティのAPIとの連携
  • JSON
  • プロミスと非同期/待ち時間
  • ローカルストレージ
  • ドラッグ&ドロップ
  • 音声認識
  • 音声合成
  • キャンバスAPIとアニメーション

というのが以上、(DeepL翻訳での翻訳と) サマリ。

具体的にどう楽しむか

ソースを丁寧に読むとよさそうだったので読んだ。以下つまみ食いメモ。

Dom Array Methods

image.png

抜粋.js
// Fetch random user and add money
async function getRandomUser() {
  const res = await fetch('https://randomuser.me/api');
  const data = await res.json();
  const user = data.results[0];
  const newUser = {
    name: `${user.name.first} ${user.name.last}`,
    money: Math.floor(Math.random() * 1000000)
  };
  addData(newUser);
}

なんて部分がありますが、以下を発見した。Random User Generator などというAPIがあるのですね。

例.js
var res;
var data;
var user;
res = await fetch('https://randomuser.me/api');
data = await res.json();
user = data.results[0];
console.log(user);

でお試し可能。

Exchange Rate

image.png

抜粋.js
function calculate() {
  const currency_one = currencyEl_one.value;
  const currency_two = currencyEl_two.value;
  fetch("https://open.exchangerate-api.com/v6/latest")
    .then(res => res.json())
    .then(data => {
      //  console.log(data);
      const rate = data.rates[currency_two] / data.rates[currency_one];
      rateEl.innerText = `1 ${currency_one} = ${rate} ${currency_two}`;
      amountEl_two.value = (amountEl_one.value * (rate)).toFixed(2);
    });
}

こちらも

などというAPIを使っている。

Memory Card

memory.gif

こちらはlocalStorageが何なのかを知るにはよさそう。

// Get cards from local storage
function getCardsData() {
  const cards = JSON.parse(localStorage.getItem('cards'));
  return cards === null ? [] : cards;
}

// Add card to local storage
function setCardsData(cards) {
  localStorage.setItem('cards', JSON.stringify(cards));
  window.location.reload();
}

// Clear cards button
clearBtn.addEventListener('click', () => {
  localStorage.clear();
  cardsContainer.innerHTML = '';
  window.location.reload();
});

LocalStorageは色々注意。

Infinite Scroll

scroll.gif

image.png

こちらもどうやらこんなものを使っている。

抜粋.js
// Fetch posts from API
async function getPosts() {
  const res = await fetch(
    `https://jsonplaceholder.typicode.com/posts?_limit=${limit}&_page=${page}`
  );

  const data = await res.json();

  return data;
}

window.addEventListener('scroll', () => {
  const { scrollTop, scrollHeight, clientHeight } = document.documentElement;

  if (scrollTop + clientHeight >= scrollHeight - 5) {
    showLoading();
  }
});

// Show posts in DOM
async function showPosts() {
  const posts = await getPosts();

  posts.forEach(post => {
    const postEl = document.createElement('div');
    postEl.classList.add('post');
    postEl.innerHTML = `
      <div class="number">${post.id}</div>
      <div class="post-info">
        <h2 class="post-title">${post.title}</h2>
        <p class="post-body">${post.body}</p>
      </div>
    `;

    postsContainer.appendChild(postEl);
  });
}

// Show loader & fetch more posts
function showLoading() {
  loading.classList.add('show');
  setTimeout(() => {
    loading.classList.remove('show');
    setTimeout(() => {
      page++;
      showPosts();
    }, 300);
  }, 1000);
}

等など。動かしてみると少し分かる。

そのほか副産物

色々なPlaceholder発見。

Udemyの教材らしい

内容が充実しているのはそのはず、Udemyのコースの題材だからのようですが、GitHubを覗くだけなら上述のとおり。お得。

以上 GitHubのTrending に居たのを見つけたのでメモでした。お役に立てばさいわいです。

1
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
5