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

Created a speech bubble loading icon for Conversation task #39

Merged
merged 2 commits into from
Aug 7, 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
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import './PendingOutput.scss';
import useBEMNaming from "../../../../../common/useBEMNaming";
import { textConversation } from '../../../../../helpers/TaskIDs';

const defaultProps = {
className: 'pending-output'
Expand All @@ -17,10 +18,25 @@ export default function PendingOutput(givenProps) {
{props.unsupportedModel &&
<div className={getElement('subtitle')}>Warning: unsupported model</div>
}
<div className={getElement('spinner-container')}>
<div className={getElement('spinner')}></div>
<p className={getElement("spinner-text")}>This could take a few minutes...</p>
</div>
{ props.outputType !== textConversation ?
(
<div className={getElement('spinner-container')}>
<div className={getElement('spinner')} />
<p className={getElement("spinner-text")}>
This could take a few minutes...
</p>
</div>
) : (
<div className={getElement('ellipsis-container')}>
<div className={getElement('ellipsis-speech-bubble')} >
<div className={getElement('ellipsis')} />
</div>
<p className={getElement("ellipsis-text")}>
This could take a few minutes...
</p>
</div>
)
}
</div>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,74 @@
margin-bottom: 16px;
}

&__spinner-text {
&__spinner-text, &__ellipsis-text {
@include headline3;
color: $charcoalLightest;
text-align: center;
}

&__ellipsis-container {
align-items: center;
display: flex;
flex-grow: 1;
justify-content: center;
position: relative;
flex-direction: column;
}

&__ellipsis-speech-bubble {
height: 65px;
width: 100px;
position: relative;
background: $smokeDarker;
border-radius: .4em;
}

&__ellipsis-speech-bubble:after {
content: '';
position: absolute;
bottom: 0;
left: 50%;
width: 0;
height: 0;
border: 20px solid transparent;
border-top-color: $smokeDarker;
border-bottom: 0;
border-left: 0;
margin-left: -10px;
margin-bottom: -20px;
}

&__ellipsis {
height: 65px;
color: $grayDarkest;
margin-top: -30px;
margin-left: 25px;
font-size: 70px;
}

&__ellipsis:after {
overflow: hidden;
display: inline-block;
-webkit-animation: ellipsis steps(4,end) 1900ms infinite;
animation: ellipsis steps(4,end) 1900ms infinite;
content: "\2026"; /* ascii code for the ellipsis character */
width: 0px;
}

@keyframes ellipsis {
to {
width: 1em;
}
}

@-webkit-keyframes ellipsis {
to {
width: 1em;
}
}

&__ellipsis-text {
margin-top: 20px;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ export default function TextConversationOutput(props) {
props.trial
);

console.log('TextConversationOutput props', props);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leaving these in for now to do a bit of debugging for Conversations on Staging, but will remove them shortly


const task = Task.getStaticTask(textConversation);

const [conversation, setConversation] = useState([
Expand Down
4 changes: 3 additions & 1 deletion src/components/Experiment/QuickOutput/QuickOutput.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ export default function QuickOutput(givenProps) {
const props = { ...defaultProps, ...givenProps };
const { getElement, getBlock } = useBEMNaming(props.className);

console.log('QuickOutput props', props);

const preview = props?.trialOutput?.inputs.length > 1 ? <MultiInputPreview inputs={props.trialOutput.inputs} onBackClicked={props.onBackClicked} /> : (
<InputPreview
input={props.input}
Expand Down Expand Up @@ -266,7 +268,7 @@ export default function QuickOutput(givenProps) {
return (
<>
{preview}
<PendingOutput />
<PendingOutput outputType={props.outputType} />
</>
);
}
Expand Down
4 changes: 4 additions & 0 deletions src/components/ModelDetailPage/ModelDetailPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ import {
const ModelDetailPage = (props) => {
const jumpRef = useRef();

console.log('ModelDetailPage props', props);

const outputType = props.model?.output?.type || "";

const getSampleInputs = () => {
Expand Down Expand Up @@ -159,6 +161,8 @@ const ModelDetailPage = (props) => {
compare={props.compare}
trialOutput={props.trialOutput}
inputType={getInputType()}
outputType={outputType}
runTrial={props.onRunModelClicked}
/>
);
}
Expand Down
11 changes: 9 additions & 2 deletions src/components/ModelDetailPage/ModelDetailPage.stories.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
semantic_segmentation,
textToText,
textToCode,
textConversation,
} from "../../helpers/TaskIDs";
import { TestObjectDetectionResult } from "../Experiment/QuickOutput/Outputs/ObjectDetection/testData/TestFeatures";
import { TestImageSegmentationResult } from "../Experiment/QuickOutput/Outputs/SemanticSegmentation/testData/TestFeatures";
Expand All @@ -21,16 +22,16 @@ import { TestImageClassificationResult } from "../Experiment/QuickOutput/Outputs
import { TestInstanceSegmentationOutput } from "../Experiment/QuickOutput/Outputs/InstanceSegmentation/testData/TestFeatures";
import { TestTextOutput } from "../Experiment/QuickOutput/Outputs/Text/testData/testTextOutput";
import { TestTextToCodeOutput } from "../Experiment/QuickOutput/Outputs/TextToCode/testData/testTextToCodeOutput";
import { TaskInputTypes } from "../../helpers/TaskInputTypes";

export default {
title: "Models/Model Detail Page",
component: ModelDetailPage,
};

const Template = (args) => <ModelDetailPage {...args} />;
const Template = (args) => <ModelDetailPage key="StandardModelDetailPage" {...args} />;

const makeArgs = (type, output = undefined) => ({
key: "StandardModelDetailPage",
trialOutput: output,
model: {
id: 13,
Expand Down Expand Up @@ -203,6 +204,12 @@ TextPendingOutput.args = makeArgs(textToText, {
inputs: ["Translate into Spanish: Hello, how are you?"],
});

export const TextConversationPendingOutput = Template.bind({});
TextConversationPendingOutput.args = makeArgs(textConversation, {
id: "7618d464-b5ed-432f-8f88-b33504c6bb0a",
inputs: [{src: "What is the meaning of life?", inputType: TaskInputTypes.Text}],
});

export const TextOutput = Template.bind({});
TextOutput.args = makeArgs(textToText, TestTextOutput);

Expand Down
10 changes: 7 additions & 3 deletions src/routes/ModelDetailContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,13 @@ export function ModelDetailContainer(props) {
}, []);

return (
<ModelDetailPage model={model} onBackToModelClicked={backToModel}
onRunModelClicked={runModel} trialOutput={trialOutput}
compare={compareModels}/>
<ModelDetailPage
model={model}
onBackToModelClicked={backToModel}
onRunModelClicked={runModel}
trialOutput={trialOutput}
compare={compareModels}
/>
)
}

Expand Down