aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/newlightbox/components/Recommendation
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/views/newlightbox/components/Recommendation')
-rw-r--r--src/client/views/newlightbox/components/Recommendation/Recommendation.scss176
-rw-r--r--src/client/views/newlightbox/components/Recommendation/Recommendation.tsx90
-rw-r--r--src/client/views/newlightbox/components/Recommendation/index.ts2
-rw-r--r--src/client/views/newlightbox/components/Recommendation/utils.ts23
4 files changed, 291 insertions, 0 deletions
diff --git a/src/client/views/newlightbox/components/Recommendation/Recommendation.scss b/src/client/views/newlightbox/components/Recommendation/Recommendation.scss
new file mode 100644
index 000000000..c86c63ba0
--- /dev/null
+++ b/src/client/views/newlightbox/components/Recommendation/Recommendation.scss
@@ -0,0 +1,176 @@
+@import '../../NewLightboxStyles.scss';
+
+.recommendation-container {
+ width: 100%;
+ height: fit-content;
+ min-height: 180px;
+ border-radius: 20px;
+ display: grid;
+ grid-template-columns: 0% 100%;
+ grid-template-rows: auto auto auto auto auto;
+ gap: 5px 0px;
+ padding: 10px;
+ cursor: pointer;
+ transition: 0.2s ease;
+ border: $standard-border;
+ border-color: $gray-l2;
+ background: white;
+
+ &:hover {
+ // background: white !important;
+ transform: scale(1.02);
+ z-index: 0;
+
+ .title {
+ text-decoration: underline;
+ }
+ }
+
+ &.previewUrl {
+ grid-template-columns: calc(30% - 10px) 70%;
+ grid-template-rows: auto auto auto auto auto;
+ gap: 5px 10px;
+ }
+
+ &.loading {
+ animation: skeleton-loading-l2 1s linear infinite alternate;
+ border: none;
+ grid-template-columns: calc(30% - 10px) 70%;
+ grid-template-rows: auto auto auto auto auto;
+ gap: 5px 10px;
+
+ .image-container,
+ .title,
+ .info,
+ .source,
+ .explainer,
+ .hide-rec {
+ animation: skeleton-loading-l3 1s linear infinite alternate;
+ }
+
+ .title {
+ border-radius: 20px;
+ }
+ }
+
+ .distance-container,
+ .type-container,
+ .source-container {
+ display: flex;
+ flex-direction: row;
+ justify-content: flex-start;
+ align-items: center;
+ gap: 5px;
+ }
+
+ .image-container {
+ grid-row: 2/5;
+ grid-column: 1;
+ border-radius: 20px;
+ overflow: hidden;
+
+ .image {
+ width: 100%;
+ height: 100%;
+ object-fit: cover;
+ }
+ }
+
+ .title {
+ grid-row: 1;
+ grid-column: 1/3;
+ border-radius: 20px;
+ font-size: $h2-size;
+ font-weight: $h2-weight;
+ overflow: hidden;
+ border-radius: 0px;
+ min-height: 30px;
+ }
+
+ .info {
+ grid-row: 2;
+ grid-column: 2;
+ border-radius: 20px;
+ display: flex;
+ flex-direction: row;
+ gap: 5px;
+ font-size: $body-size;
+
+ .lb-type {
+ padding: 2px 7px !important;
+ background: $gray-l2;
+ }
+ }
+
+ .lb-label {
+ color: $gray-l3;
+ font-weight: $h1-weight;
+ font-size: $body-size;
+ }
+
+ .source {
+ grid-row: 3;
+ grid-column: 2;
+ border-radius: 20px;
+ font-size: $body-size;
+ display: flex;
+ justify-content: flex-start;
+ align-items: center;
+
+ .lb-source {
+ padding: 2px 7px !important;
+ background: $gray-l2;
+ border-radius: 10px;
+ white-space: nowrap;
+ max-width: 130px;
+ text-overflow: ellipsis;
+ overflow: hidden;
+ }
+ }
+
+ .explainer {
+ grid-row: 4;
+ grid-column: 2;
+ border-radius: 20px;
+ font-size: 10px;
+ width: 100%;
+ background: $blue-l1;
+ border-radius: 0;
+ padding: 10px;
+
+ .concepts-container {
+ display: flex;
+ flex-flow: row wrap;
+ margin-top: 3px;
+ gap: 3px;
+ .concept {
+ padding: 2px 7px !important;
+ background: $gray-l2;
+ }
+ }
+ }
+
+ .hide-rec {
+ grid-row: 5;
+ grid-column: 2;
+ border-radius: 20px;
+ font-size: $body-size;
+ display: flex;
+ align-items: center;
+ margin-top: 5px;
+ gap: 5px;
+ justify-content: flex-end;
+ text-transform: underline;
+ }
+
+ &.dark {
+ background: $black;
+ border-color: $white;
+ }
+
+ &.light,
+ &.default {
+ background: $white;
+ border-color: $white;
+ }
+} \ No newline at end of file
diff --git a/src/client/views/newlightbox/components/Recommendation/Recommendation.tsx b/src/client/views/newlightbox/components/Recommendation/Recommendation.tsx
new file mode 100644
index 000000000..c0d357ad5
--- /dev/null
+++ b/src/client/views/newlightbox/components/Recommendation/Recommendation.tsx
@@ -0,0 +1,90 @@
+import * as React from 'react';
+import { IRecommendation } from "./utils";
+import './Recommendation.scss';
+import { getType } from '../../utils';
+import { FaEyeSlash } from 'react-icons/fa';
+import { NewLightboxView } from '../../NewLightboxView';
+import { DocumentManager } from '../../../../util/DocumentManager';
+import { Doc } from '../../../../../fields/Doc';
+import { Docs } from '../../../../documents/Documents';
+
+export const Recommendation = (props: IRecommendation) => {
+ const {title, data, type, text, transcript, loading, source, previewUrl, related_concepts, distance, docId} = props
+
+ return <div className={`recommendation-container ${loading && 'loading'} ${previewUrl && 'previewUrl'}`} onClick={() => {
+ let doc: Doc | null = null;
+ if (source == "Dash" && docId) {
+ const docView = DocumentManager.Instance.getDocumentViewById(docId)
+ if (docView) {
+ doc = docView.rootDoc;
+ }
+ } else if (data) {
+ console.log(data, type)
+ switch(type) {
+ case "YouTube":
+ console.log('create ', type, 'document')
+ doc = Docs.Create.VideoDocument(data, { title: title, _width: 400, _height: 315, transcript: transcript })
+ break;
+ case "Video":
+ console.log('create ', type, 'document')
+ doc = Docs.Create.VideoDocument(data, { title: title, _width: 400, _height: 315, transcript: transcript })
+ break;
+ case "Webpage":
+ console.log('create ', type, 'document')
+ doc = Docs.Create.WebDocument(data, { title: title, text: text })
+ break;
+ case "HTML":
+ console.log('create ', type, 'document')
+ doc = Docs.Create.WebDocument(data, { title: title, text: text })
+ break;
+ case "Text":
+ console.log('create ', type, 'document')
+ doc = Docs.Create.TextDocument(data, { title: title, text: text })
+ break;
+ case "PDF":
+ console.log('create ', type, 'document')
+ doc = Docs.Create.PdfDocument(data, { title: title, text: text })
+ break;
+ }
+ }
+ if (doc !== null) NewLightboxView.SetNewLightboxDoc(doc)
+ }}>
+ {loading ?
+ <div className={`image-container`}>
+ </div>
+ :
+ previewUrl ? <div className={`image-container`}>
+ {<img className={`image`} src={previewUrl}></img>}
+ </div>
+ : null
+ }
+ <div className={`title`}>{title}</div>
+ <div className={`info`}>
+ {!loading && <div className={`type-container`}>
+ <div className={`lb-label`}>Type</div><div className={`lb-type`}>{getType(type!)}</div>
+ </div>}
+ {!loading && <div className={`distance-container`}>
+ <div className={`lb-label`}>Distance</div><div className={`lb-distance`}>{distance}</div>
+ </div>}
+ </div>
+ <div className={`source`}>
+ {!loading && <div className={`source-container`}>
+ <div className={`lb-label`}>Source</div><div className={`lb-source`}>{source}</div>
+ </div>}
+ </div>
+ <div className={`explainer`}>
+ {!loading &&
+ <div>
+ You are seeing this recommendation because this document also explores
+ <div className={`concepts-container`}>
+ {related_concepts?.map((val) => {
+ return <div className={'concept'}>{val}</div>
+ })}
+ </div>
+ </div>}
+ </div>
+ <div className={`hide-rec`}>
+ {!loading && <><div>Hide Recommendation</div><div style={{fontSize: 15, paddingRight: 5}}><FaEyeSlash/></div></>}
+ </div>
+ </div>
+} \ No newline at end of file
diff --git a/src/client/views/newlightbox/components/Recommendation/index.ts b/src/client/views/newlightbox/components/Recommendation/index.ts
new file mode 100644
index 000000000..12ebf9d6e
--- /dev/null
+++ b/src/client/views/newlightbox/components/Recommendation/index.ts
@@ -0,0 +1,2 @@
+export * from './utils'
+export * from './Recommendation' \ No newline at end of file
diff --git a/src/client/views/newlightbox/components/Recommendation/utils.ts b/src/client/views/newlightbox/components/Recommendation/utils.ts
new file mode 100644
index 000000000..796ce0eb0
--- /dev/null
+++ b/src/client/views/newlightbox/components/Recommendation/utils.ts
@@ -0,0 +1,23 @@
+import { DocumentType } from "../../../../documents/DocumentTypes"
+
+export interface IRecommendation {
+ loading?: boolean
+ type?: DocumentType | string,
+ data?: string,
+ title?: string,
+ text?: string,
+ source?: string,
+ previewUrl?: string,
+ transcript?: {
+ text: string,
+ start: number,
+ duration: number
+ }[],
+ embedding?: {
+ x: number,
+ y: number
+ },
+ distance?: number,
+ related_concepts?: string[],
+ docId?: string
+} \ No newline at end of file