Skip to content

Commit

Permalink
use correct dot color for status
Browse files Browse the repository at this point in the history
  • Loading branch information
cdriesler committed Jul 29, 2023
1 parent 17e6f6e commit 35175ed
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public Response SolveGrasshopperDocument(NancyContext context)
// Collect document solution data
NodePenDocumentSolutionData documentSolutionData = new NodePenDocumentSolutionData(requestData.SolutionId);

documentSolutionData.DocumentRuntimeData.DurationMs = Math.Round(definition.SolutionSpan.TotalMilliseconds);
documentSolutionData.DocumentRuntimeData.DurationMs = Math.Ceiling(definition.SolutionSpan.TotalMilliseconds);

// Collect node solution data
foreach (IGH_DocumentObject documentObject in definition.Objects)
Expand Down
3 changes: 2 additions & 1 deletion packages/nodes/src/components/controls/ControlsContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ import { ActiveViewControl, PinnedPortsControl, TemplateLibraryControl } from '.

const ControlsContainer = (): React.ReactElement => {
const templates = useStore((state) => state.templates)
const activeViewKey = useStore((state) => state.layout.activeView)

return (
<ControlsContainerLayout>
<ActiveViewControl />
{/* <DocumentInfoControl /> */}
<PinnedPortsControl />
<TemplateLibraryControl templates={templates} />
{activeViewKey === 'document' ? <TemplateLibraryControl templates={templates} /> : null}
</ControlsContainerLayout>
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,16 @@ export const useModelProgress = (): ProgressStatus => {

const modelProgress = state.lifecycle.model.progress

return progress === 1 ? `Loaded model` : 'Downloading model...'
return modelProgress === 1 ? `Loaded model` : 'Downloading model...'
})

const statusLevel: ProgressStatus['statusLevel'] = progress === 1 ? 'pending' : 'normal'
const statusLevel: ProgressStatus['statusLevel'] = useStore((state) => {
if (state.lifecycle.solution !== 'ready') {
return 'pending'
}

return state.lifecycle.model.progress === 1 ? 'normal' : 'pending'
})

return { progress, statusMessage, statusLevel }
}
2 changes: 1 addition & 1 deletion packages/nodes/src/views/document-view/DocumentView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const DocumentView = ({ editable: _e }: DocumentViewProps): React.ReactElement |
<Layer id="np-selection-region-overlay-layer" position={viewPosition} z={95}>
<SelectionRegionOverlay />
</Layer>
<Layer id="np-transient-element-overlay-layer" position={viewPosition} z={90}>
<Layer id="np-transient-element-overlay-layer" position={viewPosition} z={90} fixed>
<TransientElementOverlay />
</Layer>
<Layer id="np-document-view-content-layer" position={viewPosition} z={70}>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useImperativeEvent } from '@/hooks'
import { useDispatch } from '@/store'
import { expireSolution } from '@/store/utils'
import { useCallback, useRef } from 'react'

export const useGlobalHotkeys = () => {
Expand All @@ -14,6 +15,8 @@ export const useGlobalHotkeys = () => {
for (const id of state.registry.selection.nodes) {
delete state.document.nodes[id]
}

expireSolution(state)
})
break
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,20 @@ type ProgressBarTooltipEntryProps = {
const ProgressBarTooltipEntry = ({ icon, statusLevel, statusMessage }: ProgressBarTooltipEntryProps) => {
const shadowTarget = usePseudoShadow()

const colors: Record<typeof statusLevel, string> = {
normal: COLORS.GREEN,
pending: COLORS.WARN,
error: COLORS.ERROR,
}

return (
<div className="np-w-48 np-mb-2 np-bg-light np-shadow-main np-rounded-md" ref={shadowTarget}>
<div className="np-w-full np-flex np-justify-start np-items-start">
<div className="np-w-8 np-h-8 np-flex np-justify-center np-items-center" style={{ minWidth: '2rem' }}>
{icon}
</div>
<div className="np-w-4 np-h-8 np-mr-1 np-flex np-justify-center np-items-center" style={{ minWidth: '1rem' }}>
<div className="np-w-3 np-h-3 np-rounded-full np-bg-green" />
<div className="np-w-3 np-h-3 np-rounded-full" style={{ backgroundColor: colors[statusLevel] }} />
</div>
<div className="np-pt-2 np-pb-2 np-pr-2 np-flex-grow np-flex np-flex-col np-justify-start">
<p className="np-font-sans np-font-medium np-text-dark np-text-xs -np-translate-y-px np-select-none">
Expand Down

0 comments on commit 35175ed

Please sign in to comment.