github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/ui/src/views/shared/components/userAvatar/index.tsx (about) 1 // Copyright 2019 The Cockroach Authors. 2 // 3 // Use of this software is governed by the Business Source License 4 // included in the file licenses/BSL.txt. 5 // 6 // As of the Change Date specified in that file, in accordance with 7 // the Business Source License, use of this software will be governed 8 // by the Apache License, Version 2.0, included in the file 9 // licenses/APL.txt. 10 11 import * as React from "react"; 12 import classNames from "classnames"; 13 14 import "./userAvatar.styl"; 15 16 export interface UserAvatarProps { 17 userName: string; 18 disabled?: boolean; 19 } 20 21 export default function UserAvatar(props: UserAvatarProps) { 22 const { 23 userName, 24 disabled = false, 25 } = props; 26 27 const classes = classNames("user-avatar", { 28 "user-avatar--disabled": disabled, 29 }); 30 31 const nameAbbreviation = userName[0].toUpperCase(); 32 33 return ( 34 <div className={classes}> 35 <div>{nameAbbreviation}</div> 36 </div> 37 ); 38 }