Ibigize
Wige uburyo n'impamvu twubaka hafi ibice byacu byose tubyitondeye kandi hamwe nibyiciro na modifier.
Ibyiciro shingiro
Ibice bya Bootstrap byubatswe ahanini hamwe na base-modifier nomenclature. Dutondekanya imitungo myinshi isangiwe muburyo bushoboka mubyiciro fatizo, nka .btn
, hanyuma hanyuma tugashyira hamwe uburyo butandukanye kuri buri gihinduka mubyiciro bihindura, nka .btn-primary
cyangwa .btn-success
.
Kubaka ibyiciro byacu byo guhindura, dukoresha @each
imirongo ya Sass kugirango dusubiremo ikarita ya Sass. Ibi bifasha cyane cyane kubyara ibice bigize ibice byacu $theme-colors
no gukora impinduka zishubije kuri buri gice. Mugihe uhinduye amakarita ya Sass hanyuma ukayasubiramo, uzahita ubona impinduka zawe zigaragara muriyi mirongo.
Reba amakarita yacu ya Sass hamwe nibisobanuro bya docs kugirango uhindure utwo tuzingo no kwagura uburyo bwa Bootstrap bwibanze-buhindura kode yawe.
Abahindura
Byinshi mubice bya Bootstrap byubatswe hamwe na base-modifier class approach. Ibi bivuze ko igice kinini cyimyandikire gikubiye mubyiciro fatizo (urugero, .btn
) mugihe imiterere itandukanye igarukira kumasomo yo guhindura (urugero, .btn-danger
). Aya masomo yo guhindura yubatswe kuva ku $theme-colors
ikarita kugirango uhindure umubare nizina ryibyiciro byacu byo guhindura.
Hano hari ingero ebyiri zuburyo tuzenguruka $theme-colors
ikarita kugirango tubyare impinduka .alert
kubigize .list-group
.
// Generate contextual modifier classes for colorizing the alert.
@each $state, $value in $theme-colors {
$alert-background: shift-color($value, $alert-bg-scale);
$alert-border: shift-color($value, $alert-border-scale);
$alert-color: shift-color($value, $alert-color-scale);
@if (contrast-ratio($alert-background, $alert-color) < $min-contrast-ratio) {
$alert-color: mix($value, color-contrast($alert-background), abs($alert-color-scale));
}
.alert-#{$state} {
@include alert-variant($alert-background, $alert-border, $alert-color);
}
}
// List group contextual variants
//
// Add modifier classes to change text and background color on individual items.
// Organizationally, this must come after the `:hover` states.
@each $state, $value in $theme-colors {
$list-group-variant-bg: shift-color($value, $list-group-item-bg-scale);
$list-group-variant-color: shift-color($value, $list-group-item-color-scale);
@if (contrast-ratio($list-group-variant-bg, $list-group-variant-color) < $min-contrast-ratio) {
$list-group-variant-color: mix($value, color-contrast($list-group-variant-bg), abs($list-group-item-color-scale));
}
@include list-group-item-variant($state, $list-group-variant-bg, $list-group-variant-color);
}
Igisubizo
Utuzingo twa Sass ntabwo tugarukira ku ikarita y'amabara, haba. Urashobora kandi kubyara itandukaniro ryibisubizo byibigize. Fata nk'urugero rwacu rwitondewe rwo guhuza ibitonyanga aho tuvanga @each
uruziga $grid-breakpoints
rw'ikarita ya Sass hamwe nibibazo by'itangazamakuru birimo.
// We deliberately hardcode the `bs-` prefix because we check
// this custom property in JS to determine Popper's positioning
@each $breakpoint in map-keys($grid-breakpoints) {
@include media-breakpoint-up($breakpoint) {
$infix: breakpoint-infix($breakpoint, $grid-breakpoints);
.dropdown-menu#{$infix}-start {
--bs-position: start;
&[data-bs-popper] {
right: auto;
left: 0;
}
}
.dropdown-menu#{$infix}-end {
--bs-position: end;
&[data-bs-popper] {
right: 0;
left: auto;
}
}
}
}
Ugomba guhindura ibyawe $grid-breakpoints
, impinduka zawe zizakoreshwa kumurongo wose usubiramo kurikarita.
$grid-breakpoints: (
xs: 0,
sm: 576px,
md: 768px,
lg: 992px,
xl: 1200px,
xxl: 1400px
);
Kubindi bisobanuro hamwe ningero zuburyo bwo guhindura amakarita yacu ya Sass nibihinduka, nyamuneka reba igice cya Sass cya Grid inyandiko .
Kurema ibyawe
Turagutera inkunga yo gukurikiza aya mabwiriza mugihe wubaka hamwe na Bootstrap kugirango ukore ibice byawe. Twaguye ubu buryo ubwacu kubice byabigenewe mu nyandiko zacu n'ingero. Ibigize nkumuhamagaro wacu byubatswe nkibikoresho byatanzwe hamwe nibyiciro byahinduwe.
<div class="callout">...</div>
Muri CSS yawe, wagira ikintu nkiki gikurikira aho igice kinini cyimyandikire ikorerwa .callout
. Hanyuma, uburyo budasanzwe hagati ya buri variant bugenzurwa hakoreshejwe icyiciro cyo guhindura.
// Base class
.callout {}
// Modifier classes
.callout-info {}
.callout-warning {}
.callout-danger {}
Kubaterefona, ubwo buryo budasanzwe ni a border-left-color
. Iyo uhujije iryo shuri shingiro nimwe muribyiciro byo guhindura, ubona umuryango wawe wuzuye: