Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement package search bar on docs website #270

Merged
merged 35 commits into from
Jul 23, 2019
Merged
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
bbcfbdd
Port yarn v1 search bar code almost as is
larixer Jul 1, 2019
3dd9e75
Get rid of direct document access and warnings
larixer Jul 2, 2019
986954c
Add package details showing mechanics
larixer Jul 2, 2019
01f20c6
Fix SSR problems
larixer Jul 2, 2019
40cc484
Add search box styling
larixer Jul 3, 2019
665ba28
Make search bar a part of header
larixer Jul 4, 2019
55ed0b9
Reset font-family for input to make it larger
larixer Jul 4, 2019
179ef06
Prevent control buttons crash into input on small screens
larixer Jul 5, 2019
734a424
Add hits styling
larixer Jul 5, 2019
9f4ed96
Imrpove front page responsive design
larixer Jul 5, 2019
d14d6e2
Add pagination styling
larixer Jul 5, 2019
211bd65
Add round corners to pagination section
larixer Jul 8, 2019
d156e94
Add package detail layout
larixer Jul 8, 2019
a15c6f1
Use template strings instead of manual replacements
larixer Jul 9, 2019
53eff46
Add basic readme styling
larixer Jul 10, 2019
db428e2
Add changelog styling
larixer Jul 11, 2019
7d50a61
Add link box styles
larixer Jul 17, 2019
7323b08
Update link styles on hover
larixer Jul 17, 2019
932ab0c
Add styles for use it section
larixer Jul 17, 2019
b9c2eb9
Add all styles to right sidebar
larixer Jul 18, 2019
a1d9f8c
Use functional React components
larixer Jul 18, 2019
fbf4adb
Add basic layout to files browser
larixer Jul 18, 2019
6104a11
Add basic styling to file details
larixer Jul 22, 2019
09c9fd1
Add alert styles to file browser
larixer Jul 22, 2019
d2c7598
Use React Hooks in File Browser
larixer Jul 23, 2019
0265de4
Get rid of extra classNames
larixer Jul 23, 2019
f831e63
Add styles to package not found page
larixer Jul 23, 2019
036f03c
Use withPrefix
larixer Jul 23, 2019
f125ca0
Add keywords styling
larixer Jul 23, 2019
9efdba6
Fix location update logic
larixer Jul 23, 2019
c490113
Use query param for package name for both prod and dev sites
larixer Jul 23, 2019
3738db7
DiBox styling fixes
larixer Jul 23, 2019
0b7d4a4
Add ellipsises to aside links
larixer Jul 23, 2019
5b703c9
Add collapsed readmore content shadowing
larixer Jul 23, 2019
eb0aa05
Merge branch 'master' into site-search
arcanis Jul 23, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96,903 changes: 69,793 additions & 27,110 deletions .pnp.js

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
14 changes: 13 additions & 1 deletion packages/gatsby/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@
"@emotion/core": "^10.0.7",
"@emotion/styled": "^10.0.7",
"@emotion/styled-base": "^10.0.7",
"@haroenv/react-sparklines": "^1.7.1",
"@reach/router": "npm:^1.1.1",
"algoliasearch": "^3.32.1",
"bytes": "^3.1.0",
"date-fns": "^2.0.0-beta.2",
"es6-promise": "^4.2.6",
"gatsby": "^2.13.6",
"gatsby-image": "^2.0.31",
Expand All @@ -25,17 +28,26 @@
"gatsby-source-filesystem": "^2.0.23",
"gatsby-transformer-remark": "^2.3.2",
"gatsby-transformer-sharp": "^2.1.15",
"highlight.js": "^9.15.8",
"marked": "^0.6.3",
"minimatch": "^3.0.4",
"pify": "^4.0.1",
"prismjs": "^1.16.0",
"prop-types": "^15.7.2",
"qs": "^6.7.0",
"react": "^16.8.4",
"react-dom": "^16.8.4",
"react-helmet": "^5.2.0",
"react-icons": "^3.7.0",
"react-instantsearch-dom": "^5.7.0",
"react-transition-group": "^1.2.1",
"regenerator-runtime": "^0.13.3",
"remark-html": "^9.0.0",
"remark-parse": "^6.0.3",
"unified": "^7.1.0"
"unescape-html": "^1.1.0",
"unfetch": "^4.1.0",
"unified": "^7.1.0",
"xss": "^1.0.6"
},
"scripts": {
"build:doc": "rm -rf .cache public && gatsby build --prefix-paths \"$@\" && rsync -rtuc --delete public/ ../../docs/",
Expand Down
10 changes: 10 additions & 0 deletions packages/gatsby/src/components/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export const algolia = {
appId: 'OFCNCOG2CU',
apiKey: 'f54e21fa3a2a0160595bb058179bfb1e',
indexName: 'npm-search',
};

export const docsearch = {
apiKey: '3949f721e5d8ca1de8928152ff745b28',
indexName: 'yarnpkg',
};
47 changes: 47 additions & 0 deletions packages/gatsby/src/components/details/Activity.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import React from 'react';
import { Sparklines, SparklinesLine } from '@haroenv/react-sparklines';

import { Di } from './';

const Activity = ({
graphData,
graphLink,
lastCommit,
commitsLastThreeMonths,
}) => {
if (!graphData && !graphLink && !lastCommit && !commitsLastThreeMonths) {
return null;
}

return (
<article>
<h1>Activity</h1>

{graphData && (
<a href={graphLink} target="_blank" rel="noopener noreferrer">
<Sparklines data={graphData} width={100} height={15}>
<SparklinesLine color="#2C8EBB" />
</Sparklines>
</a>
)}
<dl>
{commitsLastThreeMonths >= 0 && (
<Di
icon="commits"
title="Commits last 3 months"
description={commitsLastThreeMonths}
/>
)}
{lastCommit && (
<Di
icon="commits-last"
title="Last commit"
description={lastCommit}
/>
)}
</dl>
</article>
);
};

export default Activity;
82 changes: 82 additions & 0 deletions packages/gatsby/src/components/details/Aside.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import React from 'react';
import styled from '@emotion/styled';

import Install from './Install';
import Cdn from './Cdn';
import Links from './Links';
import Activity from './Activity';
import Popularity from './Popularity';
import Usage from './Usage';
import Versions from './Versions';
import Contributors from './Contributors';
import Tags from './Tags';
import { packageJSONLink, isKnownRepositoryHost } from '../util';
import GithubActivity from './GithubActivity';

const AsideContainer = styled.aside`
border-left: 1px solid #cbcbcb;
float: left;
width: 33.3333333333%;
padding: 0 15px;
`;

const DetailsLinks = styled.article`
margin-bottom: 2em;
`;

const Aside = ({
name,
homepage,
repository,
contributors,
activity,
downloads,
humanDownloads,
stargazers,
dependents,
humanDependents,
dependencies,
tags,
versions,
version,
devDependencies,
bundlesize,
onOpenFileBrowser,
jsDelivrHits,
}) => (
<AsideContainer>
<DetailsLinks>
<Links name={name} homepage={homepage} repository={repository} />
</DetailsLinks>
<Install name={name} onOpenFileBrowser={onOpenFileBrowser} />
<Cdn name={name} version={version} />
<Popularity
repository={repository}
downloads={downloads}
humanDownloads={humanDownloads}
stargazers={stargazers}
dependents={dependents}
humanDependents={humanDependents}
name={name}
jsDelivrHits={jsDelivrHits}
/>
{repository &&
isKnownRepositoryHost(repository.host) &&
(repository.host === 'github.com' ? (
<GithubActivity data={activity} repository={repository} />
) : (
<Activity {...activity} repository={repository} />
))}
<Usage
dependencies={dependencies}
devDependencies={devDependencies}
bundlesize={bundlesize}
{...packageJSONLink(name)}
/>
<Tags tags={tags} name={name} />
<Versions versions={versions} />
<Contributors contributors={contributors} />
</AsideContainer>
);

export default Aside;
90 changes: 90 additions & 0 deletions packages/gatsby/src/components/details/Cdn.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import React from 'react';
import styled from '@emotion/styled';

import { Di } from './';

const CdnBox = styled.article`
h1 {
color: #5a5a5a;
margin-top: 0;
margin-bottom: .5rem;
font-weight: 600;
font-size: 1.2em;
line-height: 1.1;
}
`;

const JsDelivr = ({ name, version }) => (
<Di
title="jsDelivr"
description={
<a
href={`https://cdn.jsdelivr.net/npm/${name}@${version}/`}
target="_blank"
rel="noopener noreferrer"
>
cdn.jsdelivr.net/npm/{name}/
</a>
}
/>
);

const Unpkg = ({ name, version }) => (
<Di
title="unpkg"
description={
<a
href={`https://unpkg.com/${name}@${version}/`}
target="_blank"
rel="noopener noreferrer"
>
unpkg.com/{name}/
</a>
}
/>
);

const BundleRun = ({ name, version }) => (
<Di
title="bundle.run"
description={
<a
href={`https://bundle.run/${name}@${version}`}
target="_blank"
rel="noopener noreferrer"
>
bundle.run/{name}
</a>
}
/>
);

const Cdn = ({ name, version }) => {
const cdns = {
jsdelivr: JsDelivr,
unpkg: Unpkg,
bundlerun: BundleRun
};

const order = Object.keys(cdns).sort(() => Math.random() - 0.5);

const items = order.map(key => {
const Component = cdns[key];
return (
<Component
key={key}
name={name}
version={version}
/>
);
});

return (
<CdnBox>
<h1>CDNs</h1>
<dl>{items}</dl>
</CdnBox>
);
};

export default Cdn;
18 changes: 18 additions & 0 deletions packages/gatsby/src/components/details/Contributors.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React from 'react';

import {Owner} from '../hit';

const Contributors = ({ contributors }) => (
<article>
<h1>Contributors</h1>
<ul>
{contributors.map(contributor => (
<li key={contributor.name}>
<Owner {...contributor} />
</li>
))}
</ul>
</article>
);

export default Contributors;
Loading