dev

ThemeBasedStyling, bir HTML öğesinin satır içi stillerinin her iki FandomDesktop varyasyonuna da uyum sağlamasına olanak tanır. Ek olarak, hangi varyasyonun kullanıldığına bağlı olarak farklı içeriklerin görünmesini sağlayabilirsiniz.

Installation

Bu geliştirmenin iki versiyonu (açık ve koyu) olan FandomDesktop görünümü için özel olduğu gerçeğine dayanarak, bunun yerine bu stil sayfasını MediaWiki:FandomDesktop.css içine yükleyebilirsiniz.

Usage

Satir içi özelleştirme

Bir ögeyi mevcut FandomDesktop varyasyonuna göre farklı stiller kullanacak şekilde yapmak için sınıfına tbs-* eklemeniz gerekir (burada * tam olarak CSS özniteliğinin adıdır), ardından satır içi stiline --tbs-light-* ve --tbs-dark-* CSS değişkenlerini ekleyin. Değişkenleri belirtmezseniz, varsayılan değerleri kullanılacaktır.

Desteklenen stiller ve varsayılan değerler
Desteklenen Öznitelikler İlgili Sınıf Adı İlgili Değişkenler[ref 1] Varsayılan Değer
background-color tbs-background-color --tbs-*-background-color var(--theme-page-background-color--secondary)
border-bottom-color tbs-border-bottom-color --tbs-*-border-bottom-color var(--theme-border-color)
border-color tbs-border-color --tbs-*-border-color var(--theme-border-color)
border-left-color tbs-border-left-color --tbs-*-border-left-color var(--theme-border-color)
border-right-color tbs-border-right-color --tbs-*-border-right-color var(--theme-border-color)
border-top-color tbs-border-top-color --tbs-*-border-top-color var(--theme-border-color)
box-shadow tbs-box-shadow --tbs-*-box-shadow none
caret-color tbs-caret-color --tbs-*-caret-color var(--theme-page-text-color)
color tbs-color --tbs-*-color var(--theme-page-text-color)
column-rule-color tbs-column-rule-color --tbs-*-column-rule-color var(--theme-border-color)
outline-color tbs-outline-color --tbs-*-outline-color var(--theme-border-color)
text-decoration-color tbs-text-decoration-color --tbs-*-text-decoration-color var(--theme-page-text-color)
  1. Here * should be replaced with either light or dark.

Örneğin:

<div class="tbs-background-color tbs-border-color tbs-color" style="
  border-radius: 5px;
  border-style: solid;
  border-width: 3px;
  margin: auto;
  padding: 12px;
  width: 80%;
  --tbs-light-background-color: azure;
  --tbs-light-border-color: cornflowerblue;
  --tbs-light-color: blue;
  --tbs-dark-background-color: darkblue;
  --tbs-dark-border-color: darkviolet;
  --tbs-dark-color: cornflowerblue;">
<p style="margin: 0;">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</div>

Sonuç (farkı kontrol etmek için diğer temaya geçin):

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Tema tabanlı içerik

tbs-display sınıfına sahip ögelerde, only-light ve dark-only sınıflarını kullanarak mevcut temaya göre hangi içeriklerin görüntülenebileceğine karar verebilirsiniz.

Örneğin:

<div class="tbs-background-color tbs-border-color tbs-display" style="border-width: 2px; border-style: solid; padding: 12px;">Şu anda bu web sayfasını FandomDesktop görünümün <span class="light-only">açık</span><span><span class="dark-only">koyu</span> temasıyla görüntülüyorsunuz.</div>

Sonuç (farkı kontrol etmek için diğer temaya geçin):

Şu anda bu web sayfasını FandomDesktop görünümün açıkkoyu temasıyla görüntülüyorsunuz.

(Yukarıdaki örnek, değişkenlerin ataması kaldırıldığında varsayılan CSS değerlerinin nasıl kullanıldığını da gösterir)

Ara söz

CSS kodları, aşağıdaki Python betiğini çalıştırarak oluşturulabilir:

attributes = (
    ( "background-color",      "page-background-color--secondary"),
    ( "border-bottom-color",   "border-color"),
    ( "border-color",          "border-color"),
    ( "border-left-color",     "border-color"),
    ( "border-right-color",    "border-color"),
    ( "border-top-color",      "border-color"),
    ( "box-shadow",            None),
    ( "caret-color",           "page-text-color"),
    ( "color",                 "page-text-color"),
    ( "column-rule-color",     "border-color"),
    ( "outline-color",         "border-color"),
    ( "text-decoration-color", "page-text-color")
)
with open("ThemeBasedStyling.css", "w") as fout:
    for attr in attributes:
        for theme in ("light", "dark"):
            fout.write(
                ".theme-fandomdesktop-{0} .tbs-{1} {2}\n"
                "\t--tbs-{0}-{1}: {4};\n"
                "\t{1}: var(--tbs-{0}-{1});\n{3}\n".format(
                    theme, attr[0], "{", "}",
                    f"var(--theme-{attr[1]})" if attr[1] else "none"
                )
            )
    fout.write(
        ".theme-fandomdesktop-dark .tbs-display .light-only,\n"
        ".theme-fandomdesktop-light .tbs-display .dark-only {\n"
        "\tdisplay: none;\n}"
    )

Farklı temalara uyum sağlamasına izin verilen çok daha fazla özellik istiyorsanız, bu Python betiğini düzenleyebilir ve yeni bir CSS seti oluşturabilirsiniz.

See also