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

Upgrade design system #9253

Draft
wants to merge 58 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
e8dc6ff
first pass
jossmac Aug 1, 2024
cc2d8f9
remove Card components
dcousens Aug 20, 2024
01d7c7e
tidy up and fix typescript errors
dcousens Aug 14, 2024
49e6898
remove itemQueryName, listQueryName from AdminMeta, add hideNavigation
dcousens Aug 20, 2024
3ed0edd
rebuild nexus-types
dcousens Aug 20, 2024
38288e1
create item: use form element
jossmac Aug 20, 2024
e55be17
fields util: refactor auto-focus logic
jossmac Aug 20, 2024
44e877a
relationship select: tweak layout + supporting props
jossmac Aug 20, 2024
0501f3a
relationship field: update contextual actions to keystar-ui
jossmac Aug 20, 2024
812dbc7
tidy up tsc errors
dcousens Aug 20, 2024
1368261
remove authenticatedItem from @keystone-6/core/admin-ui
dcousens Aug 20, 2024
37e6cdc
remove unused vars
jossmac Aug 20, 2024
043e04c
Merge branch 'introduce-keystar-ui' of https://github.com/keystonejs/…
jossmac Aug 20, 2024
f2a9985
fixes for 136826100, authenticatedItem usage in AdminUI
dcousens Aug 21, 2024
d79371d
update navigation components
jossmac Aug 21, 2024
1136162
navigation: fix temp naming issue
jossmac Aug 21, 2024
c81922d
tidy up
dcousens Aug 21, 2024
15e600e
type fixes and deduplication, fixes for 49e689881
dcousens Aug 21, 2024
8e5abf7
fix examples/custom-admin-ui-pages
dcousens Aug 21, 2024
a32f5cd
fix @keystone-6/example-custom-admin-ui-navigation
dcousens Aug 21, 2024
d5738b8
fix examples/extend-graphql-subscriptions
dcousens Aug 21, 2024
d098cdf
tidy up
dcousens Aug 21, 2024
2552031
type fixes and deduplication, fixes for 49e689881
dcousens Aug 21, 2024
d6b9846
move `ErrorDetailsDialog` to common components
jossmac Aug 21, 2024
c527910
type fixes and deduplication, fixes for 49e689881
dcousens Aug 21, 2024
2686d12
include error toast with useCreateItem
jossmac Aug 21, 2024
30d8b84
workaround for react-aria form submit focus issue
jossmac Aug 21, 2024
9bac0f7
Merge branch 'introduce-keystar-ui' of https://github.com/keystonejs/…
jossmac Aug 21, 2024
be6ca2b
fix for runtime errors
dcousens Aug 21, 2024
5a579e6
timestamp field: use keystar components
jossmac Aug 22, 2024
16961db
attempt timestamp filter
jossmac Sep 5, 2024
257f09f
Merge branch 'main' into introduce-keystar-ui
jossmac Sep 6, 2024
21201d1
fix old auth item ref
jossmac Sep 8, 2024
be6b0e8
attempt relationship field
jossmac Sep 9, 2024
c72ad1d
attempt integer field
jossmac Sep 9, 2024
031f905
select field: rm log
jossmac Sep 9, 2024
5131252
inject global font-family;
jossmac Sep 9, 2024
cf8318b
field group typography bandaid
jossmac Sep 9, 2024
e9e1be1
border expectations bandaid;
jossmac Sep 9, 2024
9ed2b95
calendarDay field (no filters)
jossmac Sep 9, 2024
7236496
calendarDay: fix date formatter
jossmac Sep 9, 2024
389adc0
convert password field to keystar;
jossmac Sep 9, 2024
66fe1f9
fix import order
jossmac Sep 9, 2024
989ded6
revert "touched" field changes;
jossmac Sep 9, 2024
113e70b
rm unnecessary style
jossmac Sep 9, 2024
bd199df
allow escape to cancel editing
jossmac Sep 9, 2024
c5f58c5
multiselect first pass
jossmac Sep 10, 2024
7eee9b7
multiselect field mostly working;
jossmac Sep 10, 2024
33c4dda
update field cell renderers
jossmac Sep 11, 2024
7b6c985
mobile combobox bug fix
jossmac Sep 11, 2024
c23e0e5
support `list.initialSort`
jossmac Sep 11, 2024
bc886b7
item id copy feedback—replace toast with tooltip
jossmac Sep 11, 2024
cad8592
fix some sticky behaviours
jossmac Sep 11, 2024
c820618
play with logo mark
jossmac Sep 11, 2024
9b31559
empty fields text
jossmac Sep 11, 2024
ca6b1a1
improve field access empty state
jossmac Sep 12, 2024
e1b2a91
no abbreviate int cell content
jossmac Sep 12, 2024
9f90228
render json cell content
jossmac Sep 12, 2024
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
5 changes: 5 additions & 0 deletions .changeset/admin-meta-rename.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@keystone-6/core": minor
---

Renames `isHidden` to `hideNavigation` on the AdminMeta list GraphQL type, `isHidden` is now deprecated and will be removed in a breaking change
5 changes: 5 additions & 0 deletions .changeset/admin-ui-navigation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@keystone-6/core": major
---

Removes `authenticatedItem` from `@keystone-6/core/admin-ui/components` exports
5 changes: 5 additions & 0 deletions .changeset/remove-end-session.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@keystone-6/core": major
---

Removes the `EndSession` GraphQL mutation addition when `context.session.end` is defined, extend this yourself if required
2 changes: 1 addition & 1 deletion design-system/packages/core/src/components/Core.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const BaseCSS = ({ includeNormalize, optimizeLegibility }: BaseCSSProps) => {
color: colors.foreground,
fontSize: '1rem',
fontWeight: typography.fontWeight.regular,
lineHeight: typography.leading.base,
// lineHeight: typography.leading.base,
fontFamily: typography.fontFamily.body,

// optimize legibility
Expand Down
8 changes: 4 additions & 4 deletions design-system/website/components/Navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { jsx, useTheme } from '@keystone-ui/core'
import Link from 'next/link'
import { useRouter } from 'next/router'

const Brand = () => {
function Brand () {
const { palette } = useTheme()
return (
<h2>
Expand All @@ -25,7 +25,7 @@ const Brand = () => {
}

type SectionProps = { label: string, children: ReactNode }
const Section = ({ label, children }: SectionProps) => {
function Section ({ label, children }: SectionProps) {
return (
<Fragment>
<h3>{label}</h3>
Expand All @@ -35,7 +35,7 @@ const Section = ({ label, children }: SectionProps) => {
}

type NavItemProps = { href: string, children: ReactNode }
const NavItem = ({ href, children }: NavItemProps) => {
function NavItem ({ href, children }: NavItemProps) {
const { palette, radii, spacing } = useTheme()
const router = useRouter()
const isSelected = router.pathname === href
Expand Down Expand Up @@ -68,7 +68,7 @@ const NavItem = ({ href, children }: NavItemProps) => {
)
}

export const Navigation = () => {
export function Navigation () {
return (
<Fragment>
<Brand />
Expand Down
1 change: 1 addition & 0 deletions docs/content/docs/config/auth.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ The following elements will be added to the GraphQL API.
```graphql
type Mutation {
authenticateUserWithPassword(email: String!, password: String!): UserAuthenticationWithPasswordResult!
endSession: Boolean!
}

type Query {
Expand Down
4 changes: 2 additions & 2 deletions docs/content/docs/config/lists.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ Options:
It is always possible to search by an id and `'id'` should not be specified in this option.
By default, the `labelField` is used if it has a string `contains` filter, otherwise none.
- `description` (default: `undefined`): Sets the list description displayed in the Admin UI.
- `isHidden` (default: `false`): Controls whether the list is visible in the navigation elements of the Admin UI.
- `hideNavigation` (default: `false`): Controls whether the list is visible in the navigation elements of the Admin UI.
Can be either a boolean value or an async function with an argument `{ session, context }` that returns a boolean value.
- `hideCreate` (default: `false`): Controls whether the `create` button is available in the Admin UI for this list.
Can be either a boolean value or an async function with an argument `{ session, context }` that returns a boolean value.
Expand Down Expand Up @@ -124,7 +124,7 @@ export default config({
labelField: 'name',
searchFields: ['name', 'alternativeName'],
description: '...',
isHidden: ({ session, context }) => false,
hideNavigation: ({ session, context }) => false,
hideCreate: ({ session, context }) => false,
hideDelete: ({ session, context }) => false,
createView: {
Expand Down
19 changes: 6 additions & 13 deletions docs/content/docs/fields/relationship.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,14 @@ Read our [relationships guide](../guides/relationships) for details on Keystone
- `map`: Changes the column name in the database
- `ui` (default: `{ hideCreate: false, displayMode: 'select' }`): Configures the display mode of the field in the Admin UI.
- `hideCreate` (default: `false`). If `true`, the "Create related item" button is not shown in the item view.
- `displayMode` (default: `'select'`): Controls the mode used to display the field in the item view. The mode `'select'` displays related items in a select component, while `'cards'` displays the related items in a card layout. Each display mode supports further configuration.
- `displayMode` (default: `'select'`): Controls the mode used to display the field in the item view. The mode `'select'` displays related items in a select component
- `ui.displayMode === 'select'` options:
- `labelField`: The field path from the related list to use for item labels in the select. Defaults to the `labelField` configured on the related list.
- `searchFields`: The fields used by the UI to search for this item, in context of this relationship field. Defaults to `searchFields` configured on the related list.
- `ui.displayMode === 'cards'` options:
- `cardFields`: A list of field paths from the related list to render in the card component. Defaults to `'id'` and the `labelField` configured on the related list.
- `linkToItem` (default `false`): If `true`, the default card component will render as a link to navigate to the related item.
- `removeMode` (default: `'disconnect'`): Controls whether the `Remove` button is present in the card. If `'disconnect'`, the button will be present. If `'none'`, the button will not be present.
- `inlineCreate` (default: `null`): If not `null`, an object of the form `{ fields: [...] }`, where `fields` is a list of field paths from the related list should be provided. An inline `Create` button will be included in the cards allowing a new related item to be created based on the configured field paths.
- `inlineEdit` (default: `null`): If not `null`, an object of the form `{ fields: [...] }`, where `fields` is a list of field paths from the related list should be provided. An `Edit` button will be included in each card, allowing the configured fields to be edited for each related item.
- `inlineConnect` (default: `false`): If `true`, an inline `Link existing item` button will be present, allowing existing items of the related list to be connected in this field.
Alternatively this can be an object with the properties:
- `labelField`: The field path from the related list to use for item labels in select. Defaults to the `labelField` configured on the related list.
- `searchFields`: The fields used by the UI to search for this item, in context of this relationship field. Defaults to `searchFields` configured on the related list.
- `ui.displayMode === 'count'` only supports `many` relationships
- `searchFields`: The fields used by the UI to search for this item, in context of this relationship field. Defaults to `searchFields` configured on the related list.

- `ui.displayMode === 'count'` options, which only support `many` relationships:
- `labelField`: The field path from the related list to use for item labels in select. Defaults to the `labelField` configured on the related list.
- `searchFields`: The fields used by the UI to search for this item, in context of this relationship field. Defaults to `searchFields` configured on the related list.

```typescript
import { config, list } from '@keystone-6/core';
Expand Down
101 changes: 36 additions & 65 deletions docs/content/docs/guides/custom-admin-ui-navigation.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ Reference your custom Navigation component in the export as so.

```ts
// /admin/config.ts
import type { AdminConfig } from '@keystone-6/core/types';
import { CustomNavigation } from './components/CustomNavigation';
import type { AdminConfig } from '@keystone-6/core/types'
import { CustomNavigation } from './components/CustomNavigation'

export const components: AdminConfig['components'] = {
Navigation: CustomNavigation
Expand All @@ -36,8 +36,8 @@ Here we'll export our `CustomNavigation` component as a named export.
```tsx
// admin/components/CustomNavigation.tsx

import type { NavigationProps } from '@keystone-6/core/admin-ui/components';
export function CustomNavigation({ authenticatedItem, lists }: NavigationProps) {
import type { NavigationProps } from '@keystone-6/core/admin-ui/components'
export function CustomNavigation({ lists }: NavigationProps) {
return (
{/* ... */}
)
Expand All @@ -48,8 +48,7 @@ Keystone will pass the following props to this component.

```tsx
type NavigationProps = {
lists: ListMeta[];
authenticatedItem: AuthenticatedItem
lists: ListMeta[]
}
```

Expand All @@ -62,21 +61,20 @@ For more information on the props, please see the [Navigation Props](#navigation
Next we'll want to import some components that Keystone provides to help us build our custom Navigation.

```tsx
import { NavigationContainer, NavItem, ListNavItems } from '@keystone-6/core/admin-ui/components';
import { NavigationContainer, NavItem, ListNavItems } from '@keystone-6/core/admin-ui/components'
```

The `NavigationContainer` component provides a container around your navigation links, as well as the different states of the `authenticatedItem` prop. We'll need this to:
The `NavigationContainer` component provides a container around your navigation links.

- Make our `CustomNavigation` component look and feel like the default Admin UI Navigation component.
- Render out the hamburger menu with additional options should a user session be in progress via the `authenticatedItem` prop.

```tsx
import { NavigationContainer, NavItem, ListNavItems } from '@keystone-6/core/admin-ui/components';
import type { NavigationProps } from '@keystone-6/core/admin-ui/components';
import { NavigationContainer, NavItem, ListNavItems } from '@keystone-6/core/admin-ui/components'
import type { NavigationProps } from '@keystone-6/core/admin-ui/components'

export function CustomNavigation({ authenticatedItem, lists }: NavigationProps) {
export function CustomNavigation({ lists }: NavigationProps) {
return (
<NavigationContainer authenticatedItem={authenticatedItem}>
<NavigationContainer>
{/* ... */}
</NavigationContainer>
)
Expand All @@ -92,12 +90,12 @@ For more information on the `NavigationContainer` see the [NavigationContainer](
The `ListNavItems` component takes the provided Array of `lists` and renders a list of NavItems. We'll use this component to help us easily create NavItems from Keystone lists.

```tsx
import { NavigationContainer, NavItem, ListNavItems } from '@keystone-6/core/admin-ui/components';
import type { NavigationProps } from '@keystone-6/core/admin-ui/components';
import { NavigationContainer, NavItem, ListNavItems } from '@keystone-6/core/admin-ui/components'
import type { NavigationProps } from '@keystone-6/core/admin-ui/components'

export function CustomNavigation({ authenticatedItem, lists }: NavigationProps) {
export function CustomNavigation({ lists }: NavigationProps) {
return (
<NavigationContainer authenticatedItem={authenticatedItem}>
<NavigationContainer>
<ListNavItems lists={lists}/>
{/* ... */}
</NavigationContainer>
Expand All @@ -114,12 +112,12 @@ For more information on the `ListNavItems` component, see the [ListNavItems](#li
The `NavItem` component is a thin styling and accessibility wrapper around the `Link` component from Next.js. We'll use this component to render our custom route as well as the `Dashboard` route.

```tsx
import { NavigationContainer, NavItem, ListNavItems } from '@keystone-6/core/admin-ui/components';
import type { NavigationProps } from '@keystone-6/core/admin-ui/components';
import { NavigationContainer, NavItem, ListNavItems } from '@keystone-6/core/admin-ui/components'
import type { NavigationProps } from '@keystone-6/core/admin-ui/components'

export function CustomNavigation({ authenticatedItem, lists }: NavigationProps) {
export function CustomNavigation({ lists }: NavigationProps) {
return (
<NavigationContainer authenticatedItem={authenticatedItem}>
<NavigationContainer>
<NavItem href="/">Dashboard</NavItem>
<ListNavItems lists={lists}/>
<NavItem href="https://keystonejs.com/">
Expand All @@ -144,12 +142,12 @@ With all that done, your Custom Navigation component should be good to go, and y

```tsx
// admin/components/CustomNavigation.tsx
import { NavigationContainer, NavItem, ListNavItems } from '@keystone-6/core/admin-ui/components';
import type { NavigationProps } from '@keystone-6/core/admin-ui/components';
import { NavigationContainer, NavItem, ListNavItems } from '@keystone-6/core/admin-ui/components'
import type { NavigationProps } from '@keystone-6/core/admin-ui/components'

export function CustomNavigation({ authenticatedItem, lists }: NavigationProps) {
export function CustomNavigation({ lists }: NavigationProps) {
return (
<NavigationContainer authenticatedItem={authenticatedItem}>
<NavigationContainer>
<NavItem href="/">Dashboard</NavItem>
<ListNavItems lists={lists}/>
<NavItem href="https://keystonejs.com/">
Expand All @@ -161,11 +159,11 @@ export function CustomNavigation({ authenticatedItem, lists }: NavigationProps)


// admin/config.ts
import { AdminConfig } from '@keystone-6/core/types';
import { CustomNavigation } from './components/CustomNavigation';
import { AdminConfig } from '@keystone-6/core/types'
import { CustomNavigation } from './components/CustomNavigation'
export const components: AdminConfig['components'] = {
Navigation: CustomNavigation
};
}
```

Start up your Keystone project, and you should see Custom Navigation with a route to the KeystoneJS docs in the Admin UI.
Expand All @@ -180,15 +178,14 @@ The rest of this guide will elaborate on some of the details around the helper c
This section is to provide more granular information around the props that Keystone passes to your Custom Navigation component.

```tsx
export const CustomNavigation = ({ lists, authenticatedItem }) => {}
export const CustomNavigation = ({ lists }) => {}
```

Keystone passes the following props to your custom Navigation component:

```ts
type NavigationProps {
lists: ListMeta[];
authenticatedItem: AuthenticatedItem;
lists: ListMeta[]
}
```

Expand All @@ -197,33 +194,17 @@ type NavigationProps {
```typescript
type ListMeta = {
/** Used for optimising the generated list of NavItems in React */
key: string;
key: string
/** href to the list route in the Admin UI. */
path: string;
path: string
/** Used as the label for each list generated NavItem */
label: string;
label: string
/** Other properties exists, but these are the ones that are relevant to the Navigation implementation */
};

type Lists = ListMeta[];
```

`authenticatedItem` is a union of potential authentication states, expanded on below:
}

```ts
type AuthenticatedItem =
| { state: 'unauthenticated' }
| { state: 'authenticated'; label: string; id: string; listKey: string }
| { state: 'loading' }
| { state: 'error'; error: Error | readonly [GraphQLError, ...GraphQLError[]] };
type Lists = ListMeta[]
```

The `authenticatedItem` props is rendered automatically when you pass it into the `NavigationContainer` component.

{% hint kind="warn" %}
If you render the `authenticatedItem` yourself, make sure you handle all of the possible states.
{% /hint %}

## Components

Keystone exposes a variety of helper components to make building out your custom Admin UI Navigation component easier. These are:
Expand All @@ -234,24 +215,14 @@ Keystone exposes a variety of helper components to make building out your custom

### NavigationContainer

This component renders containing markup around your navigation links, as well as as the different states of the `authenticatedItem` prop.

```typescript
type NavigationContainerProps = {
authenticatedItem?: AuthenticatedItem;
}
```

{% hint kind="tip" %}
For the shape of the `authenticatedItem` prop, please see the [Navigation Props](#navigation-props) section above.
{% /hint %}
This component renders containing markup around your navigation links.

```tsx
import { NavigationContainer} from '@keystone-6/core/admin-ui/components'

export const CustomNavigation = ({ lists, authenticatedItem }) => {
export function CustomNavigation ({ lists }) {
return (
<NavigationContainer authenticatedItem={authenticatedItem}>
<NavigationContainer>
{/* ... */}
</NavigationContainer>
)
Expand Down
Loading