Skip to content

Commit 69e4ce5

Browse files
committed
feat(search): show typescript support
1 parent 0466f8a commit 69e4ce5

File tree

7 files changed

+28
-1
lines changed

7 files changed

+28
-1
lines changed

_sass/_search.scss

+7
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,13 @@ $ais-muted-color: rgba(black, 0.5);
348348
width: 26px;
349349
height: 26px;
350350
}
351+
352+
&-typescript {
353+
margin-left: 0.2em;
354+
width: 0.8em;
355+
height: 0.8em;
356+
vertical-align: baseline;
357+
}
351358
}
352359

353360
.ais-Pagination {

assets/search/ico-typescript.svg

+3
Loading

js/src/lib/Details/Header.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { License, Deprecated, Owner, Downloads } from '../Hit';
2+
import { License, Deprecated, Owner, Downloads, TypeScript } from '../Hit';
33
import { Keywords, safeMarkdown } from '../util';
44

55
const Description = ({ description, deprecated }) => (
@@ -26,6 +26,7 @@ const Header = ({
2626
deprecated,
2727
keywords,
2828
version,
29+
types,
2930
}) => (
3031
<header className="details-main--header">
3132
<h2 className="details-main--title d-inline-block m-2">{name}</h2>
@@ -38,6 +39,7 @@ const Header = ({
3839
<License type={license} />
3940
<Deprecated deprecated={deprecated} />
4041
<span className="ais-Hit-version">{version}</span>
42+
<TypeScript ts={types.ts} />
4143
</div>
4244
<Description description={description} deprecated={deprecated} />
4345
<Keywords keywords={keywords} />

js/src/lib/Details/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,7 @@ class Details extends Component {
335335
deprecated={this.state.deprecated}
336336
keywords={this.state.keywords}
337337
version={this.state.version}
338+
types={this.state.types}
338339
/>
339340
<section id="readme" className="details-doc">
340341
<h3 className="details-doc--title details-doc--title__readme py-1">

js/src/lib/Hit/index.js

+12
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,17 @@ export const Downloads = ({ downloads = 0, humanDownloads }) => (
5555
</span>
5656
);
5757

58+
export const TypeScript = ({ ts = false }) => {
59+
return ts !== false ? (
60+
<img
61+
className="ais-Hit-typescript"
62+
src="/assets/search/ico-typescript.svg"
63+
alt={`TypeScript support: ${ts}`}
64+
title={`TypeScript support: ${ts}`}
65+
/>
66+
) : null;
67+
};
68+
5869
const Repository = ({ repository, name }) => {
5970
const [provider] = repository.host.split('.');
6071

@@ -110,6 +121,7 @@ const Hit = ({ hit, onTagClick, onOwnerClick }) => (
110121
<License type={hit.license} />
111122
<Deprecated deprecated={hit.deprecated} />
112123
<span className="ais-Hit-version">{hit.version}</span>
124+
<TypeScript ts={hit.types.ts} />
113125
<p className="ais-Hit-description">
114126
{hit.deprecated ? (
115127
hit.deprecated

js/src/lib/Search/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ class Search extends Component {
8989
'name',
9090
'owner',
9191
'version',
92+
'types',
9293
]}
9394
attributesToHighlight={['name', 'description', 'keywords']}
9495
/>

js/src/lib/schema.js

+1
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,6 @@ export default {
5151
version: '',
5252
versions: {},
5353
tags: {},
54+
types: {},
5455
loaded: false,
5556
};

0 commit comments

Comments
 (0)