Skip to content

Commit

Permalink
UI: refactor use widget wrapper (#1395)
Browse files Browse the repository at this point in the history
* UI: refactor use widget wrapper

* commit UI assets
  • Loading branch information
DimaAmega authored Dec 13, 2024
1 parent 27cd544 commit 1e692c8
Show file tree
Hide file tree
Showing 15 changed files with 145 additions and 145 deletions.
32 changes: 16 additions & 16 deletions src/evidently/nbextension/static/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/evidently/ui/assets/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
content="Evidently - ML Monitoring Demo. Hosted example to monitor the performance of a demand forecasting model on a toy dataset."
/>
<title>Evidently - ML Monitoring Demo</title>
<script type="module" crossorigin src="/static/js/index-D461mMJX.js"></script>
<script type="module" crossorigin src="/static/js/index-Bk_zDyHx.js"></script>
<link rel="modulepreload" crossorigin href="/static/js/vendor-C2GWNUp2.js">
<link rel="stylesheet" crossorigin href="/static/css/index-CJbKDbyR.css">
</head>
Expand Down

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,13 @@ import { WidgetRenderer } from '~/widgets/WidgetRenderer'

export interface DashboardContentProps {
widgets: WidgetInfo[]
ItemWrapper?: ({ id, children }: { id: string; children: React.ReactNode }) => React.ReactNode
}

export const DashboardContentWidgets: FunctionComponent<DashboardContentProps> = ({
widgets,
ItemWrapper
}) => (
export const DashboardContentWidgets: FunctionComponent<DashboardContentProps> = ({ widgets }) => (
<>
{widgets.length > 0 &&
widgets.map((wi, idx) => (
<React.Fragment key={wi.id}>{WidgetRenderer(`wi_${idx}`, wi, ItemWrapper)}</React.Fragment>
<React.Fragment key={wi.id}>{WidgetRenderer(`wi_${idx}`, wi)}</React.Fragment>
))}
</>
)
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ import type { WidgetInfo } from '~/api'
import { DashboardContentWidgets } from '~/components/DashboardContent'

export const DashboardWidgets = ({
widgets,
ItemWrapper
widgets
}: {
widgets: WidgetInfo[]
ItemWrapper?: ({ id, children }: { id: string; children: React.ReactNode }) => React.ReactNode
}) => {
if (widgets.length === 0) {
return (
Expand All @@ -20,7 +18,7 @@ export const DashboardWidgets = ({
return (
<>
<Grid container spacing={3} direction='row' alignItems='stretch'>
<DashboardContentWidgets widgets={widgets} ItemWrapper={ItemWrapper} />
<DashboardContentWidgets widgets={widgets} />
</Grid>
</>
)
Expand Down
13 changes: 13 additions & 0 deletions ui/packages/evidently-ui-lib/src/contexts/WidgetWrapper.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React, { useContext } from 'react'

export type WidgetWrapper = {
WidgetWrapper: ({ id, children }: { id: string; children: React.ReactNode }) => JSX.Element
}

const EmptyWidgetWrapper: WidgetWrapper['WidgetWrapper'] = ({ children }) => <>{children}</>

export const widgetWrapperContext = React.createContext<WidgetWrapper>({
WidgetWrapper: EmptyWidgetWrapper
})

export const useWidgetWrapper = () => useContext(widgetWrapperContext)
Loading

0 comments on commit 1e692c8

Please sign in to comment.