Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Composer/packages/client/src/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const headerContainer = css`
background: ${SharedColors.cyanBlue10};
height: 50px;
display: flex;
min-width: 1200px;
Comment thread
zhixzhan marked this conversation as resolved.
Outdated
flex-direction: row;
align-items: center;
`;
Expand Down
108 changes: 100 additions & 8 deletions Composer/packages/client/src/pages/home/CardWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,114 @@
// Licensed under the MIT License.

/** @jsx jsx */
import { jsx } from '@emotion/core';
import React from 'react';
import { jsx, SerializedStyles } from '@emotion/core';
import React, { useState } from 'react';
import { Image, ImageFit, ImageLoadState } from 'office-ui-fabric-react/lib/Image';
import { Link } from 'office-ui-fabric-react/lib/Link';

import defaultArticleCardCover from '../../images/defaultArticleCardCover.svg';
import defaultVideoCardCover from '../../images/defaultVideoCardCover.svg';

import { ItemContainer, ItemContainerProps } from './ItemContainer';
import { itemContainerWrapper } from './styles';
import * as home from './styles';

interface CardWidgetProps extends ItemContainerProps {
export interface CardWidgetProps {
onClick?: () => void | Promise<void>;
cardType: 'resource' | 'video' | 'article';
imageCover: string;
href?: string;
target?: string;
title: string | JSX.Element;
subContent?: string;
content: string;
styles?: {
container?: SerializedStyles;
title?: SerializedStyles;
imageCover?: SerializedStyles;
content?: SerializedStyles;
moreLink?: SerializedStyles;
};
disabled?: boolean;
forwardedRef?: (project: any) => void | Promise<void>;
openExternal?: boolean;
moreLinkText?: string;
ariaLabel: string;
}

export const CardWidget: React.FC<CardWidgetProps> = (props) => {
export const CardWidget: React.FC<CardWidgetProps> = ({
onClick = undefined,
href,
target = '_blank',
title,
content,
subContent,
disabled,
forwardedRef,
openExternal,
ariaLabel,
imageCover,
cardType,
moreLinkText,
...rest
}) => {
const defaultImageCover = cardType === 'video' ? defaultVideoCardCover : defaultArticleCardCover;
const [usedImageCover, setUsedImageCover] = useState(imageCover || defaultImageCover);
const [usedImageBackground, setUsedImageBackground] = useState(false);
const [usedImageFit, setUsedImageFit] = useState(ImageFit.centerContain);
Comment thread
zhixzhan marked this conversation as resolved.
Outdated
const styles =
props.cardType === 'resource' ? home.cardItem : props.imageCover ? home.mediaCardItem : home.meidiaCardNoCoverItem;
const imageCover = props.imageCover || (props.cardType === 'video' ? defaultVideoCardCover : defaultArticleCardCover);
return <ItemContainer {...props} imageCover={imageCover} styles={styles} />;
rest.styles || cardType === 'resource'
? home.cardItem
: imageCover
? home.mediaCardItem
: home.meidiaCardNoCoverItem;

const onImageLoading = (state: ImageLoadState) => {
if (state === ImageLoadState.error) {
setUsedImageCover(defaultImageCover);
}
};

// detect image cover dimention to decide apply blur background or not.
const onImgLoaded = (e) => {
Comment thread
zhixzhan marked this conversation as resolved.
Outdated
const rect = e.currentTarget.getBoundingClientRect();
const whRatio = rect.width / rect.height;
Comment thread
zhixzhan marked this conversation as resolved.
Outdated
if (whRatio < 1.5) {
Comment thread
zhixzhan marked this conversation as resolved.
Outdated
setUsedImageBackground(true);
} else {
setUsedImageFit(ImageFit.cover);
}
};

return (
<a
css={[itemContainerWrapper(disabled), styles.container]}
href={href}
target={target}
onClick={async (e) => {
if (onClick != null) {
e.preventDefault();
await onClick();
}
}}
{...rest}
>
<div ref={forwardedRef} aria-label={ariaLabel}>
<div css={styles.imageCover}>
{usedImageBackground && <div className={'image-cover-background'}></div>}
Comment thread
zhixzhan marked this conversation as resolved.
Outdated
<Image
alt={ariaLabel}
aria-label={ariaLabel}
Comment thread
zhixzhan marked this conversation as resolved.
Outdated
className={'image-cover-img'}
imageFit={usedImageFit}
src={usedImageCover}
onLoad={onImgLoaded}
onLoadingStateChange={onImageLoading}
/>
</div>
<div css={styles.title}>{title}</div>
<div css={styles.content}>{content}</div>
{moreLinkText && <Link css={styles.moreLink}> {moreLinkText} </Link>}
</div>
</a>
);
};
12 changes: 8 additions & 4 deletions Composer/packages/client/src/pages/home/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import formatMessage from 'format-message';
import { Link } from 'office-ui-fabric-react/lib/Link';
import { Image, ImageFit } from 'office-ui-fabric-react/lib/Image';
import { Pivot, PivotItem, PivotLinkSize } from 'office-ui-fabric-react/lib/Pivot';
import { Icon } from 'office-ui-fabric-react/lib/Icon';
import { RouteComponentProps } from '@reach/router';
import { navigate } from '@reach/router';
import { useRecoilValue } from 'recoil';
Expand Down Expand Up @@ -141,9 +142,9 @@ const Home: React.FC<RouteComponentProps> = () => {
];
return (
<div css={home.outline}>
<h1 css={home.title}>{formatMessage(`Bot Framework Composer`)}</h1>
<div css={home.page}>
<div css={home.leftPage} role="main">
<h1 css={home.title}>{formatMessage(`Bot Framework Composer`)}</h1>
Comment thread
zhixzhan marked this conversation as resolved.
Outdated
<div css={home.leftContainer}>
<h2 css={home.recentBotsTitle}>{formatMessage(`Recent Bots`)}</h2>
<Toolbar css={home.toolbar} toolbarItems={toolbarItems} />
Expand Down Expand Up @@ -192,7 +193,6 @@ const Home: React.FC<RouteComponentProps> = () => {
href={item.url}
imageCover={item.imageCover}
moreLinkText={item.moreText}
rel="noopener nofollow"
target="_blank"
title={item.title}
/>
Expand All @@ -204,7 +204,12 @@ const Home: React.FC<RouteComponentProps> = () => {
<Pivot aria-label="Videos and articles" linkSize={PivotLinkSize.large}>
{feed.tabs.map((tab, index) => (
<PivotItem key={index} headerText={tab.title}>
<div css={home.rowContainer}>
{tab.viewAllLinkText && (
<Link css={home.tabRowViewMore} href={tab.viewAllLinkUrl} target={'_blank'}>
{tab.viewAllLinkText} <Icon iconName={'OpenInNewWindow'}></Icon>{' '}
</Link>
)}
<div css={home.tabRowContainer}>
{tab.cards.map((card, index) => (
<CardWidget
key={index}
Expand All @@ -213,7 +218,6 @@ const Home: React.FC<RouteComponentProps> = () => {
content={card.description}
href={card.url}
imageCover={card.image}
rel="noopener nofollow"
target="_blank"
title={card.title}
/>
Expand Down
79 changes: 0 additions & 79 deletions Composer/packages/client/src/pages/home/ItemContainer.tsx

This file was deleted.

53 changes: 32 additions & 21 deletions Composer/packages/client/src/pages/home/RecentBotList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ import {
CheckboxVisibility,
} from 'office-ui-fabric-react/lib/DetailsList';
import formatMessage from 'format-message';
import { useMemo } from 'react';

import { calculateTimeDiff } from '../../utils/fileUtil';

import { detailListContainer, tableCell, content } from './styles';
import * as home from './styles';

interface RecentBotListProps {
onItemChosen: (file: IObjectWithKey) => void;
Expand All @@ -44,7 +45,7 @@ export function RecentBotList(props: RecentBotListProps): JSX.Element {
data: 'string',
onRender: (item) => {
return (
<div data-is-focusable css={tableCell}>
<div data-is-focusable css={home.tableCell}>
<Link
aria-label={formatMessage(`Bot name is {botName}`, { botName: item.name })}
onClick={() => onItemChosen(item)}
Expand All @@ -66,10 +67,10 @@ export function RecentBotList(props: RecentBotListProps): JSX.Element {
data: 'string',
onRender: (item) => {
return (
<div data-is-focusable css={tableCell}>
<div data-is-focusable css={home.tableCell}>
<div
aria-label={formatMessage(`location is {location}`, { location: item.path })}
css={content}
css={home.content}
tabIndex={-1}
>
{item.path}
Expand All @@ -89,10 +90,10 @@ export function RecentBotList(props: RecentBotListProps): JSX.Element {
data: 'number',
onRender: (item) => {
return (
<div data-is-focusable css={tableCell}>
<div data-is-focusable css={home.tableCell}>
<div
aria-label={formatMessage(`Last modified time is {time}`, { time: calculateTimeDiff(item.dateModified) })}
css={content}
css={home.content}
tabIndex={-1}
>
{calculateTimeDiff(item.dateModified)}
Expand All @@ -115,22 +116,32 @@ export function RecentBotList(props: RecentBotListProps): JSX.Element {
);
}

const botList = useMemo(() => {
return (
<DetailsList
isHeaderVisible
checkboxVisibility={CheckboxVisibility.hidden}
columns={tableColums}
compact={false}
getKey={(item) => `${item.path}/${item.name}`}
items={recentProjects}
layoutMode={DetailsListLayoutMode.justified}
selectionMode={SelectionMode.single}
onItemInvoked={onItemChosen}
onRenderDetailsHeader={onRenderDetailsHeader}
/>
);
}, []);

return (
<div css={detailListContainer} data-is-scrollable="true">
<ScrollablePane scrollbarVisibility={ScrollbarVisibility.auto}>
<DetailsList
isHeaderVisible
checkboxVisibility={CheckboxVisibility.hidden}
columns={tableColums}
compact={false}
getKey={(item) => `${item.path}/${item.name}`}
items={recentProjects}
layoutMode={DetailsListLayoutMode.justified}
selectionMode={SelectionMode.single}
onItemInvoked={onItemChosen}
onRenderDetailsHeader={onRenderDetailsHeader}
/>
</ScrollablePane>
<div css={home.detailListContainer} data-is-scrollable="true">
{recentProjects.length > 5 ? (
<div css={home.detailListScrollWrapper}>
<ScrollablePane scrollbarVisibility={ScrollbarVisibility.auto}>{botList}</ScrollablePane>{' '}
</div>
) : (
botList
)}
</div>
);
}
4 changes: 2 additions & 2 deletions Composer/packages/client/src/pages/home/WhatsNewsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ export function WhatsNewsList({ newsList }: WhatsNewsListProps): JSX.Element {
return (
<div aria-label={formatMessage("What's new list")} css={home.whatsNewsContainer} role="region">
<h3 css={home.subtitle}>{formatMessage("What's new")}</h3>
<div css={home.whatsNewsContainer}>
<div css={home.whatsNewsList}>
{newsList.map(({ title, description, url }, index) => {
return (
<Fragment key={index}>
<Link css={home.bluetitle} href={url}>
<Link css={home.bluetitle} href={url} target={'_blank'}>
{title}
</Link>
<p css={home.newsDescription}>{description}</p>
Expand Down
Loading