Skip to content

Commit b0a28f5

Browse files
authored
fix(button): Fixes default button styling accessibility (#2814)
1 parent d531137 commit b0a28f5

File tree

5 files changed

+30
-8
lines changed

5 files changed

+30
-8
lines changed

examples/demo-react/src/App.css

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ main {
8080
}
8181

8282
/* search component wrapper */
83-
.search-wrapper {
83+
.search-wrapper,
84+
.default-wrapper {
8485
display: flex;
8586
justify-content: center;
8687
align-items: center;
@@ -114,7 +115,7 @@ main {
114115
}
115116

116117
/* docsearch button customization */
117-
.DocSearch-Button {
118+
.search-wrapper .DocSearch-Button {
118119
margin: 0 !important;
119120
background: #f7fafc !important;
120121
border: 2px solid #e2e8f0 !important;
@@ -125,13 +126,13 @@ main {
125126
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05) !important;
126127
}
127128

128-
.DocSearch-Button:hover {
129+
.search-wrapper .DocSearch-Button:hover {
129130
border-color: #667eea !important;
130131
box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15) !important;
131132
transform: translateY(-1px) !important;
132133
}
133134

134-
.DocSearch-Button-Placeholder {
135+
.search-wrapper .DocSearch-Button-Placeholder {
135136
color: #718096 !important;
136137
}
137138

examples/demo-react/src/App.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import '@docsearch/css/dist/style.css';
88
import Basic from './examples/basic';
99
import BasicAskAI from './examples/basic-askai';
1010
import Composable from './examples/composable';
11+
import Default from './examples/default';
1112
import DynamicImportModal from './examples/dynamic-import-modal';
1213
import MultiIndex from './examples/multi-index';
1314
import WHitComponent from './examples/w-hit-component';
@@ -24,6 +25,13 @@ function App(): JSX.Element {
2425
</header>
2526

2627
<main>
28+
<section className="demo-section">
29+
<p className="section-description">default</p>
30+
<div className="default-wrapper">
31+
<Default />
32+
</div>
33+
</section>
34+
2735
<section className="demo-section">
2836
<p className="section-description">basic search functionality</p>
2937
<div className="search-wrapper">
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/* eslint-disable react/react-in-jsx-scope */
2+
import { DocSearch } from '@docsearch/react';
3+
import type { JSX } from 'react';
4+
5+
export default function DefaultExperience(): JSX.Element {
6+
return <DocSearch indexName="docsearch" appId="PMZUYBQDAK" apiKey="24b09689d5b4223813d9b8e48563c8f6" />;
7+
}

packages/docsearch-css/src/_variables.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020
--docsearch-logo-color: rgba(0, 61, 255, 1);
2121
--docsearch-border-radius: 4px;
2222

23+
/* button */
24+
--docsearch-search-button-background: #fff;
25+
--docsearch-search-button-text-color: var(--docsearch-secondary-text-color);
26+
2327
/* modal */
2428
--docsearch-modal-width: 800px;
2529
--docsearch-modal-height: 600px;
@@ -111,4 +115,6 @@ html[data-theme='dark'] {
111115
);
112116
--docsearch-dropdown-menu-background: var(--docsearch-hit-background);
113117
--docsearch-dropdown-menu-item-hover-background: var(--docsearch-modal-background);
118+
--docsearch-search-button-background: var(--docsearch-modal-background);
119+
--docsearch-search-button-text-color: var(--docsearch-text-color);
114120
}

packages/docsearch-css/src/button.css

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
align-items: center;
33
border: 1px solid var(--docsearch-subtle-color);
44
border-radius: 4px;
5-
background-color: var(--docsearch-searchbox-background);
6-
color: var(--docsearch-muted-color);
5+
background-color: var(--docsearch-search-button-background);
6+
color: var(--docsearch-search-button-text-color);
77
cursor: pointer;
88
display: flex;
99
all: unset;
@@ -20,7 +20,7 @@
2020
}
2121

2222
.DocSearch-Button-Container svg {
23-
color: var(--docsearch-muted-color);
23+
color: currentColor;
2424
}
2525

2626
.DocSearch-Search-Icon {
@@ -37,7 +37,7 @@
3737
font-size: 1rem;
3838
padding-block: 0;
3939
padding-inline: 8px 12px;
40-
color: var(--docsearch-muted-color);
40+
color: currentColor;
4141
display: inline-block;
4242
line-height: normal;
4343
}

0 commit comments

Comments
 (0)