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

Gatsby library search page #3456

Closed
wants to merge 247 commits into from
Closed

Gatsby library search page #3456

wants to merge 247 commits into from

Conversation

jastack
Copy link

@jastack jastack commented Jan 9, 2018

Added a draft of the plugin search with Algolia. Check it out by going to "/plugins/". The left side search bar functions in a very similar way to the regular sidebar, so I made some changes to the template index.js as well. Let me know if this is a good approach / going in the right direction! Doesn't have filter right now, but should be easy to add. @calcsam

@gatsbybot
Copy link
Collaborator

gatsbybot commented Jan 9, 2018

Deploy preview for gatsbygram ready!

Built with commit cb316ca

https://deploy-preview-3456--gatsbygram.netlify.com

@KyleAMathews
Copy link
Contributor

Looking good!

https://deploy-preview-3456--gatsbyjs.netlify.com/plugins/

screen shot 2018-01-09 at 4 17 21 pm

One quick bit of feedback — we use Yarn to manage dependencies not NPM so please remove the package-lock.json files that were added.

@calcsam
Copy link
Contributor

calcsam commented Jan 10, 2018

Awesome to see this on #3003! Thanks @jastack!

Some next steps:

  • URL stuff:
    (1) plugin links should be /plugins/name not /packages/name
    (2) search queries should be /plugins?text=URL_ENCODED_SEARCH_STRING so that if a user refreshes they get the same page. As you type things in the search bar the URL should update.

  • Right sidebar default is funky. Whenever the search bar is empty this should display the default panel as shown in @rdela's mock (but omit the learn link for now). If there are no results it should be a blank panel

image

  • Don't worry about the landing page in the mock -- let's just stick with the search for now.

  • We'll want to pull in all plugins, not just official plugins

  • Mobile support

Random design stuff:

  • The selected plugin should be highlighted
  • The left panel should have the light purple background
  • Border or box shadow on top, left and bottom.
  • whole package result box should be a click target, not just the name
  • Margin between the title and the body is too small

image


import typography from "../utils/typography"

function Search(){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const Search = () =>

style={{
color: `white`,
border: `0`,
boxShadow: `0 0 0 0`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

boxShadow: none should work

</Link>
<div css={{
fontFamily: typography.options.bodyFontFamily.join(`,`),
fontSize: `${13 / 16 * 100}%`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

scale(n)

<div css={{
fontFamily: typography.options.bodyFontFamily.join(`,`),
fontSize: `${13 / 16 * 100}%`,
lineHeight: `1.1`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rhythm(n)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(theoretically a whole # or simple fraction like 3/4)

fontFamily: typography.options.bodyFontFamily.join(`,`),
fontSize: `${13 / 16 * 100}%`,
lineHeight: `1.1`,
paddingTop: `7px`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rhythm(n)

(theoretically a whole # or simple fraction like 3/4)

www/src/html.js Outdated
<link
rel="stylesheet"
href="https://unpkg.com/react-instantsearch-theme-algolia@4.0.0/style.min.css"
/>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need / use this?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do use their styling for the search box, but mostly included it so I could have something that looked decent fairly quickly. Can definitely take this out and do our own.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it. Didn't realize we were using it. Let's talk about styling in one fell swoop, but for now just add rel="preload"

borderBottom: `1px solid grey`,
}}>
<div css={{
padding: `10px`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use rhythm

)
}

function Result({ hit }){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const Result = ({ hit }) => {

@KyleAMathews
Copy link
Contributor

plugin links should be /plugins/name not /packages/name

Is there a compelling reason to change the existing URL structure?

@KyleAMathews
Copy link
Contributor

On pulling in all plugins — we should include in the search any package on NPM with the gatsby-plugin tag. We'll probably have to create a blacklist at some point if the tag gets spammed.

@calcsam
Copy link
Contributor

calcsam commented Jan 10, 2018

Is there a compelling reason to change the existing URL structure?

@KyleAMathews could be a bit weird if the landing page is /plugins but links go to /packages/x

@calcsam
Copy link
Contributor

calcsam commented Jan 10, 2018

another thought on routing -- since we're not searching strictly plugins, we're searching all packages, let's have this live at /packages (we could make /plugins redirect to /packages too if we want).

@calcsam
Copy link
Contributor

calcsam commented Jan 10, 2018

re docsearch & algolia -- two things:

(1) The medium-term plan is to, at build time, have a source plugin that uses Algolia npm-search (https://blog.algolia.com/yarn-search-javascript-packages/) to pull all package details including the readme into Gatsby data, build a page for each package.

(2) In the short run, this is a great start and probably no need to fiddle further with algolia stuffbefore merging

@KyleAMathews KyleAMathews changed the title Plugins Plugin search page Jan 10, 2018
@jastack
Copy link
Author

jastack commented Jan 10, 2018

Thanks guys! I'm going to work on some fixes based on your feedback then get back to you

@shannonbux
Copy link
Contributor

shannonbux commented Jan 10, 2018

@jastack This is exciting! I helped with the first prototypes for this and interviewed a bunch of Gatsby users to figure out what features are essential, so it's cool to see it progressing!! A couple notes:

  • Another thing we can use Algiola for (from my understanding) is pulling more Github data beyond just the READme file. We've gotten feedback that popularity (maybe stars?) and number of downloads could be useful data points. I'm hoping those could appear on the left hand side somehow, or if nothing else, in some sort of header above the READme file on the right. I can provide screenshots of these ideas. This might not be essential in first version since we don't have lots of duplicate plugins yet.
  • Also, we will need to use some sort of truncation for the plugin names and descriptions on the left hand side, because some names are really long haha.
  • @KyleAMathews and @calcsam This mock shows the title "Gatsby Library" in the search bar. What are we going to call this? I like that because it's shorter than Gatsby Plugin Search Tool...

@KyleAMathews
Copy link
Contributor

Another thing we can use Algiola for (from my understanding) is pulling more Github data beyond just the READme file. We've gotten feedback that popularity (maybe stars?) and number of downloads could be useful data points.

💯 to this

This mock shows the title "Gatsby Library" in the search bar

yeah, let's use Gatsby Library

@rdela
Copy link
Contributor

rdela commented Jan 11, 2018

Also please do not forget "search by Algolia" @jastack #3003 (comment)

Probably want to link "Algolia" to either
https://github.com/algolia/npm-search
or
https://www.algolia.com/

like:
Search by Algolia

The main website
https://www.algolia.com/

…is probably safest bet since I think we plan to include both doc search and npm-search. @KyleAMathews? @calcsam? thoughts? Should we loop Haroen in to help decide?

@KyleAMathews KyleAMathews changed the title Plugin search page Gatsby library search page Jan 11, 2018
@jastack
Copy link
Author

jastack commented Jan 12, 2018

Alright, finally pushed another draft! Check it out at "/packages" now.

@calcsam and @KyleAMathews - the biggest change is that now the search pulls from Algolia's npm-search, instead of from only source packages, which means any package with the "gatsby-plugin" tag shows up. I realize this means more work because as Sam mentioned, we will need to have a source plugin in that pulls in all the other package details to build a page for each. So if it makes sense to stick with source package search in the short-term we can do that.

@shannonbux let me know what you think about the styling. I included more info on each search result, like tags, last updated, and downloads and can add icons too.

@KyleAMathews
Copy link
Contributor

Let's just do the source plugin for npm-search so we can build out pages for all the packages.

Two tweaks to the search

Really starting to come together! Excited to see this happen!

textAlign: `center`,
}}

>Welcome to the Gatsby Plugin and Starter Library!</h1>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's change "plugin and starter" to just "package" since we're not going to search for starters here

justifyContent: `center`,
}}>
<SearchBox
translations={{placeholder: 'Search Gatsby Library by keyword'}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be Search Gatsby Library

@@ -0,0 +1 @@

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prob want to remove this file :)


const updateAfter = 700;
const searchStateToQueryString = searchState => ({
q: searchState.query,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no using one-letter variables outside of math class :) query and page are more understandable

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ignore if not using file

...(searchState.refinementList.keywords && {
keywords: searchState.refinementList.keywords,
}),
}),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you break this out into a couple of lines with descriptive variable names? it would be more understandable that way.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ignore if not using file

page: p || 1,
refinementList: {
...(keywords && { keywords }),
...(owner && { 'owner.name': owner }),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the reason for 'owner.name' instead of 'owner'?

is there a reason why this function isn't just:

const parsedQuery = qs.parse(queryString)
return {
   ...parsedQuery,
    page: parsedQuery.page || 1
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ignore if not using file

this.state = {
searchState: queryStringToSearchState(location.search.slice(1)),
};
window.addEventListener('popstate', ({ state: searchState }) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

event listeners should be in componentDidMount and cleaned up in componentWillUnmount

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ignore if not using file

onSearchStateChange = searchState => {
clearTimeout(this.debouncedSetState);
this.debouncedSetState = setTimeout(() => {
this.props.history.replace(`/packages?=${searchState.query}`)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

keep this for now, but...

...we shouldn't be manually manipulating props // the global , we should be calling navigateTo which is how gatsby handles navigation.....

....however, this may not work at the moment with search queries due to a separate bug: #2074. (We need to check for differences in location.pathname and location.search) So hold off on changing this for a bit, I'll let you know when I address that and then you can use navigateTo.

www/src/html.js Outdated
<link
rel="stylesheet"
href="https://unpkg.com/react-instantsearch-theme-algolia@4.0.0/style.min.css"
/>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it. Didn't realize we were using it. Let's talk about styling in one fell swoop, but for now just add rel="preload"

};
};

const originalPathName = location.pathname;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is going to be evaluated outside of the component lifecycle, which is bad. try evaluating it in a constructor

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ignore if not using file

@@ -0,0 +1,91 @@
import React, { Component } from 'react';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

File should be capitalized 'WithUrlSync' since it's a component

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.......wait, are we using this file at all? I don't see it referenced anywhere

}

onSearchStateChange = searchState => {
clearTimeout(this.debouncedSetState);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see above stuff re debouncing

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ignore if not using file

@gillkyle
Copy link
Contributor

gillkyle commented Feb 7, 2018

I made some progress but I'm trying to resolve a couple of these testing/build errors on the most current commit (cb316ca) to the branch without much luck, the tests that I see failing (4 in total) running yarn test give errors akin to this:

FAIL  packages/gatsby-transformer-sharp/src/__tests__/gatsby-node.js
  ● Test suite failed to run

    dlopen(/Users/kyle/Kyle/GitHub/plugin-gatsby-library/node_modules/sharp/build/Release/sharp.node, 1): Library not loaded: @rpath/libvips-cpp.42.dylib
      Referenced from: /Users/kyle/Kyle/GitHub/plugin-gatsby-library/node_modules/sharp/build/Release/sharp.node
      Reason: image not found

This looked similar to errors on #1754, and seem like they could be issues introduced by changes in the yarn.lock with updated dependencies. Does that seem possible?

And the snapshots with errors (4) are little changes like this. I'm not familiar with when you'd need to update a jest snapshot but the changes I see to the code for the plugin library don't look like they'd be causing an issue like this, and it could be the result of something that was merged oddly.

- Snapshot
+ Received
    
-  <pre class="custom-js"><code><span class="token comment" spellcheck="true">// Fake</span>
+  <pre class="custom-js"><code><span class="token comment">// Fake</span>

I think I'll reset back to find a commit where these tests weren't failing to identify what really is causing them. Any other ideas @KyleAMathews? Maybe it's even simpler than I think.

@calcsam
Copy link
Contributor

calcsam commented Feb 7, 2018

@gillkyle the changes being caused by an odd merge could definitely be an issue. You may want to try a cherry-picking or interactive rebase strategy to isolate and squash the commits that are part of this branch (the ones by jastack) and rebase on top of a fresh master.

@KyleAMathews
Copy link
Contributor

@gillkyle tests can sometimes fail locally due to no fault of your own — Gatsby has a ton of packages and if a few of them fail to install correctly (seems like a near guarantee...) then some of tests will fail. Pay more attention to TravisCI failing then what's happening locally.

None of those tests are affected by this PR so there's probably nothing that needs fixed.

Resolve the conflicting files and then see if TravisCI passes tests.

@KyleAMathews
Copy link
Contributor

@gillkyle turned out that a minor release of one our dependencies broke some of the snapshots 🤷‍♂️ Fixed upstream with #3902. Merge in the lastest master and you'll be good.

@gillkyle
Copy link
Contributor

gillkyle commented Feb 7, 2018

I was just looking into it, I'll merge it in and try building it on my branch with Travis CI, thanks for the help!

@fk
Copy link
Contributor

fk commented Feb 22, 2018

Just chatted about this with @shannonbux a little and remembered that I had drawn a bunch of icons for the mobile navigation in case "Plugins" became its own section:

plugins-icons

The two above the "magic wand" icon a) pick up the quite common "puzzle pieces" metaphor for "Plugins", b) show data flowing through those plugins (and/or "Transformers"), all within the Gatsby monogram/"G" shape. Not super clear, so probably not a way to go.

Anyways…questions:

  • I see we decided to go with "Gatsby Library" (which I like a lot)—I suppose non of these icons really fit here anymore?
  • Will this section be called "Library" in the main navigation?
  • Where do we place it in the main navigation—in between "Tutorial" and "Community"?
  • As said I like "Library" a lot, but I also find it a little misleading as I also could imagine the "Gatsby Guides" to be living there. "Plugins" doesn't have this issue IMO. Does that make any sense or am I overthinking?

Adding another item to the main navigation is another nudge to re-think the latter in terms of the home page layout… ;-) For now I think the additional "Library" should fit in with that landing page from ~900px browser width.

Since I'd hate to lose the other navigation items when going below that width, maybe https://css-tricks.com/the-priority-navigation-pattern/ is one way to proceed long-term? Or we could revamp the homepage layout… :-(

@fk
Copy link
Contributor

fk commented Feb 22, 2018

Will starters be indexed/part of the library at some point too?

@shannonbux
Copy link
Contributor

shannonbux commented Feb 22, 2018 via email

@KyleAMathews
Copy link
Contributor

Will starters be indexed/part of the library at some point too?

yeah, like Shannon said. The Library is for plugins and Gatsby-specific React components.

@KyleAMathews
Copy link
Contributor

Though let's close this PR since work is continuing over on @gillkyle's PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
UX Project
  
Done
Development

Successfully merging this pull request may close these issues.

None yet