Skip to content

Commit 2b1c799

Browse files
Move duplicated code into check-search-color function
1 parent f14e4db commit 2b1c799

File tree

1 file changed

+98
-218
lines changed

1 file changed

+98
-218
lines changed

tests/rustdoc-gui/search-result-color.goml

+98-218
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ include: "utils.goml"
44

55
define-function: (
66
"check-search-color",
7-
[theme, count_color, desc_color, path_color, bottom_border_color],
7+
[
8+
theme, count_color, desc_color, path_color, bottom_border_color, keyword_color,
9+
struct_color, associatedtype_color, tymethod_color, method_color, structfield_color,
10+
structfield_hover_color, macro_color, fn_color, hover_path_color, hover_background, grey
11+
],
812
block {
913
call-function: ("switch-theme", {"theme": |theme|})
1014

@@ -29,6 +33,59 @@ define-function: (
2933
".search-results > a",
3034
{"border-bottom-color": |bottom_border_color|}
3135
)
36+
37+
store-value: (entry_color, |path_color|) // color of the search entry
38+
store-value: (hover_entry_color, |hover_path_color|) // color of the hovered/focused search entry
39+
store-value: (background_color, "transparent")
40+
store-value: (hover_background_color, |hover_background|)
41+
store-value: (grey, |grey|)
42+
43+
call-function: ("check-result-color", {
44+
"result_kind": "keyword",
45+
"color": |keyword_color|,
46+
"hover_color": |keyword_color|,
47+
})
48+
call-function: ("check-result-color", {
49+
"result_kind": "struct",
50+
"color": |struct_color|,
51+
"hover_color": |struct_color|,
52+
})
53+
call-function: ("check-result-color", {
54+
"result_kind": "associatedtype",
55+
"color": |associatedtype_color|,
56+
"hover_color": |associatedtype_color|,
57+
})
58+
call-function: ("check-result-color", {
59+
"result_kind": "tymethod",
60+
"color": |tymethod_color|,
61+
"hover_color": |tymethod_color|,
62+
})
63+
call-function: ("check-result-color", {
64+
"result_kind": "method",
65+
"color": |method_color|,
66+
"hover_color": |method_color|,
67+
})
68+
call-function: ("check-result-color", {
69+
"result_kind": "structfield",
70+
"color": |structfield_color|,
71+
"hover_color": |structfield_hover_color|,
72+
})
73+
call-function: ("check-result-color", {
74+
"result_kind": "macro",
75+
"color": |macro_color|,
76+
"hover_color": |macro_color|,
77+
})
78+
call-function: ("check-result-color", {
79+
"result_kind": "fn",
80+
"color": |fn_color|,
81+
"hover_color": |fn_color|,
82+
})
83+
84+
call-function: ("check-container-color", {
85+
"path_color": |path_color|,
86+
"hover_path_color": |hover_path_color|,
87+
"hover_background": |hover_background|,
88+
})
3289
}
3390
)
3491

@@ -71,26 +128,26 @@ define-function: (
71128

72129
define-function: (
73130
"check-container-color",
74-
[link_color, path_color, hover_background],
131+
[path_color, hover_path_color, hover_background],
75132
block {
76133
// Checking the `<a>` container.
77134
move-cursor-to: ".search-input"
78135
focus: ".search-input" // To ensure the `<a>` container isn't focused or hovered.
79136
assert-css: (
80137
"//*[@class='result-name']//*[text()='test_docs::']/ancestor::a",
81-
{"color": |link_color|, "background-color": "transparent"},
138+
{"color": |path_color|, "background-color": "transparent"},
82139
ALL,
83140
)
84141

85142
// Checking color and background on hover.
86143
move-cursor-to: "//*[@class='desc'][text()='Just a normal struct.']"
87144
assert-css: (
88145
"//*[@class='result-name']//*[text()='test_docs::']",
89-
{"color": |path_color|},
146+
{"color": |hover_path_color|},
90147
)
91148
assert-css: (
92149
"//*[@class='result-name']//*[text()='test_docs::']/ancestor::a",
93-
{"color": |path_color|, "background-color": |hover_background|},
150+
{"color": |hover_path_color|, "background-color": |hover_background|},
94151
)
95152
}
96153
)
@@ -107,239 +164,62 @@ call-function: ("check-search-color", {
107164
"desc_color": "#c5c5c5",
108165
"path_color": "#0096cf",
109166
"bottom_border_color": "#aaa3",
167+
"keyword_color": "#39afd7",
168+
"struct_color": "#ffa0a5",
169+
"associatedtype_color": "#39afd7",
170+
"tymethod_color": "#fdd687",
171+
"method_color": "#fdd687",
172+
"structfield_color": "#0096cf",
173+
"structfield_hover_color": "#fff",
174+
"macro_color": "#a37acc",
175+
"fn_color": "#fdd687",
176+
"hover_path_color": "#fff",
177+
"hover_background": "#3c3c3c",
178+
"grey": "#999",
110179
})
111180

112-
store-value: (entry_color, "#0096cf") // color of the search entry
113-
store-value: (hover_entry_color, "#fff") // color of the hovered/focused search entry
114-
store-value: (background_color, "transparent") // background color
115-
store-value: (hover_background_color, "#3c3c3c") // hover background color
116-
store-value: (grey, "#999")
117-
118-
call-function: (
119-
"check-result-color", {
120-
"result_kind": "keyword",
121-
"color": "#39afd7",
122-
"hover_color": "#39afd7",
123-
},
124-
)
125-
call-function: (
126-
"check-result-color", {
127-
"result_kind": "struct",
128-
"color": "#ffa0a5",
129-
"hover_color": "#ffa0a5",
130-
},
131-
)
132-
call-function: (
133-
"check-result-color", {
134-
"result_kind": "associatedtype",
135-
"color": "#39afd7",
136-
"hover_color": "#39afd7",
137-
},
138-
)
139-
call-function: (
140-
"check-result-color", {
141-
"result_kind": "tymethod",
142-
"color": "#fdd687",
143-
"hover_color": "#fdd687",
144-
},
145-
)
146-
call-function: (
147-
"check-result-color", {
148-
"result_kind": "method",
149-
"color": "#fdd687",
150-
"hover_color": "#fdd687",
151-
},
152-
)
153-
call-function: (
154-
"check-result-color", {
155-
"result_kind": "structfield",
156-
"color": "#0096cf",
157-
"hover_color": "#fff",
158-
},
159-
)
160-
call-function: (
161-
"check-result-color", {
162-
"result_kind": "macro",
163-
"color": "#a37acc",
164-
"hover_color": "#a37acc",
165-
},
166-
)
167-
call-function: (
168-
"check-result-color", {
169-
"result_kind": "fn",
170-
"color": "#fdd687",
171-
"hover_color": "#fdd687",
172-
},
173-
)
174-
175-
call-function: (
176-
"check-container-color", {
177-
"link_color": "#0096cf",
178-
"path_color": "#fff",
179-
"hover_background": "#3c3c3c",
180-
},
181-
)
182-
183181
// Dark theme
184182
call-function: ("check-search-color", {
185183
"theme": "dark",
186184
"count_color": "#888",
187185
"desc_color": "#ddd",
188186
"path_color": "#ddd",
189187
"bottom_border_color": "#aaa3",
188+
"keyword_color": "#d2991d",
189+
"struct_color": "#2dbfb8",
190+
"associatedtype_color": "#d2991d",
191+
"tymethod_color": "#2bab63",
192+
"method_color": "#2bab63",
193+
"structfield_color": "#ddd",
194+
"structfield_hover_color": "#ddd",
195+
"macro_color": "#09bd00",
196+
"fn_color": "#2bab63",
197+
"hover_path_color": "#ddd",
198+
"hover_background": "#616161",
199+
"grey": "#ccc",
190200
})
191201

192-
store-value: (entry_color, "#ddd") // color of the search entry
193-
store-value: (hover_entry_color, "#ddd") // color of the hovered/focused search entry
194-
store-value: (background_color, "transparent") // background color
195-
store-value: (hover_background_color, "#616161") // hover background color
196-
store-value: (grey, "#ccc")
197-
198-
call-function: (
199-
"check-result-color", {
200-
"result_kind": "keyword",
201-
"color": "#d2991d",
202-
"hover_color": "#d2991d",
203-
},
204-
)
205-
call-function: (
206-
"check-result-color", {
207-
"result_kind": "struct",
208-
"color": "#2dbfb8",
209-
"hover_color": "#2dbfb8",
210-
},
211-
)
212-
call-function: (
213-
"check-result-color", {
214-
"result_kind": "associatedtype",
215-
"color": "#d2991d",
216-
"hover_color": "#d2991d",
217-
},
218-
)
219-
call-function: (
220-
"check-result-color", {
221-
"result_kind": "tymethod",
222-
"color": "#2bab63",
223-
"hover_color": "#2bab63",
224-
},
225-
)
226-
call-function: (
227-
"check-result-color", {
228-
"result_kind": "method",
229-
"color": "#2bab63",
230-
"hover_color": "#2bab63",
231-
},
232-
)
233-
call-function: (
234-
"check-result-color", {
235-
"result_kind": "structfield",
236-
"color": "#ddd",
237-
"hover_color": "#ddd",
238-
},
239-
)
240-
call-function: (
241-
"check-result-color", {
242-
"result_kind": "macro",
243-
"color": "#09bd00",
244-
"hover_color": "#09bd00",
245-
},
246-
)
247-
call-function: (
248-
"check-result-color", {
249-
"result_kind": "fn",
250-
"color": "#2bab63",
251-
"hover_color": "#2bab63",
252-
},
253-
)
254-
255-
call-function: (
256-
"check-container-color", {
257-
"link_color": "#ddd",
258-
"path_color": "#ddd",
259-
"hover_background": "#616161",
260-
},
261-
)
262-
263202
// Light theme
264203
call-function: ("check-search-color", {
265204
"theme": "light",
266205
"count_color": "#888",
267206
"desc_color": "#000",
268207
"path_color": "#000",
269208
"bottom_border_color": "#aaa3",
209+
"keyword_color": "#3873ad",
210+
"struct_color": "#ad378a",
211+
"associatedtype_color": "#3873ad",
212+
"tymethod_color": "#ad7c37",
213+
"method_color": "#ad7c37",
214+
"structfield_color": "#000",
215+
"structfield_hover_color": "#000",
216+
"macro_color": "#068000",
217+
"fn_color": "#ad7c37",
218+
"hover_path_color": "#000",
219+
"hover_background": "#ccc",
220+
"grey": "#999",
270221
})
271222

272-
store-value: (entry_color, "#000") // color of the search entry
273-
store-value: (hover_entry_color, "#000") // color of the hovered/focused search entry
274-
store-value: (background_color, "transparent") // background color
275-
store-value: (hover_background_color, "#ccc") // hover background color
276-
store-value: (grey, "#999")
277-
278-
call-function: (
279-
"check-result-color", {
280-
"result_kind": "keyword",
281-
"color": "#3873ad",
282-
"hover_color": "#3873ad",
283-
},
284-
)
285-
call-function: (
286-
"check-result-color", {
287-
"result_kind": "struct",
288-
"color": "#ad378a",
289-
"hover_color": "#ad378a",
290-
},
291-
)
292-
call-function: (
293-
"check-result-color", {
294-
"result_kind": "associatedtype",
295-
"color": "#3873ad",
296-
"hover_color": "#3873ad",
297-
},
298-
)
299-
call-function: (
300-
"check-result-color", {
301-
"result_kind": "tymethod",
302-
"color": "#ad7c37",
303-
"hover_color": "#ad7c37",
304-
},
305-
)
306-
call-function: (
307-
"check-result-color", {
308-
"result_kind": "method",
309-
"color": "#ad7c37",
310-
"hover_color": "#ad7c37",
311-
},
312-
)
313-
call-function: (
314-
"check-result-color", {
315-
"result_kind": "structfield",
316-
"color": "#000",
317-
"hover_color": "#000",
318-
},
319-
)
320-
call-function: (
321-
"check-result-color", {
322-
"result_kind": "macro",
323-
"color": "#068000",
324-
"hover_color": "#068000",
325-
},
326-
)
327-
call-function: (
328-
"check-result-color", {
329-
"result_kind": "fn",
330-
"color": "#ad7c37",
331-
"hover_color": "#ad7c37",
332-
},
333-
)
334-
335-
call-function: (
336-
"check-container-color", {
337-
"link_color": "#000",
338-
"path_color": "#000",
339-
"hover_background": "#ccc",
340-
},
341-
)
342-
343223
// Check the alias.
344224
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
345225
// If the text isn't displayed, the browser doesn't compute color style correctly...

0 commit comments

Comments
 (0)