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

Set default thumbnail for examples page for development #8025

Merged
merged 3 commits into from
Mar 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ In the `.html` file, write the HTML and JavaScript constituting the example.
* Do **not** use custom styles from your personal account. Use only the default `mapbox` account styles.
* When embedding literal JSON (GeoJSON or Mapbox style snippets) into script code, double-quote property names and string values. Elsewhere, use single-quoted strings.

Every example **must** have an accompanying image:
Every example **must** have an accompanying image. To get an image, run the site locally and take a screenshot of the rendered map in the example:

1. Save the image in `docs/img/src/`. Image requirements:
- The file name of the image **must** match the example's file name
Expand Down
Binary file added docs/img/src/placeholder.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 4 additions & 2 deletions docs/pages/examples.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import PageShell from '../components/page_shell';
import { tags } from '../data/tags.js';
import examples from '@mapbox/batfish/data/examples'; // eslint-disable-line import/no-unresolved
import AppropriateImage from '../components/appropriate-image';

import imageConfig from '../img/dist/image.config.json'; // eslint-disable-line

const meta = {
title: 'Mapbox GL JS Examples',
Expand All @@ -30,6 +30,8 @@ class ExamplesLandingPage extends React.PureComponent {
.filter(example => example.tags.indexOf(topic) > -1)
.map((example, index) => {
const filename = example.pathname.split('/')[3];
// set default if thumbnail doesn't exist yet
const imageId = imageConfig[filename] ? filename : 'placeholder';
return (
<Card
key={index}
Expand All @@ -38,7 +40,7 @@ class ExamplesLandingPage extends React.PureComponent {
path={example.path}
thumbnail={
<AppropriateImage
imageId={filename}
imageId={imageId}
style={{ borderRadius: '4px' }}
background={true}
/>
Expand Down