Skip to content

Commit 2c6a4fd

Browse files
Merge pull request #650 from zendesk/maciejlorens/GG-4327-cph-theme-display-thumbnails-in-the-services-page
feat: display thumbnails in the services item list
2 parents 31a39ae + 86c199a commit 2c6a4fd

File tree

7 files changed

+51
-15
lines changed

7 files changed

+51
-15
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import ShapesIcon from "@zendeskgarden/svg-icons/src/16/shapes-fill.svg";
2+
import styled from "styled-components";
3+
import { getColorV8 } from "@zendeskgarden/react-theming";
4+
import { Avatar } from "@zendeskgarden/react-avatars";
5+
6+
const StyledAvatar = styled(Avatar)<{ size: "medium" | "large" }>`
7+
background-color: ${(props) => getColorV8("grey", 100, props.theme)};
8+
width: ${(props) => (props.size === "large" ? 72 : 40)}px !important;
9+
height: ${(props) => (props.size === "large" ? 72 : 40)}px !important;
10+
11+
&& > svg {
12+
width: ${(props) => (props.size === "large" ? 28 : 16)}px;
13+
height: ${(props) => (props.size === "large" ? 28 : 16)}px;
14+
color: ${(props) => getColorV8("grey", 600, props.theme)};
15+
}
16+
`;
17+
18+
type ItemThumbnailProps = {
19+
size: "medium" | "large";
20+
url?: string | null;
21+
};
22+
23+
export const ItemThumbnail = ({ size, url }: ItemThumbnailProps) => {
24+
return (
25+
<StyledAvatar size={size} isSystem>
26+
{url ? <img src={url} alt="" /> : <ShapesIcon aria-hidden="true" />}
27+
</StyledAvatar>
28+
);
29+
};

src/modules/service-catalog/components/service-catalog-item/CollapsibleDescription.tsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import ChevronDown from "@zendeskgarden/svg-icons/src/16/chevron-down-fill.svg";
66
import { useTranslation } from "react-i18next";
77
import { getColorV8 } from "@zendeskgarden/react-theming";
88
import { XXXL } from "@zendeskgarden/react-typography";
9+
import { ItemThumbnail } from "../item-thumbnail/ItemThumbnail";
910

1011
const DescriptionWrapper = styled.div`
1112
border-bottom: ${(props) => props.theme.borders.sm}
@@ -20,6 +21,7 @@ const DescriptionWrapper = styled.div`
2021

2122
const ItemTitle = styled(XXXL)`
2223
font-weight: ${(props) => props.theme.fontWeights.semibold};
24+
margin-bottom: 0;
2325
`;
2426

2527
const CollapsibleText = styled.div<{ expanded: boolean }>`
@@ -44,16 +46,25 @@ const ToggleButton = styled(Button)`
4446
}
4547
`;
4648

49+
const HeaderContainer = styled.div`
50+
display: flex;
51+
flex-direction: row;
52+
align-items: center;
53+
gap: ${(props) => props.theme.space.md};
54+
`;
55+
4756
interface CollapsibleDescriptionProps {
4857
title: string;
4958
description: string;
59+
thumbnailUrl: string;
5060
}
5161

5262
const DESCRIPTION_LENGTH_THRESHOLD = 270;
5363

5464
export const CollapsibleDescription = ({
5565
title,
5666
description,
67+
thumbnailUrl,
5768
}: CollapsibleDescriptionProps) => {
5869
const [isExpanded, setIsExpanded] = useState<boolean>(false);
5970
const { t } = useTranslation();
@@ -66,7 +77,10 @@ export const CollapsibleDescription = ({
6677

6778
return (
6879
<DescriptionWrapper>
69-
<ItemTitle tag="h1">{title}</ItemTitle>
80+
<HeaderContainer>
81+
<ItemThumbnail size="large" url={thumbnailUrl} />
82+
<ItemTitle tag="h1">{title}</ItemTitle>
83+
</HeaderContainer>
7084
{description && (
7185
<CollapsibleText
7286
className="service-catalog-description"

src/modules/service-catalog/components/service-catalog-item/ItemRequestForm.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ export function ItemRequestForm({
113113
<CollapsibleDescription
114114
title={serviceCatalogItem.name}
115115
description={serviceCatalogItem.description}
116+
thumbnailUrl={serviceCatalogItem.thumbnail_url}
116117
/>
117118
<FieldsContainer>
118119
{requestFields.map((field) => (

src/modules/service-catalog/components/service-catalog-list/ServiceCatalogListItem.spec.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ describe("ServiceCatalogListItem", () => {
3030
name: "Atl Nacional keyboard",
3131
description: "This is a keyboard from Atl Nacional",
3232
form_id: 456,
33+
thumbnail_url: "",
3334
};
3435

3536
const mockHelpCenterPath = "/hc/en-us";

src/modules/service-catalog/components/service-catalog-list/ServiceCatalogListItem.tsx

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { ServiceCatalogItem } from "../../data-types/ServiceCatalogItem";
2-
import ShapesIcon from "@zendeskgarden/svg-icons/src/16/shapes-fill.svg";
32
import styled from "styled-components";
43
import { getColorV8 } from "@zendeskgarden/react-theming";
4+
import { ItemThumbnail } from "../item-thumbnail/ItemThumbnail";
55

66
const ItemContainer = styled.a`
77
display: flex;
@@ -48,16 +48,7 @@ const TextContainer = styled.div`
4848
align-items: flex-start;
4949
gap: ${(props) => props.theme.space.xxs};
5050
color: ${(props) => props.theme.colors.foreground};
51-
`;
52-
53-
const IconContainer = styled.div`
54-
color: ${(props) => getColorV8("grey", 600, props.theme)};
55-
background-color: ${(props) => getColorV8("grey", 100, props.theme)};
56-
margin-bottom: ${(props) => props.theme.space.sm};
57-
width: ${(props) => props.theme.space.xl};
58-
height: ${(props) => props.theme.space.xl};
59-
text-align: center;
60-
align-content: center;
51+
margin-top: ${(props) => props.theme.space.sm};
6152
`;
6253

6354
const ServiceCatalogListItem = ({
@@ -72,9 +63,7 @@ const ServiceCatalogListItem = ({
7263
data-testid="service-catalog-list-item-container"
7364
href={`${helpCenterPath}/services/${serviceItem.id}`}
7465
>
75-
<IconContainer>
76-
<ShapesIcon />
77-
</IconContainer>
66+
<ItemThumbnail size="medium" url={serviceItem.thumbnail_url} />
7867
<TextContainer>
7968
<ItemTitle>{serviceItem.name}</ItemTitle>
8069
<ItemDescription>{serviceItem.description}</ItemDescription>

src/modules/service-catalog/data-types/ServiceCatalogItem.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ export interface ServiceCatalogItem {
33
name: string;
44
description: string;
55
form_id: number;
6+
thumbnail_url: string;
67
}

src/modules/service-catalog/hooks/useItemFormFields.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ describe("useItemFormFields", () => {
88
name: "Test Item",
99
description: "Test Description",
1010
form_id: 1,
11+
thumbnail_url: "",
1112
};
1213

1314
const textField = {

0 commit comments

Comments
 (0)