mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Usign avatar in catalog entity details
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
parent
4f11eedd06
commit
1e00ec977e
@ -33,9 +33,8 @@
|
|||||||
margin-right: calc(var(--margin) * 3);
|
margin-right: calc(var(--margin) * 3);
|
||||||
|
|
||||||
.avatar {
|
.avatar {
|
||||||
:global(.MuiAvatar-root) {
|
font-size: 3ch;
|
||||||
font-size: 3ch;
|
cursor: pointer;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.hint {
|
.hint {
|
||||||
|
|||||||
@ -27,10 +27,10 @@ import type { CatalogCategory, CatalogEntity } from "../../../common/catalog";
|
|||||||
import { Icon } from "../icon";
|
import { Icon } from "../icon";
|
||||||
import { CatalogEntityDrawerMenu } from "./catalog-entity-drawer-menu";
|
import { CatalogEntityDrawerMenu } from "./catalog-entity-drawer-menu";
|
||||||
import { CatalogEntityDetailRegistry } from "../../../extensions/registries";
|
import { CatalogEntityDetailRegistry } from "../../../extensions/registries";
|
||||||
import { HotbarIcon } from "../hotbar/hotbar-icon";
|
|
||||||
import type { CatalogEntityItem } from "./catalog-entity-item";
|
import type { CatalogEntityItem } from "./catalog-entity-item";
|
||||||
import { isDevelopment } from "../../../common/vars";
|
import { isDevelopment } from "../../../common/vars";
|
||||||
import { cssNames } from "../../utils";
|
import { cssNames } from "../../utils";
|
||||||
|
import { Avatar } from "../avatar/avatar";
|
||||||
|
|
||||||
interface Props<T extends CatalogEntity> {
|
interface Props<T extends CatalogEntity> {
|
||||||
item: CatalogEntityItem<T> | null | undefined;
|
item: CatalogEntityItem<T> | null | undefined;
|
||||||
@ -60,17 +60,14 @@ export class CatalogEntityDetails<T extends CatalogEntity> extends Component<Pro
|
|||||||
{showDetails && (
|
{showDetails && (
|
||||||
<div className="flex">
|
<div className="flex">
|
||||||
<div className={styles.entityIcon}>
|
<div className={styles.entityIcon}>
|
||||||
<HotbarIcon
|
<Avatar
|
||||||
uid={item.id}
|
|
||||||
title={item.name}
|
title={item.name}
|
||||||
source={item.source}
|
colorHash={`${item.name}-${item.source}`}
|
||||||
src={item.entity.spec.icon?.src}
|
|
||||||
material={item.entity.spec.icon?.material}
|
|
||||||
background={item.entity.spec.icon?.background}
|
|
||||||
disabled={!item?.enabled}
|
|
||||||
onClick={() => item.onRun()}
|
|
||||||
size={128}
|
size={128}
|
||||||
|
src={item.entity.spec.icon?.src}
|
||||||
data-testid="detail-panel-hot-bar-icon"
|
data-testid="detail-panel-hot-bar-icon"
|
||||||
|
background={item.entity.spec.icon?.background}
|
||||||
|
onClick={() => item.onRun()}
|
||||||
className={styles.avatar}
|
className={styles.avatar}
|
||||||
/>
|
/>
|
||||||
{item?.enabled && (
|
{item?.enabled && (
|
||||||
|
|||||||
@ -219,8 +219,7 @@ export class Catalog extends React.Component<Props> {
|
|||||||
src={item.entity.spec.icon?.src}
|
src={item.entity.spec.icon?.src}
|
||||||
background={item.entity.spec.icon?.background}
|
background={item.entity.spec.icon?.background}
|
||||||
className={styles.catalogAvatar}
|
className={styles.catalogAvatar}
|
||||||
width={24}
|
size={24}
|
||||||
height={24}
|
|
||||||
>
|
>
|
||||||
{item.entity.spec.icon?.material && <Icon material={item.entity.spec.icon?.material}/>}
|
{item.entity.spec.icon?.material && <Icon material={item.entity.spec.icon?.material}/>}
|
||||||
</Avatar>
|
</Avatar>
|
||||||
|
|||||||
@ -28,6 +28,7 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
user-select: none;
|
||||||
|
|
||||||
img {
|
img {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|||||||
@ -29,8 +29,7 @@ import { cssNames, iter } from "../../utils";
|
|||||||
interface Props extends DOMAttributes<any> {
|
interface Props extends DOMAttributes<any> {
|
||||||
title: string;
|
title: string;
|
||||||
colorHash?: string;
|
colorHash?: string;
|
||||||
width?: number;
|
size?: number;
|
||||||
height?: number;
|
|
||||||
src?: string;
|
src?: string;
|
||||||
className?: string;
|
className?: string;
|
||||||
background?: string;
|
background?: string;
|
||||||
@ -73,7 +72,7 @@ function getLabelFromTitle(title: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function Avatar(props: Props) {
|
export function Avatar(props: Props) {
|
||||||
const { title, width = 32, height = 32, variant = "rounded", colorHash, children, background, imgProps, src, className, ...rest } = props;
|
const { title, variant = "rounded", size, colorHash, children, background, imgProps, src, className, ...rest } = props;
|
||||||
|
|
||||||
const getBackgroundColor = () => {
|
const getBackgroundColor = () => {
|
||||||
return background || randomColor({ seed: colorHash, luminosity: "dark" });
|
return background || randomColor({ seed: colorHash, luminosity: "dark" });
|
||||||
@ -93,7 +92,7 @@ export function Avatar(props: Props) {
|
|||||||
[styles.circle]: variant == "circle",
|
[styles.circle]: variant == "circle",
|
||||||
[styles.rounded]: variant == "rounded",
|
[styles.rounded]: variant == "rounded",
|
||||||
}, className)}
|
}, className)}
|
||||||
style={{ width: `${width}px`, height: `${height}px`, backgroundColor: getBackgroundColor() }}
|
style={{ width: `${size}px`, height: `${size}px`, backgroundColor: getBackgroundColor() }}
|
||||||
{...rest}
|
{...rest}
|
||||||
>
|
>
|
||||||
{renderContents()}
|
{renderContents()}
|
||||||
|
|||||||
@ -90,8 +90,7 @@ export const HotbarIcon = observer(({ menuItems = [], size = 40, tooltip, ...pro
|
|||||||
title={title}
|
title={title}
|
||||||
colorHash={`${title}-${source}`}
|
colorHash={`${title}-${source}`}
|
||||||
className={cssNames(active ? "active" : "default", { interactive: !!onClick })}
|
className={cssNames(active ? "active" : "default", { interactive: !!onClick })}
|
||||||
width={size}
|
size={size}
|
||||||
height={size}
|
|
||||||
src={src}
|
src={src}
|
||||||
>
|
>
|
||||||
{material && <Icon className="materialIcon" material={material} />}
|
{material && <Icon className="materialIcon" material={material} />}
|
||||||
|
|||||||
@ -108,8 +108,7 @@ export function SidebarCluster({ clusterEntity }: { clusterEntity: CatalogEntity
|
|||||||
<Avatar
|
<Avatar
|
||||||
title={metadata.name}
|
title={metadata.name}
|
||||||
colorHash={`${metadata.name}-${metadata.source}`}
|
colorHash={`${metadata.name}-${metadata.source}`}
|
||||||
width={40}
|
size={40}
|
||||||
height={40}
|
|
||||||
src={spec.icon?.src}
|
src={spec.icon?.src}
|
||||||
className={styles.avatar}
|
className={styles.avatar}
|
||||||
/>
|
/>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user