Skip to content

Commit

Permalink
Add placeholder icon
Browse files Browse the repository at this point in the history
  • Loading branch information
krassowski committed Jul 1, 2024
1 parent 7609220 commit 63411b0
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/gallery.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { TranslationBundle } from '@jupyterlab/translation';
import { IExhibit } from './types';
import { IExhibitReply } from './types';
import { requestAPI, eventStream, IStreamMessage, IProgress } from './handler';
import { repositoryIcon } from './icons';

interface IActions {
download(exhibit: IExhibit): Promise<void>;
Expand Down Expand Up @@ -233,7 +234,12 @@ function Exhibit(props: {
<h4 className="jp-Exhibit-title">{exhibit.title}</h4>
<div className="jp-Exhibit-middle">
<div className="jp-Exhibit-icon">
<img src={exhibit.icon} alt={exhibit.title} />
{
exhibit.icon ?
<img src={exhibit.icon} alt={exhibit.title} />
:
<repositoryIcon.react className="jp-exhibitPlaceholder" />
}
</div>
<div className="jp-Exhibit-buttons">
{!exhibit.isCloned ? (
Expand Down
6 changes: 6 additions & 0 deletions src/icons.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import { LabIcon } from '@jupyterlab/ui-components';
import gallerySvgstr from '../style/icons/md/gallery.svg';
import repositorySvgstr from '../style/icons/md/repository.svg';

export const galleryIcon = new LabIcon({
name: 'jupyterlab-gallery:gallery',
svgstr: gallerySvgstr
});

export const repositoryIcon = new LabIcon({
name: 'jupyterlab-gallery:repository',
svgstr: repositorySvgstr
});
11 changes: 10 additions & 1 deletion style/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,19 @@
cursor: default;
}

.jp-Exhibit-icon > img {
.jp-Exhibit-icon > img, .jp-Exhibit-icon > .jp-exhibitPlaceholder > svg {
max-width: 100%;
}

.jp-Exhibit-icon > .jp-exhibitPlaceholder > svg {
max-width: 100%;
block-size: 100%;
}

.jp-exhibitPlaceholder {
height: 100%;
}

.jp-Exhibit-icon {
display: flex;
justify-content: center;
Expand Down
1 change: 1 addition & 0 deletions style/icons/md/repository.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 63411b0

Please sign in to comment.