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

fix: add prop for kbd shortcut display #1101

Merged
merged 1 commit into from
Oct 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix: add prop for kbd shortcut display
sunnyzanchi committed Oct 17, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 3a1f1a3c28c950a2ffdac4413a518a556220988a
Original file line number Diff line number Diff line change
@@ -130,6 +130,7 @@ const GlobalSearch = ({ onClose }) => {
placeholder={t('searchInput.placeholder')}
ref={searchRef}
setValue={setQuery}
showShortcut
size={SearchInput.SIZE.MEDIUM}
value={query}
css={css`
44 changes: 24 additions & 20 deletions packages/gatsby-theme-newrelic/src/components/SearchInput.js
Original file line number Diff line number Diff line change
@@ -46,6 +46,7 @@ const SearchInput = forwardRef(
onMove,
setValue,
size = 'medium',
showShortcut = false,
value,
width,
...props
@@ -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) => {
@@ -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,
};