mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-03-29 13:09:07 +00:00
Changes to cards in notebook gallery (#422)
* added gallery changes * addressed PR comments
This commit is contained in:
parent
93cfd52e36
commit
1c0fed88c0
@ -38,7 +38,7 @@ export class GalleryCardComponent extends React.Component<GalleryCardComponentPr
|
|||||||
private static readonly cardImageHeight = 144;
|
private static readonly cardImageHeight = 144;
|
||||||
public static readonly cardHeightToWidthRatio =
|
public static readonly cardHeightToWidthRatio =
|
||||||
GalleryCardComponent.cardImageHeight / GalleryCardComponent.CARD_WIDTH;
|
GalleryCardComponent.cardImageHeight / GalleryCardComponent.CARD_WIDTH;
|
||||||
private static readonly cardDescriptionMaxChars = 88;
|
private static readonly cardDescriptionMaxChars = 80;
|
||||||
private static readonly cardItemGapBig = 10;
|
private static readonly cardItemGapBig = 10;
|
||||||
private static readonly cardItemGapSmall = 8;
|
private static readonly cardItemGapSmall = 8;
|
||||||
|
|
||||||
@ -105,13 +105,14 @@ export class GalleryCardComponent extends React.Component<GalleryCardComponentPr
|
|||||||
</Text>
|
</Text>
|
||||||
|
|
||||||
<Text variant="small" styles={{ root: { height: 36 } }}>
|
<Text variant="small" styles={{ root: { height: 36 } }}>
|
||||||
{this.props.data.description.substr(0, GalleryCardComponent.cardDescriptionMaxChars)}
|
{this.renderTruncatedDescription()}
|
||||||
</Text>
|
</Text>
|
||||||
|
|
||||||
<span>
|
<span>
|
||||||
{this.generateIconText("RedEye", this.props.data.views.toString())}
|
{this.props.data.views !== undefined && this.generateIconText("RedEye", this.props.data.views.toString())}
|
||||||
{this.generateIconText("Download", this.props.data.downloads.toString())}
|
{this.props.data.downloads !== undefined &&
|
||||||
{this.props.isFavorite !== undefined &&
|
this.generateIconText("Download", this.props.data.downloads.toString())}
|
||||||
|
{this.props.data.favorites !== undefined &&
|
||||||
this.generateIconText("Heart", this.props.data.favorites.toString())}
|
this.generateIconText("Heart", this.props.data.favorites.toString())}
|
||||||
</span>
|
</span>
|
||||||
</Card.Section>
|
</Card.Section>
|
||||||
@ -148,6 +149,14 @@ export class GalleryCardComponent extends React.Component<GalleryCardComponentPr
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private renderTruncatedDescription = (): string => {
|
||||||
|
let truncatedDescription = this.props.data.description.substr(0, GalleryCardComponent.cardDescriptionMaxChars);
|
||||||
|
if (this.props.data.description.length > GalleryCardComponent.cardDescriptionMaxChars) {
|
||||||
|
truncatedDescription = `${truncatedDescription} ...`;
|
||||||
|
}
|
||||||
|
return truncatedDescription;
|
||||||
|
};
|
||||||
|
|
||||||
private generateIconText = (iconName: string, text: string): JSX.Element => {
|
private generateIconText = (iconName: string, text: string): JSX.Element => {
|
||||||
return (
|
return (
|
||||||
<Text
|
<Text
|
||||||
|
@ -31,6 +31,26 @@ export interface NotebookMetadataComponentProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class NotebookMetadataComponent extends React.Component<NotebookMetadataComponentProps> {
|
export class NotebookMetadataComponent extends React.Component<NotebookMetadataComponentProps> {
|
||||||
|
private renderFavouriteButton = (): JSX.Element => {
|
||||||
|
return (
|
||||||
|
<Text>
|
||||||
|
{this.props.isFavorite !== undefined ? (
|
||||||
|
<>
|
||||||
|
<IconButton
|
||||||
|
iconProps={{ iconName: this.props.isFavorite ? "HeartFill" : "Heart" }}
|
||||||
|
onClick={this.props.isFavorite ? this.props.onUnfavoriteClick : this.props.onFavoriteClick}
|
||||||
|
/>
|
||||||
|
{this.props.data.favorites} likes
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<Icon iconName="Heart" /> {this.props.data.favorites} likes
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</Text>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
public render(): JSX.Element {
|
public render(): JSX.Element {
|
||||||
const options: Intl.DateTimeFormatOptions = {
|
const options: Intl.DateTimeFormatOptions = {
|
||||||
year: "numeric",
|
year: "numeric",
|
||||||
@ -49,19 +69,7 @@ export class NotebookMetadataComponent extends React.Component<NotebookMetadataC
|
|||||||
</Text>
|
</Text>
|
||||||
</Stack.Item>
|
</Stack.Item>
|
||||||
|
|
||||||
<Stack.Item>
|
<Stack.Item>{this.renderFavouriteButton()}</Stack.Item>
|
||||||
<Text>
|
|
||||||
{this.props.isFavorite !== undefined && (
|
|
||||||
<>
|
|
||||||
<IconButton
|
|
||||||
iconProps={{ iconName: this.props.isFavorite ? "HeartFill" : "Heart" }}
|
|
||||||
onClick={this.props.isFavorite ? this.props.onUnfavoriteClick : this.props.onFavoriteClick}
|
|
||||||
/>
|
|
||||||
{this.props.data.favorites} likes
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</Text>
|
|
||||||
</Stack.Item>
|
|
||||||
|
|
||||||
{this.props.downloadButtonText && (
|
{this.props.downloadButtonText && (
|
||||||
<Stack.Item>
|
<Stack.Item>
|
||||||
|
@ -301,9 +301,9 @@ export class PublishNotebookPaneComponent extends React.Component<PublishNoteboo
|
|||||||
thumbnailUrl: this.state.imageSrc,
|
thumbnailUrl: this.state.imageSrc,
|
||||||
created: this.props.notebookCreatedDate,
|
created: this.props.notebookCreatedDate,
|
||||||
isSample: false,
|
isSample: false,
|
||||||
downloads: 0,
|
downloads: undefined,
|
||||||
favorites: 0,
|
favorites: undefined,
|
||||||
views: 0,
|
views: undefined,
|
||||||
newCellId: undefined,
|
newCellId: undefined,
|
||||||
policyViolations: undefined,
|
policyViolations: undefined,
|
||||||
pendingScanJobIds: undefined,
|
pendingScanJobIds: undefined,
|
||||||
|
@ -89,8 +89,8 @@ exports[`PublishNotebookPaneComponent renders 1`] = `
|
|||||||
"author": "CosmosDB",
|
"author": "CosmosDB",
|
||||||
"created": "2020-07-17T00:00:00Z",
|
"created": "2020-07-17T00:00:00Z",
|
||||||
"description": "",
|
"description": "",
|
||||||
"downloads": 0,
|
"downloads": undefined,
|
||||||
"favorites": 0,
|
"favorites": undefined,
|
||||||
"gitSha": undefined,
|
"gitSha": undefined,
|
||||||
"id": undefined,
|
"id": undefined,
|
||||||
"isSample": false,
|
"isSample": false,
|
||||||
@ -102,7 +102,7 @@ exports[`PublishNotebookPaneComponent renders 1`] = `
|
|||||||
"",
|
"",
|
||||||
],
|
],
|
||||||
"thumbnailUrl": undefined,
|
"thumbnailUrl": undefined,
|
||||||
"views": 0,
|
"views": undefined,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
showDelete={false}
|
showDelete={false}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user