UNPKG

@atlaskit/profilecard

Version:

A React component to display a card with user information.

147 lines 5.82 kB
/* main.tsx generated by @compiled/babel-plugin v0.36.1 */ import "./main.compiled.css"; import { ax, ix } from "@compiled/react/runtime"; import React, { useCallback, useMemo } from 'react'; import { FormattedMessage } from 'react-intl-next'; import { useAnalyticsEvents } from '@atlaskit/analytics-next'; import AvatarGroup from '@atlaskit/avatar-group'; import Heading from '@atlaskit/heading'; import { VerifiedTeamIcon } from '@atlaskit/people-teams-ui-public/verified-team-icon'; import { Box, Inline, Pressable, Stack, Text } from '@atlaskit/primitives/compiled'; import TeamAvatar from '@atlaskit/teams-avatar'; import { TeamContainers, useTeamContainers } from '@atlaskit/teams-public'; import { fireEvent } from '../../util/analytics'; import { TeamConnections } from './team-connections/main'; import { TeamContainersSkeleton } from './team-containers-skeleton'; const noop = () => {}; const styles = { wrapperStyles: "_2rkopd34 _v564nm7n _1reo15vq _18m915vq _1e0c1txw _2lx21bp4 _1bsb1gwv _1ul95x59 _4t3i1wug", containerStyles: "_otyrpxbi", avatarImageStyles: "_kqswstnw _18u01ejb", headerImageStyles: "_5ral1dfr _s7n4jp4b _4t3i53f4 _1bsb1osq", teamInformationStyles: "_18u01ejb _19pku2gc _2hwx1ejb", teamConnectionHeaderStyles: "_18u0u2gc _2hwxu2gc _c71lx2si _18m91wug", teamConnectionContainerStyles: "_18u01ejb _2hwx1ejb", connectionTitleStyles: "_11c81vhk _18u0pxbi _19pkpxbi _2hwxpxbi _otyr12x7 _syaz1gjq", viewProfileContainerStyles: "_4cvr1h6o _uwhke4h9 _15a5nqa1 _1i53muej _19bv1ejb _u5f31ejb", viewProfileButtonStyles: "_2rkoiti9 _189ee4h9 _1dqonqa1 _1h6dmuej _bfhksm61 _syaz1gjq _1bsb1osq _4t3i1ul9 _19pkpxbi" }; const TeamCardWrapper = ({ id, children }) => /*#__PURE__*/React.createElement(Box, { xcss: styles.wrapperStyles, testId: `team-card-${id}` }, children); const HeaderImage = ({ srcUrl }) => /*#__PURE__*/React.createElement(Box, { as: "img", src: srcUrl, xcss: styles.headerImageStyles, testId: "profile-header-image", alt: "team-header-image" }); export const TeamProfileCard = ({ containerId, teamId, displayName, description, avatarImageUrl, headerImageUrl, memberAvatars, memberCount, cloudId, userId, isVerified, teamProfileUrl }) => { const { teamContainers, loading } = useTeamContainers(teamId); const { createAnalyticsEvent } = useAnalyticsEvents(); // Ensure that the current container is not the only connection for this team before showing the "Where we work" section const hasOtherTeamConnections = useMemo(() => teamContainers.filter(tc => tc.id === containerId).length < teamContainers.length, [containerId, teamContainers]); const onClick = useCallback(() => { if (createAnalyticsEvent) { fireEvent(createAnalyticsEvent, { action: 'clicked', actionSubject: 'button', actionSubjectId: 'viewTeamProfileButton', attributes: {} }); } window.open(teamProfileUrl, '_blank'); }, [createAnalyticsEvent, teamProfileUrl]); return /*#__PURE__*/React.createElement(TeamCardWrapper, { id: teamId }, /*#__PURE__*/React.createElement(HeaderImage, { srcUrl: headerImageUrl }), /*#__PURE__*/React.createElement(Stack, { space: "space.200", xcss: styles.containerStyles }, /*#__PURE__*/React.createElement(Inline, { spread: "space-between", alignBlock: "center" }, /*#__PURE__*/React.createElement(Box, { xcss: styles.avatarImageStyles }, /*#__PURE__*/React.createElement(TeamAvatar, { size: "medium", src: avatarImageUrl }))), /*#__PURE__*/React.createElement(Stack, { xcss: styles.teamInformationStyles, space: "space.200" }, /*#__PURE__*/React.createElement(Stack, { space: "space.050" }, /*#__PURE__*/React.createElement(Inline, { alignBlock: "center" }, /*#__PURE__*/React.createElement(Heading, { size: "medium" }, displayName), isVerified && /*#__PURE__*/React.createElement(VerifiedTeamIcon, { showTooltip: true })), /*#__PURE__*/React.createElement(Text, { color: "color.text.subtlest" }, /*#__PURE__*/React.createElement(FormattedMessage, { defaultMessage: "Contributing team \u2022 {count, plural, one {# member} other {# members}}", values: { count: memberCount }, id: "people-and-teams.team-profile-card.member-count" }))), /*#__PURE__*/React.createElement(Inline, null, /*#__PURE__*/React.createElement(AvatarGroup, { appearance: "stack", data: memberAvatars })), description && /*#__PURE__*/React.createElement(Text, { color: "color.text", maxLines: 3 }, description)), (loading || hasOtherTeamConnections) && /*#__PURE__*/React.createElement(Box, { xcss: hasOtherTeamConnections ? styles.teamConnectionHeaderStyles : styles.teamConnectionContainerStyles }, hasOtherTeamConnections && /*#__PURE__*/React.createElement(Box, { xcss: styles.connectionTitleStyles }, /*#__PURE__*/React.createElement(FormattedMessage, { defaultMessage: "Where we work", id: "people-and-teams.team-profile-card.team-connections" })), /*#__PURE__*/React.createElement(TeamContainers, { teamId: teamId, onAddAContainerClick: noop, userId: userId, cloudId: cloudId, components: { ContainerCard: TeamConnections, TeamContainersSkeleton: TeamContainersSkeleton }, filterContainerId: containerId, isDisplayedOnProfileCard: true })), teamProfileUrl && /*#__PURE__*/React.createElement(Stack, { xcss: styles.viewProfileContainerStyles }, /*#__PURE__*/React.createElement(Pressable, { onClick: onClick, xcss: styles.viewProfileButtonStyles, testId: "view-profile-button" }, /*#__PURE__*/React.createElement(FormattedMessage, { defaultMessage: "View profile", id: "people-and-teams.team-profile-card.view-profile" }))))); };