-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(unified-search): revise suggested pages design (#2024)
* chore: enable flags for dev and preview * chore: stub in separate suggested search component * chore: use component after results too * feat: implement revised suggested page * fix: avoid user-select of nbsp fix * chore: fix grid gap * fix: hcp suggested page icon color * chore: remove redundant content div
- Loading branch information
Showing
8 changed files
with
112 additions
and
14 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -13,6 +13,6 @@ | |
"max_static_paths": 1 | ||
}, | ||
"flags": { | ||
"enable_unified_search": false | ||
"enable_unified_search": true | ||
} | ||
} |
This file contains 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 |
---|---|---|
|
@@ -4,6 +4,6 @@ | |
"max_static_paths": 10 | ||
}, | ||
"flags": { | ||
"enable_unified_search": false | ||
"enable_unified_search": true | ||
} | ||
} |
This file contains 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
51 changes: 51 additions & 0 deletions
51
...omponents/command-bar/commands/search/unified-search/components/suggested-pages/index.tsx
This file contains 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,51 @@ | ||
/** | ||
* Copyright (c) HashiCorp, Inc. | ||
* SPDX-License-Identifier: MPL-2.0 | ||
*/ | ||
|
||
import Text from 'components/text' | ||
import LinkRegion from 'components/link-region' | ||
import IconTile from 'components/icon-tile' | ||
import { CommandBarList } from 'components/command-bar/components' | ||
import { SuggestedPageProps } from './types' | ||
// Styles | ||
import s from './suggested-page.module.css' | ||
|
||
/** | ||
* Renders a single suggested page list item. | ||
*/ | ||
function SuggestedPage({ icon, url, text }: SuggestedPageProps) { | ||
return ( | ||
<LinkRegion className={s.root} href={url} ariaLabel={text}> | ||
<div className={s.content}> | ||
<IconTile className={s.icon} size="small"> | ||
{icon} | ||
</IconTile> | ||
<Text | ||
dangerouslySetInnerHTML={{ __html: text }} | ||
asElement="span" | ||
className={s.text} | ||
size={300} | ||
weight="medium" | ||
/> | ||
</div> | ||
</LinkRegion> | ||
) | ||
} | ||
|
||
/** | ||
* Renders a list of suggested search result pages. | ||
*/ | ||
function SuggestedPages({ pages }: { pages: SuggestedPageProps[] }) { | ||
return ( | ||
<CommandBarList label="Suggested Pages"> | ||
{pages.map(({ url, icon, text }: SuggestedPageProps) => ( | ||
<li key={url}> | ||
<SuggestedPage icon={icon} text={text} url={url} /> | ||
</li> | ||
))} | ||
</CommandBarList> | ||
) | ||
} | ||
|
||
export default SuggestedPages |
35 changes: 35 additions & 0 deletions
35
...d-bar/commands/search/unified-search/components/suggested-pages/suggested-page.module.css
This file contains 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,35 @@ | ||
.root { | ||
--border-radius: 5px; | ||
|
||
border-radius: var(--border-radius); | ||
padding: 8px; | ||
|
||
&:hover { | ||
background: var(--token-color-surface-strong); | ||
box-shadow: var(--token-surface-base-box-shadow); | ||
cursor: pointer; | ||
} | ||
} | ||
|
||
.content { | ||
display: flex; | ||
align-items: center; | ||
gap: 8px; | ||
} | ||
|
||
.icon { | ||
color: var(--token-color-foreground-primary); | ||
flex-shrink: 0; | ||
|
||
@media (--dev-dot-mobile) { | ||
display: none; | ||
} | ||
} | ||
|
||
.text { | ||
color: var(--token-color-foreground-strong); | ||
display: block; | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
white-space: nowrap; | ||
} |
14 changes: 14 additions & 0 deletions
14
...components/command-bar/commands/search/unified-search/components/suggested-pages/types.ts
This file contains 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,14 @@ | ||
/** | ||
* Copyright (c) HashiCorp, Inc. | ||
* SPDX-License-Identifier: MPL-2.0 | ||
*/ | ||
|
||
import { ReactElement } from 'react' | ||
|
||
interface SuggestedPageProps { | ||
icon: ReactElement | ||
text: string | ||
url: string | ||
} | ||
|
||
export type { SuggestedPageProps } |
This file contains 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 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 |
---|---|---|
|
@@ -20,6 +20,7 @@ | |
bottom: 0; | ||
left: 0; | ||
right: 0; | ||
user-select: none; | ||
|
||
/* makes the whole region clickable */ | ||
&::before { | ||
|
72577b4
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.
Successfully deployed to the following URLs:
dev-portal – ./
dev-portal-hashicorp.vercel.app
dev-portal-git-main-hashicorp.vercel.app
docs.hashicorp.com
developer.hashicorp.com