0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

yarnでbootswatchをインストール

Posted at

環境

rails 6.0.3.2
yarn 1.22.10
bootstrap4.5(yarnで導入済)

インストール可能なバージョンを調べる

$ yarn info bootswatch | less
yarn info v1.22.10
{
  name: 'bootswatch',
  description: 'Bootswatch is a collection of themes for Bootstrap.',
  'dist-tags': {
    latest: '4.6.0',
    next: '4.0.0-beta.3',
    old: '3.4.1'
  },
  versions: [
==中略==
    '4.0.0-alpha.6',
    '4.0.0-beta.2',
    '4.0.0-beta.3',
==中略==
    '4.5.0',
    '4.5.1',
    '4.5.2',
    '4.5.3',
    '4.6.0'
  ],
==以下略==

4.6.0が最新のようだ。

インストール

$ yarn add bootswatch@4.6.0
==中略==
success Saved lockfile.
success Saved 1 new dependency.
info Direct dependencies
└─ bootswatch@4.6.0
info All dependencies
└─ bootswatch@4.6.0
✨  Done in 7.92s.

scssに追加

当たり前ですが、bootstrapは入ってる前提です。
app/app/javascript/src/application.scss
に以下を追記する。
※必ず「@import "~bootstrap/scss/bootstrap";」
を前(variables)と後(bootswatch)で挟む

app/javascript/src/application.scss
+ @import "~bootswatch/dist/[theme]/variables";
@import "~bootstrap/scss/bootstrap";
+@import "~bootswatch/dist/[theme]/bootswatch";

適用されているかテスト

前項の[theme]をテーマ名に変えて体裁を確認。
※nav.nav-barを
.navbar-dark.bg-primary
.navbar-dark.bg-dark
.navbar-light.bg-light
の3つ並べたものです。

sandstone

スクリーンショット 2021-01-30 14.48.03.png

solar

スクリーンショット 2021-01-30 14.47.05.png

minty

スクリーンショット 2021-01-30 14.49.08.png

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?