Skip to content

Commit 1250946

Browse files
authored
Merge branch 'main' into 5515-sops-lock
2 parents 0f39f3b + ac741ef commit 1250946

3 files changed

Lines changed: 271 additions & 0 deletions

File tree

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import pagefindCss from '../../styles/pagefind.css?raw';
2+
3+
export async function GET() {
4+
return new Response(pagefindCss, {
5+
headers: {
6+
'Content-Type': 'text/css',
7+
'Cache-Control': 'public, max-age=3600',
8+
},
9+
});
10+
}
Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
2+
/* Search Box */
3+
@media (width < 800px) {
4+
#search-and-buttons {
5+
width: calc(100% - 50px) !important;
6+
}
7+
}
8+
9+
site-search button {
10+
background-color: var(--color-opacity-5);
11+
border: 1px solid var(--color-opacity-10);
12+
border-radius: 6px;
13+
color: var(--color-gray-2);
14+
height: 100%;
15+
max-width: none;
16+
min-height: 44px;
17+
padding: 6px 12px;
18+
}
19+
20+
/* Search Box NOT inside Dialog */
21+
site-search>button {
22+
display: flex;
23+
width: 100%;
24+
}
25+
26+
site-search button svg {
27+
color: var(--color-gray-1);
28+
}
29+
30+
/* Search Dialog Box */
31+
site-search dialog[open] {
32+
background: var(--color-dialog-bg);
33+
border-radius: .5rem;
34+
display: flex;
35+
height: max-content;
36+
margin: 4rem auto auto;
37+
max-height: calc(100% - 8rem);
38+
max-width: 40rem;
39+
min-height: 15rem;
40+
width: 90%;
41+
}
42+
43+
button[data-close-modal] {
44+
color: black;
45+
display: none;
46+
}
47+
48+
site-search .dialog-frame {
49+
overflow-x: hidden;
50+
padding: 1.5rem;
51+
}
52+
53+
#starlight__search > div:nth-of-type(2) {
54+
display: none;
55+
}
56+
57+
site-search .pagefind-ui {
58+
color: oklch(0.37 0.013 285.805);
59+
}
60+
61+
site-search .pagefind-ui__drawer {
62+
display: flex;
63+
flex-direction: row;
64+
flex-wrap: wrap;
65+
}
66+
67+
site-search .pagefind-ui__results {
68+
padding-left: 0;
69+
}
70+
71+
site-search .pagefind-ui__result {
72+
padding: 20px 10px;
73+
}
74+
75+
/* Site Search Dark Mode */
76+
html[data-theme="dark"] site-search input,
77+
html[data-theme="dark"] site-search .pagefind-ui__result-link {
78+
color: rgb(19, 24, 36);
79+
}
80+
81+
82+
/*
83+
* Starlight Overrides
84+
*
85+
* Context: Starlight components apply different styles based on dark/light mode state.
86+
* This causes visual issues because the docs pages have dark mode support, but the homepage nav does not.
87+
* This override fixes an issue on the homepage nav by styling CMD+K in a consistent way across all pages in both * modes.
88+
*
89+
* Future Considerations:
90+
* - If homepage gains dark mode support, this override may need adjustment
91+
* - Consider if a more systematic theming approach is needed long-term
92+
*/
93+
site-search button kbd {
94+
background-color: transparent;
95+
font-size: var(--sl-text-sm);
96+
gap: 0;
97+
margin: 0 0 0 auto;
98+
}
99+
100+
.pagefind-ui__message {
101+
padding: 1.5em 0;
102+
height: auto;
103+
}
104+
105+
#starlight__search .pagefind-ui__form:before {
106+
background-color: black !important;
107+
}
108+
109+
input.pagefind-ui__search-input {
110+
background-color: white;
111+
color: black;
112+
border: 1px solid oklch(0.871 0.006 286.286);
113+
border-radius: 8px;
114+
max-width: 590px;
115+
padding-left: 50px;
116+
width: -webkit-fill-available;
117+
}
118+
119+
input.pagefind-ui__search-input::placeholder {
120+
color: #666;
121+
}
122+
123+
input.pagefind-ui__search-input:focus {
124+
outline: 2px solid #448daf;
125+
outline-offset: 2px;
126+
}
127+
128+
.pagefind-ui__search-clear {
129+
background-color: transparent;
130+
border: none;
131+
right: 0;
132+
}
133+
134+
.pagefind-ui__search-clear:before {
135+
background-color: black;
136+
content: "";
137+
display: block;
138+
height: 100%;
139+
margin-bottom: 20px;
140+
width: 100%;
141+
-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m13.41 12 6.3-6.29a1 1 0 1 0-1.42-1.42L12 10.59l-6.29-6.3a1 1 0 0 0-1.42 1.42l6.3 6.29-6.3 6.29a1 1 0 0 0 .33 1.64 1 1 0 0 0 1.09-.22l6.29-6.3 6.29 6.3a1 1 0 0 0 1.64-.33 1 1 0 0 0-.22-1.09L13.41 12Z'/%3E%3C/svg%3E") center / 100% no-repeat;
142+
mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m13.41 12 6.3-6.29a1 1 0 1 0-1.42-1.42L12 10.59l-6.29-6.3a1 1 0 0 0-1.42 1.42l6.3 6.29-6.3 6.29a1 1 0 0 0 .33 1.64 1 1 0 0 0 1.09-.22l6.29-6.3 6.29 6.3a1 1 0 0 0 1.64-.33 1 1 0 0 0-.22-1.09L13.41 12Z'/%3E%3C/svg%3E") center / 100% no-repeat;
143+
}
144+
145+
#starlight__search .pagefind-ui__result-title:not(:where(.pagefind-ui__result-nested *)),
146+
#starlight__search .pagefind-ui__result-nested,
147+
.pagefind-ui__result-title,
148+
.pagefind-ui__result-nested {
149+
background-color: transparent;
150+
}
151+
152+
.pagefind-ui__result {
153+
background: white;
154+
color: black;
155+
border-radius: 8px;
156+
margin-bottom: 20px;
157+
}
158+
159+
/* Fix search result icons - same approach as text fix */
160+
.pagefind-ui__result svg,
161+
.pagefind-ui__result svg path {
162+
fill: black;
163+
}
164+
165+
.pagefind-ui__result-link,
166+
.pagefind-ui__result-excerpt {
167+
color: black;
168+
}
169+
170+
.pagefind-ui__result-title a {
171+
color: black;
172+
}
173+
174+
.pagefind-ui__result-title a:hover {
175+
color: #448daf;
176+
}
177+
178+
/* Fix to site-search button area smaller on mobile */
179+
@media (width <= 768px) {
180+
body.tg site-search > button {
181+
width: 100%;
182+
}
183+
}

internal/util/file_test.go

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -714,3 +714,81 @@ func TestMoveFile(t *testing.T) {
714714
require.NoError(t, err)
715715
assert.Equal(t, "test", string(contents))
716716
}
717+
718+
func TestRelPathForLog(t *testing.T) {
719+
t.Parallel()
720+
721+
testCases := []struct {
722+
name string
723+
basePath string
724+
targetPath string
725+
expected string
726+
showAbsPath bool
727+
}{
728+
{
729+
name: "showAbsPath true returns targetPath unchanged",
730+
basePath: helpers.RootFolder + "base",
731+
targetPath: helpers.RootFolder + "base/child/file.txt",
732+
showAbsPath: true,
733+
expected: helpers.RootFolder + "base/child/file.txt",
734+
},
735+
{
736+
name: "same path returns targetPath",
737+
basePath: helpers.RootFolder + "base",
738+
targetPath: helpers.RootFolder + "base",
739+
showAbsPath: false,
740+
expected: helpers.RootFolder + "base",
741+
},
742+
{
743+
name: "child path gets ./ prefix",
744+
basePath: helpers.RootFolder + "base",
745+
targetPath: helpers.RootFolder + "base/child",
746+
showAbsPath: false,
747+
expected: "." + string(filepath.Separator) + "child",
748+
},
749+
{
750+
name: "nested child path gets ./ prefix",
751+
basePath: helpers.RootFolder + "base",
752+
targetPath: helpers.RootFolder + "base/child/subchild/file.txt",
753+
showAbsPath: false,
754+
expected: "." + string(filepath.Separator) + filepath.Join("child", "subchild", "file.txt"),
755+
},
756+
{
757+
name: "parent path returns relative path with ..",
758+
basePath: helpers.RootFolder + "base/child",
759+
targetPath: helpers.RootFolder + "base",
760+
showAbsPath: false,
761+
expected: "..",
762+
},
763+
{
764+
name: "sibling path returns relative path with ..",
765+
basePath: helpers.RootFolder + "base/child1",
766+
targetPath: helpers.RootFolder + "base/child2",
767+
showAbsPath: false,
768+
expected: ".." + string(filepath.Separator) + "child2",
769+
},
770+
{
771+
name: "deeply nested sibling path",
772+
basePath: helpers.RootFolder + "base/a/b/c",
773+
targetPath: helpers.RootFolder + "base/x/y/z",
774+
showAbsPath: false,
775+
expected: ".." + string(filepath.Separator) + ".." + string(filepath.Separator) + ".." + string(filepath.Separator) + filepath.Join("x", "y", "z"),
776+
},
777+
{
778+
name: "unrelated paths at different roots",
779+
basePath: helpers.RootFolder + "foo",
780+
targetPath: helpers.RootFolder + "bar/baz",
781+
showAbsPath: false,
782+
expected: ".." + string(filepath.Separator) + filepath.Join("bar", "baz"),
783+
},
784+
}
785+
786+
for _, tc := range testCases {
787+
t.Run(tc.name, func(t *testing.T) {
788+
t.Parallel()
789+
790+
actual := util.RelPathForLog(tc.basePath, tc.targetPath, tc.showAbsPath)
791+
assert.Equal(t, tc.expected, actual, "For basePath %s and targetPath %s", tc.basePath, tc.targetPath)
792+
})
793+
}
794+
}

0 commit comments

Comments
 (0)