import React, {ComponentType, CSSProperties} from 'react'
import {Dashboard} from './containers/Dashboard'
import {definePlugin} from 'sanity'
import {DashboardConfig, DashboardWidget, LayoutConfig} from './types'
const strokeStyle: CSSProperties = {
stroke: 'currentColor',
strokeWidth: 1.2,
}
const DashboardIcon = () => (
)
export interface DashboardPluginConfig {
/**
* Dashboard tool title
*/
title?: string
/**
* Dashboard tool name (used in url path)
*/
name?: string
/**
* Dashboard tool icon
*/
icon?: ComponentType
widgets?: DashboardWidget[]
/**
* Will be used for widgets that do not define a layout directly.
*/
defaultLayout?: LayoutConfig
}
export const dashboardTool = definePlugin((config = {}) => {
const pluginConfig: DashboardConfig = {
layout: config.defaultLayout ?? {},
widgets: config.widgets ?? [],
}
const title = config.title ?? 'Dashboard'
const name = config.name ?? 'dashboard'
const icon = config.icon ?? DashboardIcon
return {
name: 'dashboard',
tools: (prev, context) => {
return [
...prev,
{
title,
name,
icon,
component: () => ,
},
]
},
}
})