Skip to content

Commit 74d5b24

Browse files
Replace hardcoded strings with customizable attributes in multiple components (#893)
* Update shell.handlebars adding two options: search_button search_placeholder * Update table.handlebars adding search_placeholder option * Update 01_documentation.sql documentation update for the shell component options: search_placeholder search_button and for the table component option: search_placeholder * avoid failing tests on long loading map tiles * add an example for search_placeholder --------- Co-authored-by: lovasoa <[email protected]>
1 parent 32778bf commit 74d5b24

File tree

4 files changed

+18
-9
lines changed

4 files changed

+18
-9
lines changed

examples/official-site/sqlpage/migrations/01_documentation.sql

+14-5
Original file line numberDiff line numberDiff line change
@@ -770,6 +770,7 @@ INSERT INTO parameter(component, name, description, type, top_level, optional) S
770770
('sort', 'Make the columns clickable to let the user sort by the value contained in the column.', 'BOOLEAN', TRUE, TRUE),
771771
('search', 'Add a search bar at the top of the table, letting users easily filter table rows by value.', 'BOOLEAN', TRUE, TRUE),
772772
('initial_search_value', 'Pre-fills the search bar used to filter the table. The user will still be able to edit the value to display table rows that will initially be filtered out.', 'TEXT', TRUE, TRUE),
773+
('search_placeholder', 'Customizes the placeholder text shown in the search input field. Replaces the default "Search..." with text that better describes what users should search for.', 'TEXT', TRUE, TRUE),
773774
('markdown', 'Set this to the name of a column whose content should be interpreted as markdown . Used to display rich text with links in the table. This argument can be repeated multiple times to intepret multiple columns as markdown.', 'TEXT', TRUE, TRUE),
774775
('icon', 'Set this to the name of a column whose content should be interpreted as a tabler icon name. Used to display icons in the table. This argument can be repeated multiple times to intepret multiple columns as icons. Introduced in v0.8.0.', 'TEXT', TRUE, TRUE),
775776
('align_right', 'Name of a column the contents of which should be right-aligned. This argument can be repeated multiple times to align multiple columns to the right. Introduced in v0.15.0.', 'TEXT', TRUE, TRUE),
@@ -801,9 +802,11 @@ INSERT INTO example(component, description, properties) VALUES
801802
('table', 'The most basic table.',
802803
json('[{"component":"table"}, {"a": 1, "b": 2}, {"a": 3, "b": 4}]')),
803804
('table', 'A table of users with filtering and sorting.',
804-
json('[{"component":"table", "sort":true, "search":true}, '||
805-
'{"First Name": "Ophir", "Last Name": "Lojkine", "Pseudonym": "lovasoa"},' ||
806-
'{"First Name": "Linus", "Last Name": "Torvalds", "Pseudonym": "torvalds"}]')),
805+
json('[
806+
{"component":"table", "sort":true, "search":true, "search_placeholder": "Filter by name"},
807+
{"First Name": "Ophir", "Last Name": "Lojkine", "Pseudonym": "lovasoa"},
808+
{"First Name": "Linus", "Last Name": "Torvalds", "Pseudonym": "torvalds"}
809+
]')),
807810
('table', 'A table that uses markdown to display links',
808811
json('[{"component":"table", "markdown": "Name", "icon": "icon", "search": true}, '||
809812
'{"icon": "table", "name": "[Table](?component=table)", "description": "Displays SQL results as a searchable table.", "_sqlpage_color": "red"},
@@ -835,8 +838,12 @@ Numbers can be displayed
835838
'table',
836839
'A table with some presentation options',
837840
json(
838-
'[{"component":"table", "hover": true, "striped_rows": true, "description": "Some Star Trek Starfleet starships", "small": true, "initial_search_value": "NCC-" },'||
839-
'{"name": "USS Enterprise", "registry": "NCC-1701-C", "class":"Ambassador"},
841+
'[{"component":"table",
842+
"hover": true, "striped_rows": true,
843+
"description": "Some Star Trek Starfleet starships",
844+
"small": true, "initial_search_value": "NCC-"
845+
},
846+
{"name": "USS Enterprise", "registry": "NCC-1701-C", "class":"Ambassador"},
840847
{"name": "USS Archer", "registry": "NCC-44278", "class":"Archer"},
841848
{"name": "USS Endeavour", "registry": "NCC-06", "class":"Columbia"},
842849
{"name": "USS Constellation", "registry": "NCC-1974", "class":"Constellation"},
@@ -1174,6 +1181,8 @@ INSERT INTO parameter(component, name, description, type, top_level, optional) S
11741181
('fixed_top_menu', 'Fixes the top bar with menu at the top (the top bar remains visible when scrolling long pages).', 'BOOLEAN', TRUE, TRUE),
11751182
('search_target', 'When this is set, a search field will appear in the top navigation bar, and load the specified sql file with an URL parameter named "search" when the user searches something.', 'TEXT', TRUE, TRUE),
11761183
('search_value', 'This value will be placed in the search field when "search_target" is set. Using the "$search" query parameter value will mirror the value that the user has searched for.', 'TEXT', TRUE, TRUE),
1184+
('search_placeholder', 'Customizes the placeholder text shown in the search input field. Replaces the default "Search" with text that better describes what users should search for.', 'TEXT', TRUE, TRUE),
1185+
('search_button', 'Customizes the text displayed on the search button. Replaces the default "Search" label with custom text that may better match your applications terminology or language.', 'TEXT', TRUE, TRUE),
11771186
('norobot', 'Forbids robots to save this page in their database and follow the links on this page. This will prevent this page to appear in Google search results for any query, for instance.', 'BOOLEAN', TRUE, TRUE),
11781187
('font', 'Specifies the font to be used for displaying text, which can be a valid font name from fonts.google.com or the path to a local WOFF2 font file starting with a slash (e.g., "/fonts/MyLocalFont.woff2").', 'TEXT', TRUE, TRUE),
11791188
('font_size', 'Font size on the page, in pixels. Set to 18 by default.', 'INTEGER', TRUE, TRUE),

sqlpage/templates/shell.handlebars

+2-2
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,8 @@
155155
</ul>
156156
{{#if search_target}}
157157
<form class="d-flex" role="search" action="{{search_target}}">
158-
<input class="form-control me-2" type="search" placeholder="Search" aria-label="Search" name="search" value="{{search_value}}">
159-
<button class="btn btn-outline-success" type="submit">Search</button>
158+
<input class="form-control me-2" type="search" placeholder="{{default search_placeholder 'Search'}}" aria-label="Search" name="search" value="{{search_value}}">
159+
<button class="btn btn-outline-success" type="submit">{{default search_button 'Search'}}</button>
160160
</form>
161161
{{/if}}
162162
{{/inline}}

sqlpage/templates/table.handlebars

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<input
66
type="search"
77
class="form-control form-control-rounded fs-6 search"
8-
placeholder="Search…"
8+
placeholder="{{default search_placeholder 'Search…'}}"
99
value="{{initial_search_value}}"
1010
{{#if initial_search_value}}autocomplete="off"{{/if}}
1111
>

tests/end-to-end/official-site.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ async function checkNoConsoleErrors(page: Page, component: string) {
137137
});
138138

139139
await page.goto(`${BASE}/documentation.sql?component=${component}`);
140-
await page.waitForLoadState("networkidle");
140+
await page.waitForLoadState();
141141

142142
expect(errors).toHaveLength(0);
143143
}

0 commit comments

Comments
 (0)