zapret-kvn/xray_fluent/ui/about_us/icons.py
loop-uh cd84060021
Some checks failed
Windows project source guards / test (push) Failing after 2m6s
Show service logos on the "О нас" page
Each link gets its own SVG logo instead of one generic icon: Telegram for the bot
and channels, a book for the wiki, Git, Google Docs and GitHub (Gist). The logos
are real brand SVGs embedded as strings: simple-icons 16.x (CC0-1.0) and the
Material Icons menu_book (Apache-2.0). Brand logos keep their colour, GitHub and
the book follow the light or dark theme at paint time, and the bot button on the
accent colour draws its logo white.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-14 14:01:02 -05:00

69 lines
4.7 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""Значки сервисов для страницы «О нас»: настоящие логотипы в SVG, не эмодзи.
Контуры взяты из SVG без правок: Telegram, GitHub, Git и Google Docs — из набора
simple-icons 16.x (лицензия CC0-1.0), книга — из Material Icons ``menu_book``
(Apache-2.0, © Google). Названия и логотипы принадлежат их владельцам и нужны только
затем, чтобы человек узнал сервис. Все значки 24×24.
Модуль без Qt: SVG лежат строками, чтобы PyInstaller не терял файлы, а тесты могли их читать.
``brand`` — фирменный цвет: значок рисуется им и не перекрашивается. У ``None`` цвет
берёт тема (чёрный GitHub не виден на тёмном фоне): ``svg(fill)`` красит его цветом текста.
``mono=True`` красит одним цветом и фирменные значки: на цветной кнопке акцента синий Telegram
пропал бы.
"""
from __future__ import annotations
from dataclasses import dataclass
@dataclass(frozen=True, slots=True)
class BrandIcon:
key: str
brand: str | None
path: str
def svg(self, fill: str | None = None, *, mono: bool = False) -> str:
color = fill if fill and (mono or self.brand is None) else (self.brand or "#000000")
return (
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">'
f'<path fill="{color}" d="{self.path}"/></svg>'
)
@property
def follows_theme(self) -> bool:
return self.brand is None
TELEGRAM = BrandIcon(
"telegram",
"#26A5E4",
"M11.944 0A12 12 0 0 0 0 12a12 12 0 0 0 12 12 12 12 0 0 0 12-12A12 12 0 0 0 12 0a12 12 0 0 0-.056 0zm4.962 7.224c.1-.002.321.023.465.14a.506.506 0 0 1 .171.325c.016.093.036.306.02.472-.18 1.898-.962 6.502-1.36 8.627-.168.9-.499 1.201-.82 1.23-.696.065-1.225-.46-1.9-.902-1.056-.693-1.653-1.124-2.678-1.8-1.185-.78-.417-1.21.258-1.91.177-.184 3.247-2.977 3.307-3.23.007-.032.014-.15-.056-.212s-.174-.041-.249-.024c-.106.024-1.793 1.14-5.061 3.345-.48.33-.913.49-1.302.48-.428-.008-1.252-.241-1.865-.44-.752-.245-1.349-.374-1.297-.789.027-.216.325-.437.893-.663 3.498-1.524 5.83-2.529 6.998-3.014 3.332-1.386 4.025-1.627 4.476-1.635z",
)
BOOK = BrandIcon(
"book",
None,
"M21 5c-1.11-.35-2.33-.5-3.5-.5-1.95 0-4.05.4-5.5 1.5-1.45-1.1-3.55-1.5-5.5-1.5S2.45 4.9 1 6v14.65c0 .25.25.5.5.5.1 0 .15-.05.25-.05C3.1 20.45 5.05 20 6.5 20c1.95 0 4.05.4 5.5 1.5 1.35-.85 3.8-1.5 5.5-1.5 1.65 0 3.35.3 4.75 1.05.1.05.15.05.25.05.25 0 .5-.25.5-.5V6c-.6-.45-1.25-.75-2-1zm0 13.5c-1.1-.35-2.3-.5-3.5-.5-1.7 0-4.15.65-5.5 1.5V8c1.35-.85 3.8-1.5 5.5-1.5 1.2 0 2.4.15 3.5.5v11.5z M17.5 10.5c.88 0 1.73.09 2.5.26V9.24c-.79-.15-1.64-.24-2.5-.24-1.7 0-3.24.29-4.5.83v1.66c1.13-.64 2.7-.99 4.5-.99zM13 12.49v1.66c1.13-.64 2.7-.99 4.5-.99.88 0 1.73.09 2.5.26V11.9c-.79-.15-1.64-.24-2.5-.24-1.7 0-3.24.3-4.5.83zm4.5 1.84c-1.7 0-3.24.29-4.5.83v1.66c1.13-.64 2.7-.99 4.5-.99.88 0 1.73.09 2.5.26v-1.52c-.79-.16-1.64-.24-2.5-.24z",
)
GIT = BrandIcon(
"git",
"#F05032",
"M13.09 23.549a1.54 1.54 0 0 1-2.18 0L.451 13.089a1.54 1.54 0 0 1 0-2.179l7.191-7.19 2.733 2.733a1.85 1.85 0 0 0 .964 2.326v6.66a1.849 1.849 0 1 0 1.54 0V8.957l2.508 2.508a1.85 1.85 0 1 0 1.09-1.09l-2.634-2.634a1.85 1.85 0 0 0-2.378-2.377L8.73 2.63 10.91.451a1.54 1.54 0 0 1 2.179 0l10.459 10.46a1.54 1.54 0 0 1 0 2.179z",
)
GOOGLEDOCS = BrandIcon(
"googledocs",
"#4285F4",
"M14.727 6.727H14V0H4.91c-.905 0-1.637.732-1.637 1.636v20.728c0 .904.732 1.636 1.636 1.636h14.182c.904 0 1.636-.732 1.636-1.636V6.727h-6zm-.545 10.455H7.09v-1.364h7.09v1.364zm2.727-3.273H7.091v-1.364h9.818v1.364zm0-3.273H7.091V9.273h9.818v1.363zM14.727 6h6l-6-6v6z",
)
GITHUB = BrandIcon(
"github",
None,
"M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12",
)
ALL: dict[str, BrandIcon] = {icon.key: icon for icon in (TELEGRAM, BOOK, GIT, GOOGLEDOCS, GITHUB)}