From 63411b0496772788c87d155c9f55f73f99d84848 Mon Sep 17 00:00:00 2001 From: krassowski <5832902+krassowski@users.noreply.github.com> Date: Mon, 1 Jul 2024 09:40:36 +0100 Subject: [PATCH] Add placeholder icon --- src/gallery.tsx | 8 +++++++- src/icons.ts | 6 ++++++ style/base.css | 11 ++++++++++- style/icons/md/repository.svg | 1 + 4 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 style/icons/md/repository.svg diff --git a/src/gallery.tsx b/src/gallery.tsx index 5848664..e9f1170 100644 --- a/src/gallery.tsx +++ b/src/gallery.tsx @@ -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; @@ -233,7 +234,12 @@ function Exhibit(props: {

{exhibit.title}

- {exhibit.title} + { + exhibit.icon ? + {exhibit.title} + : + + }
{!exhibit.isCloned ? ( diff --git a/src/icons.ts b/src/icons.ts index d884ac1..169b8b8 100644 --- a/src/icons.ts +++ b/src/icons.ts @@ -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 +}); diff --git a/style/base.css b/style/base.css index c1899bf..258eeae 100644 --- a/style/base.css +++ b/style/base.css @@ -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; diff --git a/style/icons/md/repository.svg b/style/icons/md/repository.svg new file mode 100644 index 0000000..5250b24 --- /dev/null +++ b/style/icons/md/repository.svg @@ -0,0 +1 @@ + \ No newline at end of file