Dokumentacja
Funkcje
Uzyskanie tłumaczenia
Pobranie komunikatu z mapy tłumaczeń.
Źródło
@function message($theme, $key) {
$message-key: $theme + ':' + $key;
@if not map-has-key($messages, $message-key) {
@error 'Nie znaleziono `#{$message-key}`.';
}
@return map-get($messages, $message-key);
}
Parametry
Nazwa |
Opis |
Typ |
Domyślnie |
$theme |
Albo advice , error , warning , albo obsolete |
String |
— |
$key |
Klucz do znalezienia wiadomości dla |
String |
— |
Używane przez
Uzyskanie konfiguracji motywu
Funkcja pomocnicza umożliwiająca łatwy dostęp do konfiguracji motywu.
Źródło
@function theme-conf($theme, $key) {
@return map-get(map-get($themes, $theme), $key);
}
Parametry
Nazwa |
Opis |
Typ |
Domyślnie |
$theme |
Albo advice , error , warning , albo obsolete |
String |
— |
$key |
Dane do uzyskania: color , index lub background-offset |
String |
— |
Przykład
Pobierz kolor błędu z motywu.
.selector {
color: theme-conf('error', 'color');
}
.selector {
color: #911;
}
Używane przez
Sprawdź poziom do wyświetlania
Przetestuj, czy $level
jest wystarczająco wysoki, by zostać wyświetlonym, porównując jego indeks do $minimum-level
.
Źródło
@function is-level-enough($level) {
$levels: map-keys($themes);
@return index($levels, $level) <= index($levels, $minimum-level);
}
Parametry
Nazwa |
Opis |
Type |
Domyślnie |
$level |
Albo advice , error , warning , albo obsolete |
String |
— |
Używane przez
Escape attr()
Zapewnia, że funkcja CSS attr()
będzie renderować oczekiwaną wartość, zamiast być wyprowadzoną jako ciąg znaków.
Źródło
@function replace-attr($message) {
$has-attr: str-index($message, 'attr(');
$first-paren: str-index($message, ')');
@if not $has-attr {
@return $message;
}
$first-chunk: str-slice($message, 1, $has-attr - 1);
$last-chunk: str-slice($message, $first-paren + 1);
$result: ();
@if str-length($first-chunk) > 0 {
$result: append($result, $first-chunk);
}
$result: append($result, unquote(str-slice($message, $has-attr, $first-paren)));
@if str-length($last-chunk) > 0 {
$result: append($result, replace-attr($last-chunk));
}
@return $result;
}
Parameters
Nazwa |
Opis |
Typ |
Domyślnie |
$message |
Komunikat do ucieczki |
String |
— |
Przykład
.selector {
content: replace-attr("ARIA role attr(role) powinien być unikalny, ale ten jest drugim!");
}
.selector {
content: "ARIA role " attr(role) "powinien być unikalny, ale ten jest drugim!";
}
Używane przez
Domieszki
Symbole zastępcze
Zmienne