Skip to content

Commit 0032f38

Browse files
feat(js): wrap item action buttons in container (#434)
1 parent 1d53bb9 commit 0032f38

File tree

4 files changed

+58
-44
lines changed

4 files changed

+58
-44
lines changed

examples/js/app.tsx

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -124,15 +124,17 @@ function ProductItem({ hit }: ProductItemProps) {
124124
{snippetHit<ProductHit>({ hit, attribute: 'description' })}
125125
</div>
126126
</div>
127-
<button
128-
className="aa-ItemActionButton aa-TouchOnly aa-ActiveOnly"
129-
type="button"
130-
title="Select"
131-
>
132-
<svg fill="currentColor" viewBox="0 0 24 24" width="20" height="20">
133-
<path d="M18.984 6.984h2.016v6h-15.188l3.609 3.609-1.406 1.406-6-6 6-6 1.406 1.406-3.609 3.609h13.172v-4.031z"></path>
134-
</svg>
135-
</button>
127+
<div className="aa-ItemActions">
128+
<button
129+
className="aa-ItemActionButton aa-TouchOnly aa-ActiveOnly"
130+
type="button"
131+
title="Select"
132+
>
133+
<svg fill="currentColor" viewBox="0 0 24 24" width="20" height="20">
134+
<path d="M18.984 6.984h2.016v6h-15.188l3.609 3.609-1.406 1.406-6-6 6-6 1.406 1.406-3.609 3.609h13.172v-4.031z"></path>
135+
</svg>
136+
</button>
137+
</div>
136138
</Fragment>
137139
);
138140
}

packages/autocomplete-plugin-query-suggestions/src/getTemplates.tsx

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,26 @@ export function getTemplates<TItem extends QuerySuggestionsHit>({
3636
})}
3737
</div>
3838
</div>
39-
<button
40-
className="aa-ItemActionButton"
41-
title={`Fill query with "${item.query}"`}
42-
onClick={(event) => {
43-
event.stopPropagation();
44-
onTapAhead(item);
45-
}}
46-
>
47-
<svg viewBox="0 0 24 24" fill="currentColor" width="18" height="18">
48-
<rect fill="none" height="24" width="24" />
49-
<path d="M5,15h2V8.41L18.59,20L20,18.59L8.41,7H15V5H5V15z" />
50-
</svg>
51-
</button>
39+
<div className="aa-ItemActions">
40+
<button
41+
className="aa-ItemActionButton"
42+
title={`Fill query with "${item.query}"`}
43+
onClick={(event) => {
44+
event.stopPropagation();
45+
onTapAhead(item);
46+
}}
47+
>
48+
<svg
49+
viewBox="0 0 24 24"
50+
fill="currentColor"
51+
width="18"
52+
height="18"
53+
>
54+
<rect fill="none" height="24" width="24" />
55+
<path d="M5,15h2V8.41L18.59,20L20,18.59L8.41,7H15V5H5V15z" />
56+
</svg>
57+
</button>
58+
</div>
5259
</Fragment>
5360
);
5461
},

packages/autocomplete-plugin-recent-searches/src/getTemplates.tsx

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -29,29 +29,31 @@ export function getTemplates<TItem extends RecentSearchesItem>({
2929
})}
3030
</div>
3131
</div>
32-
<button
33-
className="aa-ItemActionButton"
34-
title="Remove this search"
35-
onClick={(event) => {
36-
event.stopPropagation();
37-
onRemove(item.id);
38-
}}
39-
>
40-
<svg
41-
viewBox="0 0 24 24"
42-
width="20"
43-
height="20"
44-
fill="none"
45-
stroke="currentColor"
32+
<div className="aa-ItemActions">
33+
<button
34+
className="aa-ItemActionButton"
35+
title="Remove this search"
36+
onClick={(event) => {
37+
event.stopPropagation();
38+
onRemove(item.id);
39+
}}
4640
>
47-
<path
48-
d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"
49-
strokeLinecap="round"
50-
strokeLinejoin="round"
51-
strokeWidth={2}
52-
/>
53-
</svg>
54-
</button>
41+
<svg
42+
viewBox="0 0 24 24"
43+
width="18"
44+
height="18"
45+
fill="none"
46+
stroke="currentColor"
47+
>
48+
<path
49+
d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"
50+
strokeLinecap="round"
51+
strokeLinejoin="round"
52+
strokeWidth={2}
53+
/>
54+
</svg>
55+
</button>
56+
</div>
5557
</Fragment>
5658
);
5759
},

packages/autocomplete-theme-classic/src/theme.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,9 @@ body {
410410
}
411411
}
412412
// secondary click action
413+
.aa-ItemActions {
414+
display: flex;
415+
}
413416
.aa-ItemActionButton {
414417
align-items: center;
415418
background: none;

0 commit comments

Comments
 (0)