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

Customisable Navigation #6111

Merged
merged 32 commits into from Jul 26, 2021
Merged

Conversation

gwyneplaine
Copy link
Contributor

@gwyneplaine gwyneplaine commented Jul 15, 2021

This PR does the following:

  • Adds the Navigation component as a customisable property in the AdminConfig
  • Decomposes the Navigation component into smaller components to make providing custom Navigation easier.

We expose the following components now besides the core Navigation component:

  • NavItem - thin a11y and styling wrapper around the Link component from Next.js
  • ListNavItem - thin wrapper on top of NavItem, that takes a singe list item (of type ListMeta) and renders a NavItem. **
  • ListNavItems - this component takes an array of lists ListMeta[] and an optional include array. If an include array is specified only list items with keys that match the includes array are rendered as NavItems. Otherwise all lists are rendered as NavItems
  • NavContainer - Component encapsulates rendering logic for the AuthenticatedItem, as well as keystones a11y and styling decisions for the layout of the side nav.

** The impetus behind ListNavItem is to have a higher-level abstraction that can allow users to not have to care about the contents and structure of our lists. This is especially relevant for future feature additions to the nav. (i.e. if we add icon support, that would work out of the box from a dependency bump for users of ListNavItem, whereas you'd have to add that icon prop manually leveraging a lower level component.)

**The impetus behind ListNavItems is similar, but for rendering a list of NavItems. This is also a pre-emptive DX optimisation for creating custom navigation groups and subsections in the future.

Guide and example split into #6185 for expedited functional release.

Preview:
Screen Shot 2021-07-16 at 9 47 37 am

@vercel
Copy link

vercel bot commented Jul 15, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/keystonejs/keystone-next-docs/8rjRZZAAWhbWMZYAWDCk9Hh6hdUY
✅ Preview: https://keystone-next-docs-git-customisable-component-0bda32-keystonejs.vercel.app

@changeset-bot
Copy link

changeset-bot bot commented Jul 15, 2021

🦋 Changeset detected

Latest commit: 7be77b7

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 11 packages
Name Type
@keystone-next/keystone Minor
@keystone-next/types Minor
@keystone-next/auth Major
@keystone-next/example-auth Patch
@keystone-next/examples-app-basic Patch
@keystone-next/example-ecommerce Patch
keystone-next-app Patch
@keystone-next/example-roles Patch
@keystone-next/example-sandbox Patch
@keystone-next/example-testing Patch
@keystone-next/example-with-auth Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@gwyneplaine gwyneplaine marked this pull request as draft July 15, 2021 06:02
@codesandbox-ci
Copy link

codesandbox-ci bot commented Jul 15, 2021

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@vercel vercel bot temporarily deployed to Preview July 19, 2021 05:49 Inactive
@vercel vercel bot temporarily deployed to Preview July 19, 2021 06:27 Inactive
@vercel vercel bot temporarily deployed to Preview July 19, 2021 06:28 Inactive
@gwyneplaine gwyneplaine force-pushed the customisable-components/navigation branch from 20708d0 to 8795064 Compare July 20, 2021 00:26
@vercel vercel bot temporarily deployed to Preview July 20, 2021 00:26 Inactive
@vercel vercel bot temporarily deployed to Preview July 20, 2021 23:45 Inactive
@vercel vercel bot temporarily deployed to Preview July 20, 2021 23:55 Inactive
@vercel vercel bot temporarily deployed to Preview July 21, 2021 06:15 Inactive
@vercel vercel bot temporarily deployed to Preview July 22, 2021 04:10 Inactive
@vercel vercel bot temporarily deployed to Preview July 22, 2021 04:15 Inactive
@gwyneplaine gwyneplaine force-pushed the customisable-components/navigation branch from ccf4b33 to 374fb5a Compare July 22, 2021 04:17
@vercel vercel bot temporarily deployed to Preview July 22, 2021 04:27 Inactive
);
});
})()}
<nav role="navigation" aria-label="Side Navigation" css={{ marginTop: spacing.xlarge }}>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a11y fix:

  • adding a role and aria-label to the side nav for better screen reader support.
  • all nav items are now wrapped in an unordered list as per WCAG recommendation.

padding: `${spacing.small}px ${spacing.xlarge}px`,
position: 'relative',
textDecoration: 'none',
<li>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

related to fixes below:
NavItems are now wrapped in a list item for better SR readability and general semantics

@gwyneplaine gwyneplaine requested a review from a team July 26, 2021 06:36
@vercel vercel bot temporarily deployed to Preview July 26, 2021 06:37 Inactive
@gwyneplaine gwyneplaine marked this pull request as ready for review July 26, 2021 06:37
Co-authored-by: Tim Leslie <timl@thinkmill.com.au>
@vercel vercel bot temporarily deployed to Preview July 26, 2021 06:41 Inactive
Co-authored-by: Tim Leslie <timl@thinkmill.com.au>
Copy link
Contributor

@timleslie timleslie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yarn lock changes should be reverted

@vercel vercel bot temporarily deployed to Preview July 26, 2021 06:44 Inactive
@vercel vercel bot temporarily deployed to Preview July 26, 2021 06:47 Inactive
@vercel vercel bot temporarily deployed to Preview July 26, 2021 06:50 Inactive
Copy link
Contributor

@timleslie timleslie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm 👍 on this. I'll let @mitchellhamilton have a final review and give it the ✅

@timleslie timleslie dismissed their stale review July 26, 2021 06:55

Changes made.

export { Logo } from './Logo';
export { Navigation } from './Navigation';
export { Navigation, NavigationContainer, NavItem, ListNavItems, ListNavItem } from './Navigation';
Copy link
Member

@emmatown emmatown Jul 26, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When would someone want to use Navigation? Also, it is a different thing to the thing that accepts NavigationProps, right? (what i would probably expect Navigation to be is the default of adminConfig.components.Navigation)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct, the wrapping Navigation component would only be used for custom pages.
For example if someone were to not want to opt into the entire layout provided by PageContainer but did want to have a sidebar nav, they'd leverage that Navigation export

@vercel vercel bot temporarily deployed to Preview July 26, 2021 23:34 Inactive
@gwyneplaine gwyneplaine enabled auto-merge (squash) July 26, 2021 23:38
@gwyneplaine gwyneplaine merged commit 9e2deac into master Jul 26, 2021
@gwyneplaine gwyneplaine deleted the customisable-components/navigation branch July 26, 2021 23:41
Nikitoring pushed a commit to Nikitoring/keystone that referenced this pull request Sep 14, 2021
* add Navigation component to customisable components in adminConfig

* add composable navigation components and types to admin-ui/component exports

* update to Navigation component

* add types for Navigation component

* add example for custom-navigation-compoent

* add custom route

* add example

* add guide links

* wip nav guide

* add minor a11y fixes

* update docs and examples

* custom admin-ui docs

* update yarn.lock

* smoke tests for nav example

* update test and example

* dependency fixes

* fix smoke tests

* fix failing tests

* nope nevermind, not fixed

* nav architecture refactor

* docs wip

* remove d ocs to be added in subsequent PR

* type shuffling, so we do not have icky circular type references in @keystone-next/types

* changesets

* Update .changeset/fluffy-schools-allow.md

Co-authored-by: Tim Leslie <timl@thinkmill.com.au>

* Update .changeset/rare-carrots-deliver.md

Co-authored-by: Tim Leslie <timl@thinkmill.com.au>

* yarn.lock reversion

* remove unnecessary comments

Co-authored-by: Tim Leslie <timl@thinkmill.com.au>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants