Giter VIP home page Giter VIP logo

viewcomponent-hotwire-tailwindcss's Introduction

ViewComponent + Hotwire + TailwindCSS

Rails7, Hotwire, ViewComponent, TailwindCSS でのサンプルプロジェクト.

Hotwire + ViewComponent + TailwindCSS の組み合わせにより、/componentsでコンポーネント指向な実装を目指す.


Categories


Version

  • Ruby 3.2.2
  • Rails 7.0.4
  • Tailwind CSS

Install

1. node_modules フォルダを作成

Docker Componse で node_modules ボリュームをバインドするために必要.

./
  ├─ app
  ├─ ...
  ├─ node_modules // このフォルダを作成
  └─ ...

2. env ファイルを作成

.envに記述したクレデンシャルは、docker-compose.yml経由でプロジェクト内に環境変数として登録される.(※本プロジェクトでは未使用)

./
  ├─ app
  ├─ ...
  ├─ .env // このファイルを作成
  └─ ...

3. Docker イメージを作成

docker compose build

4. database を作成

docker compose run web rails db:create && rails db:migrate

4. seed データを投入

docker compose run web rails db:seed

5. プロジェクトを起動

docker compose up

6. seed ファイルに定義したアカウントでログイン

id pass
[email protected] example
[email protected] example

7. 画面にアクセス

ブラウザから各画面にアクセスして表示されることを確認.

画面名 URL
タスク一覧画面 http://localhost:3000/tasks
ログイン画面 http://localhost:3000/sign_in

8. 完了

Command

  • view_component と stimulus コントローラをジェネレート
    • rails generate component Hoge::Fuga --stimulus --preview
  • stimulus コントローラを index.js に登録(rake コマンドで拡張したもの)
    • rails view_component:stimulus_manifest:update

Other

ViewComponentのプレビュー

/rails/view_componentsからコンポーネント単位でのプレビューを確認できる

viewcomponent-hotwire-tailwindcss's People

Contributors

kuroweb avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

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.