sanity-plugin-workspace-home 1.0.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
- import {Button, Hotkeys, Stack, Box, Flex, Heading, Card, Text} from '@sanity/ui'
2
- // import {StarIcon} from '@sanity/icons'
1
+ import {DatabaseIcon} from '@sanity/icons'
2
+ import {Box, Button, Card, Flex, Grid, Hotkeys, Stack, Text} from '@sanity/ui'
3
3
  import React, {createElement, isValidElement, useMemo} from 'react'
4
4
  import {isValidElementType} from 'react-is'
5
5
  import {useActiveWorkspace, WorkspaceSummary} from 'sanity'
@@ -24,10 +24,13 @@ export const MediaCard = styled(Card)`
24
24
  export type WorkspacePreviewProps = {
25
25
  workspace: WorkspaceSummary
26
26
  index: number
27
+ query: string
27
28
  }
28
29
 
29
30
  export default function WorkspacePreview(props: WorkspacePreviewProps) {
30
- const {icon, title, name, subtitle} = props.workspace
31
+ const {workspace, index, query} = props
32
+ const {icon, title, name, subtitle, dataset} = workspace
33
+
31
34
  const {setActiveWorkspace} = useActiveWorkspace()
32
35
  const iconComponent = useMemo(() => createIcon(icon), [icon])
33
36
 
@@ -42,25 +45,51 @@ export default function WorkspacePreview(props: WorkspacePreviewProps) {
42
45
  // localStorage.setItem('favoriteWorkspace', name)
43
46
  // }, [name])
44
47
 
48
+ const hotKeyIndex = index + 1 === 10 ? 0 : index + 1
49
+
45
50
  return (
46
- <Card shadow={1} radius={2}>
47
- <Flex align="center" gap={[2, 3, 4, 4]} paddingX={[2, 3, 4, 4]}>
48
- <Hotkeys keys={[String(props.index + 1)]} padding={2} />
49
- <Box flex={1}>
51
+ <Card borderTop={Boolean(index)} tone="default">
52
+ <Grid columns={5} gap={[2, 3, 4, 4]} paddingY={1}>
53
+ <Card columnStart={1} columnEnd={4}>
50
54
  <Stack>
51
- <Button mode="bleed" tone="default" onClick={() => setActiveWorkspace(name)}>
55
+ <Button
56
+ mode="bleed"
57
+ tone="default"
58
+ onClick={() => setActiveWorkspace(name)}
59
+ >
52
60
  <Flex align="center" gap={[2, 3, 4, 4]}>
53
- {iconComponent ? <MediaCard>{createIcon(iconComponent)}</MediaCard> : null}
61
+ {iconComponent ? (
62
+ <MediaCard>{createIcon(iconComponent)}</MediaCard>
63
+ ) : null}
54
64
  <Box flex={1}>
55
65
  <Stack space={[1, 2, 3, 3]}>
56
- <Heading>{title || name}</Heading>
66
+ <Text size={3} weight="semibold" textOverflow="ellipsis">
67
+ {title || name}
68
+ </Text>
57
69
  {subtitle ? <Text muted>{subtitle}</Text> : null}
58
70
  </Stack>
59
71
  </Box>
60
72
  </Flex>
61
73
  </Button>
62
74
  </Stack>
63
- </Box>
75
+ </Card>
76
+ <Card columnStart={4} columnEnd={5}>
77
+ <Flex height="fill" align="center" gap={2}>
78
+ <Text size={1} weight="semibold">
79
+ <DatabaseIcon />
80
+ </Text>
81
+ <Text size={1} weight="semibold" textOverflow="ellipsis">
82
+ {dataset}
83
+ </Text>
84
+ </Flex>
85
+ </Card>
86
+ <Card paddingRight={[2, 3, 3, 3]}>
87
+ <Flex height="fill" align="center" justify="flex-end">
88
+ {!query && hotKeyIndex < 10 ? (
89
+ <Hotkeys keys={[String(hotKeyIndex)]} padding={2} />
90
+ ) : null}
91
+ </Flex>
92
+ </Card>
64
93
  {/* <Button
65
94
  mode={isFavourite ? 'default' : 'bleed'}
66
95
  tone={isFavourite ? 'primary' : 'default'}
@@ -71,7 +100,7 @@ export default function WorkspacePreview(props: WorkspacePreviewProps) {
71
100
  setFavoriteWorkspace()
72
101
  }}
73
102
  /> */}
74
- </Flex>
103
+ </Grid>
75
104
  </Card>
76
105
  )
77
106
  }
package/src/index.ts CHANGED
@@ -1,5 +1,5 @@
1
- import {Config, definePlugin} from 'sanity'
2
1
  import {HomeIcon} from '@sanity/icons'
2
+ import {definePlugin, WorkspaceOptions} from 'sanity'
3
3
 
4
4
  import {workspaceHomeTool} from './tool'
5
5
 
@@ -18,7 +18,7 @@ type WorkspaceHomeConfigProps = {
18
18
  export const workspaceHomeConfig = ({
19
19
  projectId = ``,
20
20
  dataset = ``,
21
- }: WorkspaceHomeConfigProps): Config => ({
21
+ }: WorkspaceHomeConfigProps): WorkspaceOptions => ({
22
22
  name: 'home',
23
23
  title: 'Home',
24
24
  basePath: '/home',