Skip to content

Commit 643d2d5

Browse files
committed
Remove result count from filter badges and fix related styling
1 parent 67a8b61 commit 643d2d5

File tree

1 file changed

+44
-26
lines changed
  • src/Elastic.Documentation.Site/Assets/web-components/SearchOrAskAi/Search/SearchResults

1 file changed

+44
-26
lines changed

src/Elastic.Documentation.Site/Assets/web-components/SearchOrAskAi/Search/SearchResults/SearchFilters.tsx

Lines changed: 44 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,13 @@ import { css } from '@emotion/react'
44
import { useRef, useCallback, MutableRefObject } from 'react'
55

66
interface SearchFiltersProps {
7-
counts: {
8-
apiResultsCount: number
9-
docsResultsCount: number
10-
totalCount: number
11-
}
127
isLoading: boolean
138
inputRef?: React.RefObject<HTMLInputElement>
149
itemRefs?: MutableRefObject<(HTMLAnchorElement | null)[]>
1510
resultsCount?: number
1611
}
1712

1813
export const SearchFilters = ({
19-
counts,
2014
isLoading,
2115
inputRef,
2216
itemRefs,
@@ -29,7 +23,6 @@ export const SearchFilters = ({
2923
const { euiTheme } = useEuiTheme()
3024
const selectedFilter = useTypeFilter()
3125
const { setTypeFilter } = useSearchActions()
32-
const { apiResultsCount, docsResultsCount, totalCount } = counts
3326

3427
const filterRefs = useRef<(HTMLButtonElement | null)[]>([])
3528

@@ -64,8 +57,38 @@ export const SearchFilters = ({
6457

6558
const buttonStyle = css`
6659
border-radius: 99999px;
67-
padding-inline: ${euiTheme.size.m};
60+
padding-inline: ${euiTheme.size.s};
6861
min-inline-size: auto;
62+
&[aria-pressed='true'] {
63+
background-color: ${euiTheme.colors.backgroundBaseHighlighted};
64+
border-color: ${euiTheme.colors.borderStrongPrimary};
65+
color: ${euiTheme.colors.textPrimary};
66+
border-width: 1px;
67+
border-style: solid;
68+
span svg {
69+
fill: ${euiTheme.colors.textPrimary};
70+
}
71+
}
72+
&:hover,
73+
&:focus-visible,
74+
&:hover:not(:disabled)::before {
75+
background-color: ${euiTheme.colors.backgroundBaseHighlighted};
76+
}
77+
&[aria-pressed='true']:hover,
78+
&[aria-pressed='true']:focus-visible {
79+
background-color: ${euiTheme.colors.backgroundBaseHighlighted};
80+
border-color: ${euiTheme.colors.borderStrongPrimary};
81+
color: ${euiTheme.colors.textPrimary};
82+
}
83+
span {
84+
gap: 4px;
85+
&.eui-textTruncate {
86+
padding-inline: 4px;
87+
}
88+
svg {
89+
fill: ${euiTheme.colors.borderBaseProminent};
90+
}
91+
}
6992
`
7093

7194
return (
@@ -79,13 +102,12 @@ export const SearchFilters = ({
79102
role="group"
80103
aria-label="Search filters"
81104
>
105+
82106
<EuiButton
83107
color="text"
84108
iconType="globe"
85-
iconSize="s"
86-
// @ts-expect-error: xs is valid size according to EuiButton docs
87-
size="xs"
88-
fill={selectedFilter === 'all'}
109+
iconSize="m"
110+
size="s"
89111
onClick={() => setTypeFilter('all')}
90112
onKeyDown={(e: React.KeyboardEvent<HTMLButtonElement>) =>
91113
handleFilterKeyDown(e, 0)
@@ -94,18 +116,16 @@ export const SearchFilters = ({
94116
filterRefs.current[0] = el
95117
}}
96118
css={buttonStyle}
97-
aria-label={`Show all results, ${totalCount} total`}
119+
aria-label={`Show all results`}
98120
aria-pressed={selectedFilter === 'all'}
99121
>
100-
{`ALL (${totalCount})`}
122+
{`All`}
101123
</EuiButton>
102124
<EuiButton
103125
color="text"
104-
iconType="document"
105-
iconSize="s"
106-
// @ts-expect-error: xs is valid size according to EuiButton docs
107-
size="xs"
108-
fill={selectedFilter === 'doc'}
126+
iconType="documentation"
127+
iconSize="m"
128+
size="s"
109129
onClick={() => setTypeFilter('doc')}
110130
onKeyDown={(e: React.KeyboardEvent<HTMLButtonElement>) =>
111131
handleFilterKeyDown(e, 1)
@@ -114,18 +134,16 @@ export const SearchFilters = ({
114134
filterRefs.current[1] = el
115135
}}
116136
css={buttonStyle}
117-
aria-label={`Filter to documentation results, ${docsResultsCount} available`}
137+
aria-label={`Filter to documentation results`}
118138
aria-pressed={selectedFilter === 'doc'}
119139
>
120-
{`DOCS (${docsResultsCount})`}
140+
{`Docs`}
121141
</EuiButton>
122142
<EuiButton
123143
color="text"
124144
iconType="code"
125145
iconSize="s"
126-
// @ts-expect-error: xs is valid size according to EuiButton docs
127-
size="xs"
128-
fill={selectedFilter === 'api'}
146+
size="s"
129147
onClick={() => setTypeFilter('api')}
130148
onKeyDown={(e: React.KeyboardEvent<HTMLButtonElement>) =>
131149
handleFilterKeyDown(e, 2)
@@ -134,10 +152,10 @@ export const SearchFilters = ({
134152
filterRefs.current[2] = el
135153
}}
136154
css={buttonStyle}
137-
aria-label={`Filter to API results, ${apiResultsCount} available`}
155+
aria-label={`Filter to API results`}
138156
aria-pressed={selectedFilter === 'api'}
139157
>
140-
{`API (${apiResultsCount})`}
158+
{`API`}
141159
</EuiButton>
142160
</div>
143161
<EuiSpacer size="m" />

0 commit comments

Comments
 (0)