Skip to content

Commit b1e588d

Browse files
committed
UI ✨
1 parent 72b965c commit b1e588d

File tree

3 files changed

+25
-7
lines changed

3 files changed

+25
-7
lines changed

www/components/Header.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,21 @@ type HeaderProps = {
4949
};
5050

5151
const Header = ({ project, showSearch = true }: HeaderProps) => {
52+
const placeholder = project
53+
? `👉Search for a name in ${project.name}👈`
54+
: "👉Search👈";
5255
return (
5356
<HeaderContainer>
5457
<HeaderContent>
5558
<HeaderItem width={showSearch ? "60%" : "100%"}>
56-
<HeaderText>Python. Wabbajack Theatrical Fantasy</HeaderText>
59+
<HeaderText>py.wtf: Docs for Python projects on PyPI</HeaderText>
5760
</HeaderItem>
5861
{showSearch && project && (
5962
<HeaderItem width="40%">
60-
<Search descriptors={generateProjectIndex(project)} />
63+
<Search
64+
descriptors={generateProjectIndex(project)}
65+
placeholder={placeholder}
66+
/>
6167
</HeaderItem>
6268
)}
6369
</HeaderContent>

www/components/core/Search.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { Link } from "./navigation/Link";
1010

1111
type SearchParams = {
1212
descriptors: Index;
13+
placeholder: string;
1314
};
1415

1516
const SearchContainer = styled.div`
@@ -49,6 +50,12 @@ const ItemLink = styled(Link)`
4950
width: 100%;
5051
`;
5152

53+
const SearchInput = styled.input`
54+
::placeholder {
55+
text-align: center;
56+
}
57+
`;
58+
5259
interface MatchProps {
5360
result: Result;
5461
}
@@ -84,7 +91,7 @@ function Match({ result }: MatchProps): ReactElement {
8491
);
8592
}
8693

87-
export const Search = ({ descriptors }: SearchParams) => {
94+
export const Search = ({ descriptors, placeholder }: SearchParams) => {
8895
const [searchTerm, setSearchTerm] = useState("");
8996
const [results, setResults] = useState<Results | null>(null);
9097
useHotkeys("/", (event) => {
@@ -116,12 +123,13 @@ export const Search = ({ descriptors }: SearchParams) => {
116123

117124
return (
118125
<SearchContainer>
119-
<input
126+
<SearchInput
120127
id="Search_Input"
121128
onChange={(event) => {
122129
setSearchTerm(event.target.value);
123130
}}
124131
value={searchTerm}
132+
placeholder={`${placeholder} (press / to focus)`}
125133
onKeyDown={(event) => keyPressHandler(event, -1)}
126134
/>
127135
{searchTerm && results && (

www/pages/index.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ function useHomeData() {
133133

134134
function humanizeTime(timestamp: number) {
135135
const dt = new Intl.DateTimeFormat(undefined, {
136-
timeStyle: "long",
136+
timeStyle: "short",
137137
dateStyle: "long",
138138
});
139139
return dt.format(timestamp * 1000);
@@ -162,7 +162,10 @@ export default function Home({
162162
<PageLayout title="py.wtf" header={<Header showSearch={false} />}>
163163
<ProjectContainer>
164164
<SearchContainer>
165-
<Search descriptors={makeIndex(descriptors)} />
165+
<Search
166+
descriptors={makeIndex(descriptors)}
167+
placeholder="👉Search for a Python package👈"
168+
/>
166169
</SearchContainer>
167170
<ProjectTables>
168171
<ProjectTable
@@ -177,7 +180,8 @@ export default function Home({
177180
/>
178181
</ProjectTables>
179182
<TimestampFooter>
180-
Generated on {humanizeTime(generatedAt)}
183+
Generated on {humanizeTime(generatedAt)} for {descriptors.length}{" "}
184+
projects
181185
</TimestampFooter>
182186
</ProjectContainer>
183187
</PageLayout>

0 commit comments

Comments
 (0)