-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'publisher-production' into sync-publisher-production
* publisher-production: (41 commits) bump publisher after timeout (#8058) cosmetic update to draggable Marker/point examples to prevent coordinates overlapping Mapbox logo (#8057) update mapbox style and tileset version numbers to most recent (#8056) update docs page shell (#8039) [email protected] Add create-image script to generate example thumbnails (#8029) Add HTML clusters + aggregated properties example (#8019) add 3D model with three.js example (#7977) update mapbox-gl-geocoder to @3.1.4 in examples (#7978) V0.53.1 (#7961) rename example for accepting coordinates in the geocoder (#7859) [docs] use appropriate-images for examples to increase page speed (#7900) [docs] dr-ui 0.6.0 (#7909) version bump gl-geocoder to v3.1.2 (#7924) Fix docs for Camera methods Docs page shell update 02-14-19 (#7907) fixes regression with css on examples pages (#7891) updates sentry project for docs subdomain (#7890) v0.53.0 (#7884) [docs] update dr-ui 0.5.0 (#7880) ...
- Loading branch information
Showing
285 changed files
with
9,460 additions
and
5,099 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/usr/bin/env node | ||
'use strict'; | ||
|
||
const path = require('path'); // eslint-disable-line import/no-commonjs | ||
const appropriateImages = require('@mapbox/appropriate-images'); // eslint-disable-line import/no-commonjs | ||
const imageConfig = require('../img/dist/image.config.json'); // eslint-disable-line import/no-commonjs | ||
|
||
appropriateImages.createCli(imageConfig, { | ||
inputDirectory: path.join(__dirname, '../img/src'), | ||
outputDirectory: path.join(__dirname, '../img/dist') | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/usr/bin/env node | ||
// builds image.config.json | ||
// this configuration file is required to generate the appropriate images sizes with docs/bin/appropriate-images.js | ||
// it is also required in react component that loads the image in components/appropriate-image.js | ||
const imagePath = './docs/img/src/'; | ||
|
||
const imageConfig = require('fs').readdirSync(imagePath).reduce((obj, image) => { | ||
const ext = require('path').extname(`${imagePath}${image}`); | ||
// only process png | ||
if (ext === '.png') { | ||
const key = image.replace(ext, ''); | ||
// set sizes for all images | ||
const sizes = [{ width: 800 }, { width: 500 }]; | ||
// set additional sizes for specific images | ||
if (key === 'simple-map') sizes.push({ width: 1200 }); | ||
obj[key] = { | ||
basename: image, | ||
sizes | ||
}; | ||
} | ||
return obj; | ||
}, {}); | ||
|
||
require('fs').writeFileSync('./docs/img/dist/image.config.json', JSON.stringify(imageConfig)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
'use strict'; | ||
|
||
const puppeteer = require('puppeteer'); // eslint-disable-line | ||
const path = require('path'); // eslint-disable-line | ||
const pack = require('../../package.json'); // eslint-disable-line | ||
|
||
const fileName = process.argv[2]; | ||
const token = process.argv[3] || process.env.MAPBOX_ACCESS_TOKEN || process.env.MapboxAccessToken; | ||
|
||
if (!token || !fileName) { | ||
throw new Error('\n Usage: npm run create-image <file-name> <mapbox-access-token>\nExample: npm run create-image 3d-buildings pk000011110000111100001111\n\n'); | ||
} | ||
|
||
// strip file extension from file name | ||
const fileNameFormatted = fileName.replace('.html', '').replace('.js', ''); | ||
// get the example contents/snippet | ||
const snippet = require('fs').readFileSync(path.resolve(__dirname, '..', 'pages', 'example', `${fileNameFormatted}.html`), 'utf-8'); | ||
// create an HTML page to display the example snippet | ||
const html = `<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset='utf-8' /> | ||
<script src='https://api.tiles.mapbox.com/mapbox-gl-js/v${pack.version}/mapbox-gl.js'></script> | ||
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v${pack.version}/mapbox-gl.css' rel='stylesheet' /> | ||
<style> | ||
body { margin:0; padding:0; } | ||
#map { position: absolute; top:0; bottom:0; width: 600px; max-height: 300px; } | ||
</style> | ||
</head> | ||
<body> | ||
<script> | ||
mapboxgl.accessToken = '${token}'; | ||
</script> | ||
${snippet} | ||
</body> | ||
</html>`; | ||
|
||
// initilize puppeteer | ||
(async() => { | ||
const browser = await puppeteer.launch(); | ||
const page = await browser.newPage(); | ||
// set html for page and then wait until mapbox-gl-js loads | ||
await page.setContent(html, {waitUntil: 'networkidle2'}); | ||
// set viewport and double deviceScaleFactor to get a closer shot of the map | ||
await page.setViewport({ | ||
width: 600, | ||
height: 600, | ||
deviceScaleFactor: 2 | ||
}); | ||
// create screenshot | ||
await page.screenshot({ | ||
path: `./docs/img/src/${fileNameFormatted}.png`, | ||
type: 'png', | ||
clip: { | ||
x: 0, | ||
y: 0, | ||
width: 600, | ||
height: 250 | ||
} | ||
}).then(() => console.log(`Created ./docs/img/src/${fileNameFormatted}.png`)) | ||
.catch((err) => { console.log(err); }); | ||
await browser.close(); | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import React from 'react'; | ||
import GithubSlugger from 'github-slugger'; | ||
import createFormatters from 'documentation/src/output/util/formatters'; | ||
import LinkerStack from 'documentation/src/output/util/linker_stack'; | ||
import docs from '../components/api.json'; // eslint-disable-line import/no-unresolved | ||
import ApiItem from '../components/api-item'; | ||
import Icon from '@mapbox/mr-ui/icon'; | ||
|
||
const linkerStack = new LinkerStack({}) | ||
.namespaceResolver(docs, (namespace) => { | ||
const slugger = new GithubSlugger(); | ||
return `#${slugger.slug(namespace)}`; | ||
}); | ||
|
||
const formatters = createFormatters(linkerStack.link); | ||
|
||
class ApiItemMember extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
this.state = {disclosed: false}; | ||
this.hashChange = this.hashChange.bind(this); | ||
} | ||
|
||
href = m => `#${m.namespace.toLowerCase()}` | ||
|
||
render() { | ||
const member = this.props; | ||
return ( | ||
<div className='border-b border--gray-light'> | ||
<div className='pt60' style={{ marginTop: '-60px' }} id={member.namespace.toLowerCase()} /> | ||
<div> | ||
<button | ||
className='cursor-pointer toggle-sibling color-blue-on-hover w-full py18' | ||
onClick={(e) => { | ||
this.setState({disclosed: !this.state.disclosed}); | ||
if (history.pushState) { | ||
history.pushState(null, null, this.href(member)); | ||
} else { | ||
location.hash = this.href(member); | ||
} | ||
|
||
e.preventDefault(); | ||
}} | ||
> | ||
<span className='txt-code truncate bg-white'>{member.name}</span> | ||
{member.kind === 'function' && | ||
<span className='color-gray txt-code mr12' dangerouslySetInnerHTML={{__html: formatters.parameters(member, true)}}/>} | ||
<div className='fr'><Icon size={30} name={`${this.state.disclosed ? 'caret-down' : 'caret-right'}`} inline={true} /></div> | ||
</button> | ||
</div> | ||
|
||
{this.state.disclosed && | ||
<div className="toggle-target bg-gray-faint round py18 px18 mb12"> | ||
<ApiItem nested={true} {...member}/> | ||
</div>} | ||
</div> | ||
); | ||
} | ||
|
||
hashChange() { | ||
if (window.location.hash === this.href(this.props)) { | ||
this.setState({disclosed: true }); | ||
} | ||
} | ||
|
||
componentDidMount() { | ||
window.addEventListener("hashchange", this.hashChange); | ||
this.hashChange(); | ||
} | ||
|
||
componentWillUnmount() { | ||
window.removeEventListener("hashchange", this.hashChange); | ||
} | ||
} | ||
|
||
export default ApiItemMember; |
Oops, something went wrong.