Skip to content

Commit fd139be

Browse files
authored
Implement new search UI design and add keyboard navigation (#2235)
* Implement new search UI design and add keyboard navigation * Update src/Elastic.Documentation.Site/Assets/web-components/SearchOrAskAi/Search/SearchResults/SearchResultsListItem.tsx * Update src/Elastic.Documentation.Site/Assets/web-components/SearchOrAskAi/Search/SearchResults/SearchResultsListItem.tsx * Update src/Elastic.Documentation.Site/Assets/web-components/SearchOrAskAi/Search/SearchResults/SearchResultsListItem.tsx
1 parent e73310b commit fd139be

File tree

12 files changed

+1158
-474
lines changed

12 files changed

+1158
-474
lines changed
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
import { useIsAskAiCooldownActive } from '../AskAi/useAskAiCooldown'
2+
import { EuiButton, EuiIcon, useEuiTheme } from '@elastic/eui'
3+
import { css } from '@emotion/react'
4+
import { forwardRef } from 'react'
5+
6+
interface TellMeMoreButtonProps {
7+
term: string
8+
onAsk: () => void
9+
onArrowUp?: () => void
10+
isInputFocused: boolean
11+
}
12+
13+
export const TellMeMoreButton = forwardRef<
14+
HTMLButtonElement,
15+
TellMeMoreButtonProps
16+
>(({ term, onAsk, onArrowUp, isInputFocused }, ref) => {
17+
const isAskAiCooldownActive = useIsAskAiCooldownActive()
18+
const { euiTheme } = useEuiTheme()
19+
20+
const askAiButtonStyles = css`
21+
font-weight: ${euiTheme.font.weight.bold};
22+
color: ${euiTheme.colors.link};
23+
`
24+
25+
return (
26+
<div
27+
css={css`
28+
@keyframes gradientMove {
29+
from {
30+
background-position: 0% 0%;
31+
}
32+
to {
33+
background-position: 100% 0%;
34+
}
35+
}
36+
height: 42px;
37+
background: linear-gradient(
38+
90deg,
39+
#f04e98 0%,
40+
#02bcb7 25%,
41+
#f04e98 50%,
42+
#02bcb7 75%,
43+
#f04e98 100%
44+
);
45+
background-size: 200% 100%;
46+
background-position: 0% 0%;
47+
display: flex;
48+
align-items: center;
49+
justify-content: center;
50+
border-radius: 4px;
51+
animation: gradientMove 3s ease infinite;
52+
`}
53+
>
54+
<EuiButton
55+
buttonRef={ref}
56+
css={css`
57+
& > span {
58+
display: flex;
59+
align-items: center;
60+
justify-content: flex-start;
61+
width: 100%;
62+
gap: ${euiTheme.size.s};
63+
}
64+
margin-inline: 1px;
65+
border: none;
66+
position: relative;
67+
:focus .return-key-icon {
68+
visibility: visible;
69+
}
70+
`}
71+
color="text"
72+
fullWidth
73+
onClick={onAsk}
74+
disabled={isAskAiCooldownActive}
75+
onKeyDown={(e) => {
76+
if (e.key === 'ArrowUp') {
77+
e.preventDefault()
78+
onArrowUp?.()
79+
}
80+
}}
81+
>
82+
<span
83+
css={css`
84+
flex: 1;
85+
min-width: 0;
86+
overflow: hidden;
87+
text-overflow: ellipsis;
88+
white-space: nowrap;
89+
text-align: left;
90+
`}
91+
>
92+
Tell me more about&nbsp;
93+
<span css={askAiButtonStyles}>{term}</span>
94+
</span>
95+
<EuiIcon
96+
className="return-key-icon"
97+
css={css`
98+
visibility: ${isInputFocused ? 'visible' : 'hidden'};
99+
flex-shrink: 0;
100+
`}
101+
type="returnKey"
102+
color="subdued"
103+
size="m"
104+
/>
105+
</EuiButton>
106+
</div>
107+
)
108+
})
109+
110+
TellMeMoreButton.displayName = 'TellMeMoreButton'

0 commit comments

Comments
 (0)