Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add placeholder exhibit icon #31

Merged
merged 3 commits into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
9 changes: 9 additions & 0 deletions binder/jupyter_gallery_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@
"homepage": "https://github.com/amueller/scipy-2018-sklearn",
"title": "Scikit-learn Tutorial 2018",
"description": "SciPy 2018 Scikit-learn Tutorial"
},
{
"git": "https://github.com/jupyter-widgets/tutorial.git",
"title": "Example without description"
},
{
"git": "https://gitlab.gnome.org/GNOME/atomix.git",
"title": "GNOME atomix",
"description": "Example without icon"
}
]
}
Expand Down
7 changes: 6 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,11 @@ 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
});
12 changes: 11 additions & 1 deletion style/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,20 @@
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.
Loading