Angular アバターコンポーネント | ng-hub-ui-avatar
イニシャル、フォールバック画像、プレゼンスバッジ、CSS 変数を備えた Angular アバターコンポーネント。再利用可能なユーザー識別 UI を構築できます。
インタラクティブなサンプル
一般的な Angular のユースケースでライブラリがどのように動作するかを示すライブサンプルをご覧ください。
アバターのソース
ソーシャルプロフィール、カスタム画像、名前のイニシャル、またはカスタム値からアバターを解決し、自動フォールバックを備えています。
Facebook プロフィール
Gravatar
GitHub プロフィール
カスタム画像ソース
名前のイニシャル
値の表示
フォールバックシステム
意味のある表現が表示されるまで、設定されたすべてのソースを段階的にフォールバックします。
フォールバックシステム
Showing GitHub source (Facebook ID invalid)
サイズ設定
アバターの寸法、テキストとサイズの比率、レンダリングされるイニシャルの数を制御します。
カスタムサイズ
3.5remcalc(2rem + 12px)72 (pixels)テキストサイズ比率
イニシャルサイズの上限
スタイリング
形状、角の半径、色、ボーダー、任意のインラインスタイルはすべて、入力と CSS 変数によって駆動されます。
丸型アバター
角の丸み
背景色 & 前景色
--hub-avatar-bg-color ([autoColor]="false")いつでも読めるイニシャル
The automatic palette, as it paints today
Eight names, one per palette slot. Each avatar writes black or white on the colour its name hashed to, and the first ratio below it is read back from the two colours the browser actually painted. The second is what white initials would have scored on that same colour — what the component forced before 22.14.0, and what six of these eight would still be doing.
- GHmeasuring…
- ALmeasuring…
- LTmeasuring…
- BLmeasuring…
- DKmeasuring…
- ATmeasuring…
- KTmeasuring…
- ABmeasuring…
Those six are stated rather than shown on purpose: a row of white-on-yellow initials would be a page about readable labels printing six unreadable ones. An explicit fgColor does still win, contrast or not — that is how you pin the old look, and the snippet below is all it takes.
A palette the library has never seen
#ffcc00, #cccccc and #004080 — three colours the library ships no knowledge of. An application hands them to provideAvatar({ colors }) once at bootstrap; this demo scopes the same palette to its own avatars so it does not repaint the rest of the page. Either way the ink is derived from whatever colour ends up behind the text, so the guarantee travels with the background rather than with a list of approved pairings.
- VRmeasuring…
- INmeasuring…
- RPmeasuring…
枠線の色
カスタムスタイル
インタラクティビティ
アバターのクリックイベントでユーザーのインタラクションに反応します。
クリックイベントハンドラー
グループとバッジ
アバターをグループに重ね、角にバッジ(プレゼンスのドットやカウント)を重ねます。色はセマンティックパレットから。
アバターグループ表示
バッジ(ドット&カウント)
カスタムコンテンツ
任意のアイコン、インライン SVG、画像、絵文字をアバター内に投影できます。中央寄せ・パディング・アバター形状でのクリップが行われ、サイズは非依存に調整され(フォントアイコンは拡大、SVG/画像はフィット)、通常の bgColor / fgColor 入力でテーマ設定できます。
カスタムコンテンツ(アイコン・SVG)