Giter Club home page Giter Club logo

polymer-element-catalog's Introduction

Polymer Element Catalog

⚠️ This catalog is no longer maintained. There is a non-Polymer specific catalog available on https://www.webcomponents.org/ A self-hosting catalog is available at https://github.com/PolymerLabs/indie-catalog ⚠️

Getting Started

To work on the Polymer Elements Catalog, clone the repository.

To install dependencies:

npm run deps

To start a local development server:

npm run serve

To start a local development server with fixtures turned on:

FIXTURES=true npm run serve

To prepare the repo for publication:

npm run build

Note: Make sure that you're running chrome 42 or later!

Fixtures

While parts of the system are still in flux, it will be necessary to have stubbed data and other bits to be able to work against. Anything in the fixtures directory will be available when running a development server. By the time the catalog ships, the fixtures directory should be empty.

Managing Catalog Data

Data for the catalog is compiled by intelligently composing together information from multiple sources:

  1. The catalog.json file in this repository
  2. The bower.json for each element package and individual element
  3. Metadata parsed directly elements' source using hydrolysis
  4. Other files in package and element repositories, such as guide markdown files

Each of these inputs is combined and compiled into a static format easily loaded by the catalog application. Outputs of the catalog compilation process include:

  1. A /data/catalog.json file heavily annotated with parsed metadata
  2. Pre-parsed element documentation in /data/docs
  3. The compiled HTML output of guide markdown files in /data/guides

How catalog.json is Created

The final catalog.json file can be thought of as the repo's initial file decorated substantially with metadata. For instance, a package in the initial file:

{
  "packages": [
    {"title":"Iron Elements", "name":"iron-elements"}
  ]
}

Gets decorated with metadata parsed from its' bower.json:

{
  "packages": [
    {
      "title":"Iron Elements",
      "name":"iron-elements",
      "description":"Polymer core elements",
      "version":"1.0.0",
      "tags":["utility","scaffolding","user-input"]
    }
  ]
}

This decoration occurs in steps and can be considered a series of merges.

Packages

Each set of elements (henceforth "package") is responsible for maintaining its own documentation according to the conventions established elsewhere in this document. Each package is represented in catalog.json as an entry in an array. This array corresponds to the order in which packages are presented in nav contexts in the element catalog. Each package has the following associated data:

  • name: the corresponding package name from bower.json
  • title: the human-friendly name of the package for nav display

Each named package should be declared as a dependency in the bower.json for this repository. Additionally, each package's version number should be explicit, as the version declared in bower.json is used as display text in the catalog.

{
  // correct example
  "iron-elements":  "PolymerElements/iron-elements#1.0.0"
  // incorrect example
  "paper-elements": "PolymerElements/paper-elements#^1.0"
}

By maintaining strict versioning in the catalog, updating a package's data becomes as easy as a pull request to bower.json.

Package Metadata

As much as possible, the element catalog uses existing conventions from systems such as Bower as a repository for metadata.

bower.json

The bower.json for a package should contain a dependencies entry for each of its child elements. A declared dependency will be considered a child element of the package if and only if its name is identical to the package name before the first dash. As an example, if the package is iron-elements, iron-ajax would be considered a child but polymer would not.

The element catalog uses the following information from bower.json:

  • name: The package name should correspond to a packages entry in the catalog.json file in this repository for it to be displayed.
  • description: The package description should be phrased such that it can be used as descriptive summary text in the catalog when the package is presented along-side other packages. It should be less than 200 characters in length but adequately descriptive of the primary use cases for the package.
  • keywords: Excluding web-components and polymer, these keywords will be used as tags in the final catalog data.

Elements

Elements behave much like packages: they are responsible for maintaining their own documentation in bower.json. In addition, the source .html files for elements should be documented in accordance with the Polymer Elements style guide.

bower.json

The catalog uses the following information from an element's bower.json:

  • name: The element name. Except in rare cases, this should match a .html file of the same name that contains the element or imports all default elements for element repos with multiple elements.
  • description: A less-than-200 character description of what the element does and how it should be used.
  • keywords: Except for web-components and polymer, these keywords will be used as tags in the final catalog data.
  • main: This field should represent every .html file that a user might directly import. For instance, in iron-icons each icon set might be imported separately, so each set should be included in main. For many (most) elements this can just be a string with the .html filename matching the name field.

Guides

Guides are in-depth articles that allow for article-style documentation in addition to the API documentation for each element parsed using hydrolysis.

Guides are simply Markdown files with YAML front-matter and can be included in the repository for the catalog, a package, or an individual element. To avoid namespace collisions, guides for packages and individual elements are identified with repo-name/guide-name, while guides in this repository are identified simply with guide-name.

Each guide will be listed and accessible in the Guides section of the catalog, and will additionally be associated with each element and package it references.

Example Markdown File (e.g. bower_components/gold-elements/guides/ecommerce.md)

---
title: How to Build an E-Commerce Site with Gold Elements
summary: "Learn how to add drop-in E-commerce components to quickly build a web presence for your business."
tags: ['ecommerce','beginner']
elements: ['gold-checkout','paper-input']
updated: 2015-04-10
---

Actual article content starts here.

## Example Section

Etc. etc.

Example compiled catalog.json

{
  // guides with associated packages should also be referenced in the package metadata
  "packages": [
    {"name":"gold-elements","guides":["gold-elements/ecommerce"]}
  ],
  "guides": [
    {
      "name":"gold-elements/ecommerce",
      "title":"How to Build an E-Commerce Site with Gold Elements",
      "tags":["ecommerce","beginner"],
      "elements":["gold-checkout","paper-input"],
      "package":"gold-elements"
    }
  ],
  "elements": [
     {"name":"paper-input","guides":["gold-elements/ecommerce"]}
  ]
}

Assets in Guides

If a guide needs images or other assets, those should be stored in /guides/assets in the repository and always referenced with relative URLs (e.g. assets/filename.jpg). By maintaining this convention the catalog compilation process will automatically ensure that images and other assets are properly accessible to the guide.

polymer-element-catalog's People

Contributors

addyosmani avatar beaufortfrancois avatar beckula avatar blasten avatar ctojoe avatar dfreedm avatar eakuefner avatar ebidel avatar fastdivision avatar frankiefu avatar fredj avatar gpx avatar jeffposnick avatar kaycebasques avatar kevinpschaaf avatar lostinbrittany avatar mattmattv avatar maxrabin avatar mbleigh avatar nevir avatar notwaldorf avatar rictic avatar samccone avatar scarygami avatar scottcorgan avatar shauvik avatar tejasedate avatar timvdlippe avatar tjsavage avatar tony19 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

polymer-element-catalog's Issues

Gulp Catalog Data Compilation

To make everything easy to load and navigate, we will write a custom Gulp task to generate a catalog JSON database starting with the catalog.json in the project root and decorating and adding to it from there. Here's a rough picture of how it should work:

  • Read catalog.json
  • For each entry in packages, take the name and look for a corresponding entry in the dependencies object in bower.json
  • Parse the version number specified from the dependency and store it as the "version" key in the packages list.
  • Load and parse the bower.json for the package (e.g. for core-elements look for bower_components/core-elements/bower.json
  • Add "description" and "tags" from bower.json to the catalog metadata
  • Find any dependencies of the package with the same dash prefix (i.e. core for core-elements).
  • For each of these, append it to an "elements" array in the package's catalog metadata
  • For each of these, load its bower.json
  • Create a key in an elements object in the catalog metadata corresponding to the element name. It should include the name, description, tags, and parent package for the element
  • For each of the element's tags, create or append a corresponding key in a tags object on the catalog metadata that is an array of elements that match the tag sorted alphabetically.
  • Once you've parsed each package and built the metadata, pipe the output to .tmp/catalog.json and dist/catalog.json
  • elements is an array sorted by name

Sample Source

{
  "packages": [
    {"name":"core-elements", "title":"Core Elements"}
  ]
}

Sample Result

{
  "packages": [
    {
      "name":"core-elements",
      "version":"1.0.0",
      "title":"Core Elements",
      "description":"The description from the bower.json for the package.",
      "elements":["core-example"]
    }
  ],
  "elements": {
    "core-example": {
      "name":"core-example",
      "package":"core-elements",
      "description":"The description from bower_elements/core-example/bower.json",
      "tags":["tags","from","bower_elements/core-example/bower.json"]
    }
  },
  "tags": {
    "tags": ["core-example"],
    "from": ["core-example"],
    "bower_elements/core-example/bower.json": ["core-example"]
  }
}

Element pages should have an Installation section

As an alternative to adding to cart and then downloading a bower.json, I'd like to just see the dependency line that I can copy and paste into my existing bower.json. A bower install command line would be nice too.

# of elements/collection counts

It would be nice to at a lance (either on the landing page, or inside a collection view) the number of elements in a collection.

"Catalog Instant Search"

Discussion on Thursday led to conclusion that the homepage search should behave like Google Instant Search: you start typing and the search bar jumps to the sidebar and the filter view instantly (instead of displaying tiled elements in the home page view).

This needs to feel completely instantaneous and smooth, interesting UI challenge.

View what product lines exist on the home page

  • Basic display of product lines based on catalog.json contents
  • Fully styled display
  • Animation on page load
  • Animation on clicking through a line (maybe have it slide left while rest fade down and away since the details show up in the left sidebar?)

Add Related guides links

Could we add an (optional) section to the left sidebar for packages & elements showing the related guides. I'd like to have this below the Description but before the Tags.

Related guides

Using iron-icons

For extra credit, pluralize "Related guides" correctly :D

There should be a place to show element documentation guides. Guides can be generic, or tied to a product line. Guides will be markdown-based.

Let's keep it simple. Guides will be stored as .md files in a guides folder in the main project. They will have YAML frontmatter (like Jekyll) that contains metadata, starting with title, summary, tags, updated (date in form YYYY-MM-DD). Let's make a Gulp task that scans the guides directory and builds metadata to insert intocatalog.json`.

Example Markdown File (e.g. bower_components/gold-elements/guides/ecommerce.md)

---
title: How to Build an E-Commerce Site with Gold Elements
summary: "Learn how to add drop-in E-commerce components to quickly build a web presence for your business."
tags: ['ecommerce','beginner']
elements: ['gold-checkout','paper-input']
updated: 2015-04-10

---

Actual article content starts here.

## Example Section

Etc. etc.

Example catalog.json

{
  // guides with associated packages should also be referenced in the package metadata
  "packages": [
    {"name":"gold-elements","guides":["gold-elements/ecommerce"]}
  ],
  "guides": [
    {
      "name":"gold-elements/ecommerce",
      "title":"How to Build an E-Commerce Site with Gold Elements",
      "tags":["ecommerce","beginner"],
      "elements":["gold-checkout","paper-input"],
      "package":"gold-elements"
    }
  ],
  "elements": [
     {"name":"paper-input","guides":["gold-elements/ecommerce"]}
  ]
}

HTML Generation

In addition to parsing the metadata, the Markdown should be rendered into HTML and output into .tmp and dist at guides/<guide-name>.html

Guides in Other Repos

Guides can be added to package or individual element repositories as well. When scanning a package or element, the guides folder in the bower directory should be scanned as well. If there are any Markdown files, they should be parsed and aggregated but have the package or element key set in their metadata (depending on if it's a package or element repo you're exploring).

In addition, guides in other repos should have generated HTML placed in subdirectories named after them to avoid name conflicts. So a guide namedmy-guide.md in iron-elements should have generated HTML in app/iron-elements/my-guide.html.

Todo

  • add guides to guide key in catalog.json
  • add guides array to package listing in catalog.json
  • convert markdown to html in .tmp and dist folders

Travis CI Deploy to Divshot

Let's hook up a Travis CI deploy that runs Gulp and deploys to Divshot. For now let's have master deploy to development and put a password on it.

  • travis file
  • create app on Divshot
  • protect environment

Element selector is not obvious

It's not obvious "google-sheets" is a dropdown that gives me more related elements. I'm worried many people will not ever see the extra elements.

screen shot 2015-05-20 at 1 35 30 pm

Analytics all the things

We need analytics on everything. Specifically, tracking page views on doc pages, element guides, and demo views

The catalog should be able to be given an arbitrary github element repo that is structured the same way, and display its documentation and demo.

Here we will do our best to approximate all of the same metadata we have about official packages and elements, but arbitrarily based off of a GitHub repository. The URL for these will be /community/:user/:repo/:version (where version is an optional GitHub ref that defaults to master) and there should be no required up-front processing to be able to display: using the GitHub API on the fly should be sufficient.

  1. Grab the raw bower.json for the repo using the GitHub API. This tells us the name, description, tags, etc.
  2. Use the main declaration to pick up which .html files should be parsed for docs.
  3. Pull the raw contents of the indicated HTML files, parse them for docs, and display.

Unanswered Questions

  1. How do we get around potential GitHub client-side rate limiting problems?
  2. Should we require explicit declarations in bower.json for things that we can otherwise find by directory scanning to cut down on GitHub API requests?
  3. Do we cache or otherwise index data that we've collected (maybe in Firebase)?
  4. How do we handle demos and dependencies? Simplest possible is <iframe> to URL specified in element docs, but is there a better way?

Pre-process element docs with hydrolysis

During the catalog build process, each element should be analyzed with hydrolysis and the result stored in /data/docs/<element-name>.json. Note that you should use the clean option to make sure the output is serializable.

See this source for how to instantiate and run the analyzer.

The reason to do this is that then we have a static version of the docs and the analysis doesn't have to be run client-side each time you load.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.