-
Notifications
You must be signed in to change notification settings - Fork 46
[WEB-4686] Add PageHeader component and migrate LanguageSelector to Radix UI #2956
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
Open
jamiehenson
wants to merge
8
commits into
web-4684-docs-redesign
Choose a base branch
from
web-4686-docs-header
base: web-4684-docs-redesign
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
a2f8b27
chore: add radix-ui/react-select
jamiehenson 8ac23d4
chore: add ibm plex serif font as font-serif
jamiehenson 850f824
chore: rewrite LanguageSelector using radix/react-select
jamiehenson 3d25aec
feat: add new PageHeader unit
jamiehenson 4dd6fd6
fix: update breadcrumbs behaviour
jamiehenson 59f14ca
fix: allow padding for container-bordering focus outlines
jamiehenson bf3d01c
chore: add skeleton component as a placeholder for loading language s…
jamiehenson b0e9d5e
fix: unlock scrolling when radix select dropdown open
jamiehenson 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
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 |
|---|---|---|
|
|
@@ -27,7 +27,7 @@ export const Head = ({ | |
| <link rel="preconnect" href="https://fonts.googleapis.com" /> | ||
| <link rel="preconnect" href="https://fonts.gstatic.com" crossOrigin="" /> | ||
| <link | ||
| href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:ital,wght@0,100..800;1,100..800&family=Manrope:[email protected]&family=Source+Code+Pro:wght@600&display=swap" | ||
| href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:ital,wght@0,100..800;1,100..800&family=Manrope:[email protected]&family=Source+Code+Pro:wght@600&family=IBM+Plex+Serif:ital,wght@1,400;1,700&display=swap" | ||
| rel="stylesheet" | ||
| /> | ||
| </Helmet> | ||
|
|
||
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 |
|---|---|---|
| @@ -1,31 +1,34 @@ | ||
| import React, { useMemo } from 'react'; | ||
| import React from 'react'; | ||
| import { useLayoutContext } from 'src/contexts/layout-context'; | ||
| import Link from '../Link'; | ||
| import Icon from '@ably/ui/core/Icon'; | ||
| import cn from '@ably/ui/core/utils/cn'; | ||
| import { hierarchicalKey, PageTreeNode } from './utils/nav'; | ||
| import { hierarchicalKey } from './utils/nav'; | ||
|
|
||
| const linkStyles = | ||
| 'ui-text-label4 font-semibold text-neutral-900 hover:text-neutral-1300 active:text-neutral-800 dark:text-neutral-400 dark:hover:text-neutral-000 dark:active:text-neutral-500 focus-base transition-colors'; | ||
|
|
||
| const Breadcrumbs: React.FC = () => { | ||
| const { activePage } = useLayoutContext(); | ||
|
|
||
| const breadcrumbNodes = useMemo(() => { | ||
| const filteredNodes = activePage?.tree.filter((node) => node.page.link !== '#') ?? []; | ||
| const uniqueNodes = filteredNodes.reduce((acc: PageTreeNode[], current) => { | ||
| const isDuplicate = acc.some((item) => item.page.link === current.page.link); | ||
| if (!isDuplicate) { | ||
| acc.push(current); | ||
| } | ||
| return acc; | ||
| }, []); | ||
| return uniqueNodes; | ||
| }, [activePage?.tree]); | ||
|
|
||
| if (breadcrumbNodes.length === 0) { | ||
| if (!activePage?.tree || activePage.tree.length === 0) { | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't need to do this processing anymore, we no longer care about eliminating duplicates |
||
| return null; | ||
| } | ||
|
|
||
| const linkStyles = | ||
| 'ui-text-label4 font-semibold text-neutral-900 hover:text-neutral-1300 active:text-neutral-800 dark:text-neutral-400 dark:hover:text-neutral-000 dark:active:text-neutral-500'; | ||
| const lastActiveNodeIndex = (() => { | ||
| const index = activePage.tree | ||
| .toReversed() | ||
| .slice(1) | ||
| .findIndex((node) => node.page.link !== '#'); | ||
|
|
||
| if (index !== -1) { | ||
| return activePage.tree.length - index - 2; | ||
| } | ||
|
|
||
| return null; | ||
| })(); | ||
|
|
||
| console.log(lastActiveNodeIndex, activePage.tree); | ||
|
|
||
| return ( | ||
| <nav aria-label="breadcrumb" className="flex mt-8 items-center gap-1"> | ||
|
|
@@ -35,17 +38,18 @@ const Breadcrumbs: React.FC = () => { | |
| <Icon | ||
| name="icon-gui-chevron-right-micro" | ||
| size="16px" | ||
| additionalCSS={cn('rotate-180 sm:rotate-0', { 'hidden sm:flex': breadcrumbNodes.length === 1 })} | ||
| color="text-neutral-900 dark:text-neutral-400" | ||
| additionalCSS={cn('rotate-180 sm:rotate-0', { 'hidden sm:flex': lastActiveNodeIndex === null })} | ||
| /> | ||
| {breadcrumbNodes.map((node, index) => ( | ||
| {activePage.tree.map((node, index) => ( | ||
| <React.Fragment key={hierarchicalKey(node.page.link, index, activePage.tree)}> | ||
| {index > 0 ? <Icon name="icon-gui-chevron-right-micro" size="16px" additionalCSS="hidden sm:flex" /> : null} | ||
| <Link | ||
| to={node.page.link} | ||
| className={cn(linkStyles, { | ||
| 'text-gui-unavailable dark:text-gui-unavailable-dark pointer-events-none': | ||
| index === breadcrumbNodes.length - 1, | ||
| 'hidden sm:flex': index !== breadcrumbNodes.length - 2, | ||
| index === activePage.tree.length - 1 || node.page.link === '#', | ||
| 'hidden sm:flex': index !== lastActiveNodeIndex, | ||
| })} | ||
| > | ||
| {node.page.name} | ||
|
|
||
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.
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.
This allows focus outlines to be visible when otherwise they would be cut off by the container's overflow property