Skip to content

Commit

Permalink
Merge pull request #1101 from newrelic/sunny/fix-search-icons
Browse files Browse the repository at this point in the history
fix: add prop for kbd shortcut display
  • Loading branch information
sunnyzanchi authored Oct 17, 2024
2 parents c5b3deb + 3a1f1a3 commit b9565bc
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ const GlobalSearch = ({ onClose }) => {
placeholder={t('searchInput.placeholder')}
ref={searchRef}
setValue={setQuery}
showShortcut
size={SearchInput.SIZE.MEDIUM}
value={query}
css={css`
Expand Down
44 changes: 24 additions & 20 deletions packages/gatsby-theme-newrelic/src/components/SearchInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const SearchInput = forwardRef(
onMove,
setValue,
size = 'medium',
showShortcut = false,
value,
width,
...props
Expand Down Expand Up @@ -196,27 +197,29 @@ const SearchInput = forwardRef(
}
`}
/>
<kbd
css={css`
border: 1px solid currentColor;
border-radius: 4px;
display: inline-grid;
line-height: 1.1;
margin-right: 0.25rem;
padding: 2px 4px;
place-items: center;
position: absolute;
right: 0.5rem;
top: 50%;
transform: translateY(-50%);
{showShortcut && (
<kbd
css={css`
border: 1px solid currentColor;
border-radius: 4px;
display: inline-grid;
line-height: 1.1;
margin-right: 0.25rem;
padding: 2px 4px;
place-items: center;
position: absolute;
right: 0.5rem;
top: 50%;
transform: translateY(-50%);
@media (max-width: ${mobileBreakpoint}) {
display: none;
}
`}
>
/
</kbd>
@media (max-width: ${mobileBreakpoint}) {
display: none;
}
`}
>
/
</kbd>
)}
{onClear && (
<button
onClick={(e) => {
Expand Down Expand Up @@ -295,6 +298,7 @@ SearchInput.propTypes = {
onSubmit: PropTypes.func,
setValue: PropTypes.func.isRequired,
size: PropTypes.oneOf(Object.values(SIZES)),
showShortcut: PropTypes.bool,
value: PropTypes.string,
width: PropTypes.string,
};
Expand Down

0 comments on commit b9565bc

Please sign in to comment.