-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Extract Page and NavigableRegion components to an admin-ui package #72106
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| <!-- Learn how to maintain this file at https://github.com/WordPress/gutenberg/tree/HEAD/packages#maintaining-changelogs. --> | ||
|
|
||
| ## Unreleased |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| # Admin UI | ||
|
|
||
| Generic components to be used to build the Admin UI. | ||
|
|
||
| ## Installation | ||
|
|
||
| Install the module | ||
|
|
||
| ```bash | ||
| npm install @wordpress/admin-ui --save | ||
| ``` | ||
|
|
||
| ## API | ||
|
|
||
| <!-- START TOKEN(Autogenerated API docs) --> | ||
|
|
||
| ### NavigableRegion | ||
|
|
||
| Undocumented declaration. | ||
|
|
||
| ### Page | ||
|
|
||
| Undocumented declaration. | ||
|
|
||
| <!-- END TOKEN(Autogenerated API docs) --> | ||
|
|
||
| ## Contributing to this package | ||
|
|
||
| This is an individual package that's part of the Gutenberg project. The project is organized as a monorepo. It's made up of multiple self-contained software packages, each with a specific purpose. The packages in this monorepo are published to [npm](https://www.npmjs.com/) and used by [WordPress](https://make.wordpress.org/core/) as well as other software projects. | ||
|
|
||
| To find out more about contributing to this package or Gutenberg as a whole, please read the project's main [contributor guide](https://github.com/WordPress/gutenberg/tree/HEAD/CONTRIBUTING.md). | ||
|
|
||
| <br /><br /><p align="center"><img src="https://s.w.org/style/images/codeispoetry.png?1" alt="Code is Poetry." /></p> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| { | ||
| "name": "@wordpress/admin-ui", | ||
| "version": "1.0.0", | ||
| "description": "Generic components to be used in the Admin UI.", | ||
| "author": "The WordPress Contributors", | ||
| "license": "GPL-2.0-or-later", | ||
| "keywords": [ | ||
| "wordpress", | ||
| "admin", | ||
| "ui" | ||
| ], | ||
| "homepage": "https://github.com/WordPress/gutenberg/tree/HEAD/packages/admin-ui/README.md", | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "https://github.com/WordPress/gutenberg.git", | ||
| "directory": "packages/admin-ui" | ||
| }, | ||
| "bugs": { | ||
| "url": "https://github.com/WordPress/gutenberg/issues" | ||
| }, | ||
| "engines": { | ||
| "node": ">=18.12.0", | ||
| "npm": ">=8.19.2" | ||
| }, | ||
| "main": "build/index.js", | ||
| "module": "build-module/index.js", | ||
| "react-native": "src/index", | ||
| "types": "build-types", | ||
| "sideEffects": false, | ||
| "dependencies": { | ||
| "@babel/runtime": "7.25.7", | ||
| "@wordpress/components": "file:../components", | ||
| "@wordpress/element": "file:../element", | ||
| "clsx": "^2.1.1" | ||
| }, | ||
| "publishConfig": { | ||
| "access": "public" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| export { default as NavigableRegion } from './navigable-region'; | ||
| export { default as Page } from './page'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| /** | ||
| * WordPress dependencies | ||
| */ | ||
| import { | ||
| __experimentalHeading as Heading, | ||
| __experimentalHStack as HStack, | ||
| __experimentalVStack as VStack, | ||
| } from '@wordpress/components'; | ||
|
|
||
| export default function Header( { | ||
| breadcrumbs, | ||
| badges, | ||
| title, | ||
| subTitle, | ||
| actions, | ||
| }: { | ||
| breadcrumbs?: React.ReactNode; | ||
| badges?: React.ReactNode; | ||
| title?: React.ReactNode; | ||
| subTitle: React.ReactNode; | ||
| actions?: React.ReactNode; | ||
| showSidebarToggle?: boolean; | ||
| } ) { | ||
| return ( | ||
| <VStack className="admin-ui-page__header" as="header"> | ||
| <HStack | ||
| className="admin-ui-page__header-title" | ||
| justify="space-between" | ||
| spacing={ 2 } | ||
| > | ||
| <HStack spacing={ 2 }> | ||
| { title && ( | ||
| <Heading as="h2" level={ 3 } weight={ 500 } truncate> | ||
| { title } | ||
| </Heading> | ||
| ) } | ||
| { breadcrumbs } | ||
| { badges } | ||
| </HStack> | ||
| <HStack | ||
| style={ { width: 'auto', flexShrink: 0 } } | ||
| spacing={ 2 } | ||
| > | ||
| { actions } | ||
| </HStack> | ||
| </HStack> | ||
| { subTitle && ( | ||
| <p className="admin-ui-page__header-subtitle">{ subTitle }</p> | ||
| ) } | ||
| </VStack> | ||
| ); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| /** | ||
| * External dependencies | ||
| */ | ||
| import clsx from 'clsx'; | ||
|
|
||
| /** | ||
| * Internal dependencies | ||
| */ | ||
| import Header from './header'; | ||
| import NavigableRegion from '../navigable-region'; | ||
|
|
||
| function Page( { | ||
| breadcrumbs, | ||
| badges, | ||
| title, | ||
| subTitle, | ||
| children, | ||
| className, | ||
| actions, | ||
| hasPadding = true, | ||
| }: { | ||
| breadcrumbs?: React.ReactNode; | ||
| badges?: React.ReactNode; | ||
| title?: React.ReactNode; | ||
| subTitle?: React.ReactNode; | ||
| children: React.ReactNode; | ||
| className?: string; | ||
| actions?: React.ReactNode; | ||
| hasPadding?: boolean; | ||
| } ) { | ||
| const classes = clsx( 'admin-ui-page', className ); | ||
|
|
||
| return ( | ||
| <NavigableRegion className={ classes } ariaLabel={ title }> | ||
| { ( title || breadcrumbs || badges ) && ( | ||
| <Header | ||
| breadcrumbs={ breadcrumbs } | ||
| badges={ badges } | ||
| title={ title } | ||
| subTitle={ subTitle } | ||
| actions={ actions } | ||
| /> | ||
| ) } | ||
| <div | ||
| className={ clsx( 'admin-ui-page__content', { | ||
| 'has-padding': hasPadding, | ||
| } ) } | ||
| > | ||
| { children } | ||
| </div> | ||
| </NavigableRegion> | ||
| ); | ||
| } | ||
|
|
||
| export default Page; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| .admin-ui-page { | ||
| height: 100%; | ||
| background: $white; | ||
| color: $gray-800; | ||
| container: admin-ui-page / inline-size; | ||
|
|
||
| @media not (prefers-reduced-motion) { | ||
| transition: width ease-out 0.2s; | ||
| } | ||
| } | ||
|
|
||
| .admin-ui-page__header { | ||
| padding: $grid-unit-20 $grid-unit-60; | ||
| border-bottom: 1px solid $gray-100; | ||
| background: $white; | ||
| position: sticky; | ||
| top: 0; | ||
|
|
||
| @container (max-width: 430px) { | ||
| padding: $grid-unit-20 $grid-unit-30; | ||
| } | ||
| } | ||
|
|
||
| .admin-ui-page__header-subtitle { | ||
| padding-block-end: $grid-unit-10; | ||
| color: $gray-700; | ||
| @include body-medium(); | ||
| margin: 0; | ||
| } | ||
|
|
||
| .admin-ui-page__content { | ||
| flex-grow: 1; | ||
| overflow: auto; | ||
| display: flex; | ||
| flex-direction: column; | ||
|
|
||
| &.has-padding { | ||
| padding: $grid-unit-20 $grid-unit * 2.5; | ||
| @container (max-width: 430px) { | ||
| padding: $grid-unit-20 $grid-unit-30; | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| @import "./page/style.scss"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| { | ||
| "$schema": "https://json.schemastore.org/tsconfig.json", | ||
| "extends": "../../tsconfig.base.json", | ||
| "references": [ { "path": "../components" }, { "path": "../element" } ] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Breadcrumbs sounds like a very handy feature as we think about admin pages with potentially deep structures like settings. How does this render? Should breadcrumbs appear before the title, with the title acting as the 'current item' in the trail?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea here is that it replaces the title, you provide one or the other, not both