Tɛmɛn ka taa kunnafoni kunbabaw la Tɛmɛn ka taa docs navigation kan
Check

Bootstrap bɛ dɛmɛ ni kulɛri caman ye min bɛ an ka cogoyaw ni an ka yɔrɔw barokunw di. O bɛ kɛ sababu ye ka fɛn caman kɛ ka kɛɲɛ ni mɔgɔw sago ye ani ka fɛnw fara ɲɔgɔn kan porozɛ o porozɛ kama.

Barokun kulɛriw

An bɛ baara Kɛ ni kulɛri bɛɛ kulu fitinin dɔ ye walasa ka kulɛri fitinin dɔ Dabɔ walasa ka kulɛriw labɛn, o fana bɛ Sɔrɔ i n’a fɔ Sass fɛn caman sɛgɛsɛgɛli ani Sass karti Bootstrap ka scss/_variables.scssdosiye kɔnɔ.

Fɔlɔ
Seginnkanni
Sanga
Farati
Lasɔmi
Info
Yeelen
Dibi

Nin kulɛri ninnu bɛɛ bɛ sɔrɔ i n’a fɔ Sass karti, $theme-colors.

$theme-colors: (
  "primary":    $primary,
  "secondary":  $secondary,
  "success":    $success,
  "info":       $info,
  "warning":    $warning,
  "danger":     $danger,
  "light":      $light,
  "dark":       $dark
);

Aw ye an ka Sass maps and loops docs lajɛ walasa ka nin kulɛriw ladilan cogo min na.

Kulɛriw bɛɛ

Bootstrap kulɛriw bɛɛ bɛ sɔrɔ i n’a fɔ Sass variables ani Sass map in scss/_variables.scssfile. Walasa ka dɔ fara dosiye hakɛw kan, an tɛ sɛbɛnni walima kɔkanna kulɛri kalasiw Dabɔ o fɛn caman ɲɔgɔnna kelen-kelen bɛɛ kama. O nɔ na, ​​an bɛ o kulɛriw kulu fitinin dɔ sugandi barokun palɛti dɔ kama .

Aw ye aw jija ka danfara hakɛw kɔlɔsi ni aw bɛ kulɛriw labɛn ka kɛɲɛ ni aw yɛrɛ sago ye. I n’a fɔ a jiralen bɛ cogo min na jukɔrɔ, an ye danfara saba fara kulɛri kunbaba kelen-kelen bɛɛ kan—kelen ye swatch ka kulɛriw ye minnu bɛ yen sisan, kelen ye fin ye, kelen ye nɛrɛ ye.

$bulu ye#0d6efd ye
$bulu-100 ye
$bulu-200 ye
$bulu-300 ye
$bulu-400 ye
$bulu-500 ye
$bulu-600 ye
$bulu-700 ye
$bulu-800 ye
$bulu-900 ye
$indigo ye#6610f2 ye
$indigo-100 ye
$indigo-200 ye
$indigo-300 ye
$indigo-400 ye
$indigo-500 ye
$indigo-600 ye
$indigo-700 ye
$indigo-800 ye
$indigo-900 ye
$purple ye#6f42c1 ye
$purple-100 ye
$purple-200 ye
$purple-300 ye
$purple-400 ye
$purple-500 ye
$purple-600 ye
$purple-700 ye
$purple-800 ye
$purple-900 ye
$pink ye#d63384 ye
$pink-100 ye
$pink-200 ye
$pink-300 ye
$pink-400 ye
$pink-500 ye
$pink-600 ye
$pink-700 ye
$pink-800 ye
$pink-900 ye
$red ye#dc3545 ye
$red-100 ye
$red-200 ye
$red-300 ye
$red-400 ye
$red-500 ye
$red-600 ye
$red-700 ye
$red-800 ye
$red-900 ye
$orange ye# fd7e14 ye
$orange-100 ye
$orange-200 ye
$orange-300 ye
$orange-400 ye
$orange-500 ye
$orange-600 ye
$orange-700 ye
$orange-800 ye
$orange-900 ye
$jɛman#ffc107 ye
$jɛ-100 ye
$jɛ-200 ye
$jɛman-300 ye
$jɛman-400 ye
$jɛman-500 ye
$jɛman-600 ye
$jɛman-700 ye
$jɛman-800 ye
$jɛman-900 ye
$green ye#198754 ye
$green-100 ye
$green-200 ye
$green-300 ye
$green-400 ye
$green-500 ye
$green-600 ye
$green-700 ye
$green-800 ye
$green-900 ye
$teal ye#20c997 ye
$teal-100 ye
$teal-200 ye
$teal-300 ye
$teal-400 ye
$teal-500 ye
$teal-600 ye
$teal-700 ye
$teal-800 ye
$teal-900 ye
$cyan ye#0dcaf0 ye
$cyan-100 ye
$cyan-200 ye
$cyan-300 ye
$cyan-400 ye
$cyan-500 ye
$cyan-600 ye
$cyan-700 ye
$cyan-800 ye
$cyan-900 ye
$gri-500 ye#adb5bd ye
$gri-100 ye
$gri-200 ye
$gri-300 ye
$gri-400 ye
$gri-500 ye
$gri-600 ye
$gri-700 ye
$gri-800 ye
$gri-900 ye
$nɛrɛma#000 ye
$nɛrɛmuguma#fff ye

Kɔlɔsiliw Sass kan

Sass tɛ Se ka fɛn caman sɛgɛsɛgɛli Kɛ porogaramu fɛ, o de kama an ye fɛn caman Dabɔ ni bolo ye tintin ni biɲɛ kelen-kelen bɛɛ kama an yɛrɛ ye. An bɛ cɛmancɛ-yɔrɔ nafa jira (misali la, $blue-500) ani ka baara kɛ ni kulɛri baarakɛcogo ladamulenw ye walasa ka an ka kulɛriw tintin (ka yeelen bɔ) walima ka u bonya (ka dibi) Sass ka mix()kulɛri baarakɛcogo fɛ.

Baara kɛli mix()ni lighten()ani darken()—fɔlɔ bɛ kulɛri kofɔlen ɲagami ni finman walima nɛrɛmuguma ye, k’a sɔrɔ filanan bɛ kulɛri kelen-kelen bɛɛ nɔgɔya nafa dɔrɔn de ladilan. O kɔlɔlɔ ye kulɛriw suite dafalen ye kosɛbɛ, i n’a fɔ a jiralen bɛ cogo min na nin CodePen demo in kɔnɔ .

An ka tint-color()ni shade-color()baarakɛcogo bɛ baara Kɛ mix()an ka $theme-color-intervalfɛn caman sɛgɛsɛgɛli kɛrɛfɛ, o min bɛ kɛmɛsarada la nafa dɔ Jira an bɛ min Bɔ kulɛri ɲagaminen kelen-kelen bɛɛ la. Aw ye scss/_functions.scssani scss/_variables.scssfilenw lajɛ walasa ka kunnafoni sɔrɔyɔrɔ dafalen sɔrɔ.

Kulɛri Sass ka kartiw

Bootstrap ka source Sass files kɔnɔ, karti saba bɛ yen minnu b’i dɛmɛ ka teliya ani ka loop kɛ kulɛriw lisɛli kan ani u hex values.

  • $colorsbɛ an ka basigi ( 500) kulɛriw bɛɛ jira minnu bɛ sɔrɔ
  • $theme-colorsbɛ barokun kulɛriw bɛɛ tɔgɔ fɔ kɔrɔko siratigɛ la (a jiralen bɛ jukɔrɔ) .
  • $graysbɛ ɲɛgɛnw ni ɲɛgɛnw bɛɛ lajɛlen jira

, kɔnɔ scss/_variables.scss, i bɛ Bootstrap ka kulɛri caman ɲɔgɔnna sɔrɔ ani Sass karti. $colorsSass karti misali dɔ filɛ nin ye :

$colors: (
  "blue":       $blue,
  "indigo":     $indigo,
  "purple":     $purple,
  "pink":       $pink,
  "red":        $red,
  "orange":     $orange,
  "yellow":     $yellow,
  "green":      $green,
  "teal":       $teal,
  "cyan":       $cyan,
  "black":      $black,
  "white":      $white,
  "gray":       $gray-600,
  "gray-dark":  $gray-800
);

Nafaw fara ɲɔgɔn kan, ka bɔ yen, walima ka fɛn dɔw sɛmɛntiya karti kɔnɔ walasa ka u baaracogo kura ye yɔrɔ caman wɛrɛw la. A fɔ man di nka nin waati in na, yɔrɔ bɛɛ tɛ baara kɛ ni Sass karti in ye. Kuma kura nataw bɛna an jija ka ɲɛtaa kɛ o ko la. Fɔ ka se o waati ma, aw bɛ labɛn kɛ ka baara kɛ ni ${color}fɛn caman sɛgɛsɛgɛli ye ani nin Sass karti in.

Misaliya

Aw bɛ se ka baara kɛ ni ninnu ye cogo min na aw ka Sass kɔnɔ, o filɛ nin ye:

.alpha { color: $purple; }
.beta {
  color: $yellow-300;
  background-color: $indigo-900;
}

Kulɛri ni kɔkanna nafama kalanw fana bɛ sɔrɔ walasa ka kulɛri nafaw sigi colorani ka background-colorbaara kɛ ni u ye.500

Nafamafɛnw sɔrɔli

A farala a kan v5.1.0 kɔnɔ

Bootstrap tɛ colorni background-colornafalanw ye kulɛri caman ɲɔgɔnna bɛɛ la, nka i bɛ se ka ninnu labɛn i yɛrɛ ye ni an ka nafamafɛnw API ye ani an ka Sass kartiw janyalenw faralen ɲɔgɔn kan v5.1.0 kɔnɔ.

  1. Walasa ka daminɛ, aw ye aw jija ka an ka baarakɛcogo, fɛn caman sɛgɛsɛgɛli, mixins ani nafamafɛnw don.
  2. Baara kɛ n’an ka map-merge-multiple()baarakɛcogo ye walasa ka Sass karti caman fara ɲɔgɔn kan teliya la karti kura kɔnɔ.
  3. Nin karti faralen kura in fara ɲɔgɔn kan walasa ka nafamafɛn o nafalan janya ni {color}-{level}kalasi tɔgɔ ye.

Misali dɔ filɛ nin ye min bɛ sɛbɛnni kulɛri nafalanw (misali la, .text-purple-500) lawuli ni sanfɛla fɛɛrɛw ye.

@import "bootstrap/scss/functions";
@import "bootstrap/scss/variables";
@import "bootstrap/scss/maps";
@import "bootstrap/scss/mixins";
@import "bootstrap/scss/utilities";

$all-colors: map-merge-multiple($blues, $indigos, $purples, $pinks, $reds, $oranges, $yellows, $greens, $teals, $cyans);

$utilities: map-merge(
  $utilities,
  (
    "color": map-merge(
      map-get($utilities, "color"),
      (
        values: map-merge(
          map-get(map-get($utilities, "color"), "values"),
          (
            $all-colors
          ),
        ),
      ),
    ),
  )
);

@import "bootstrap/scss/utilities/api";

O bɛna nafamafɛn kuraw lawuli .text-{color}-{level}kulɛri ni hakɛ bɛɛ la. Aw bɛ se k’o ɲɔgɔn kɛ nafamafɛn wɛrɛw ni nafolo wɛrɛw fana na.