/** @jsx jsx */ import { Global, css, jsx } from '@emotion/core'; import { Fragment } from 'react'; import PropTypes from 'prop-types'; import { fontSans, fontMono } from '../utils/style.js'; import { PackageInfoProvider } from './PackageInfo.js'; import DirectoryViewer from './DirectoryViewer.js'; import FileViewer from './FileViewer.js'; import { TwitterIcon, GitHubIcon } from './Icons.js'; import SelectDownArrow from './images/SelectDownArrow.png'; const globalStyles = css` html { box-sizing: border-box; } *, *:before, *:after { box-sizing: inherit; } html, body, #root { height: 100%; margin: 0; } body { ${fontSans} font-size: 16px; line-height: 1.5; background: white; color: black; } code { ${fontMono} } th, td { padding: 0; } select { font-size: inherit; } #root { display: flex; flex-direction: column; } `; // Adapted from https://github.com/highlightjs/highlight.js/blob/master/src/styles/atom-one-light.css const lightCodeStyles = css` .code-listing { background: #fbfdff; color: #383a42; } .code-comment, .code-quote { color: #a0a1a7; font-style: italic; } .code-doctag, .code-keyword, .code-link, .code-formula { color: #a626a4; } .code-section, .code-name, .code-selector-tag, .code-deletion, .code-subst { color: #e45649; } .code-literal { color: #0184bb; } .code-string, .code-regexp, .code-addition, .code-attribute, .code-meta-string { color: #50a14f; } .code-built_in, .code-class .code-title { color: #c18401; } .code-attr, .code-variable, .code-template-variable, .code-type, .code-selector-class, .code-selector-attr, .code-selector-pseudo, .code-number { color: #986801; } .code-symbol, .code-bullet, .code-meta, .code-selector-id, .code-title { color: #4078f2; } .code-emphasis { font-style: italic; } .code-strong { font-weight: bold; } `; const linkStyle = { color: '#0076ff', textDecoration: 'none', ':hover': { textDecoration: 'underline' } }; export default function App({ packageName, packageVersion, availableVersions = [], filename, target }) { function handleChange(event) { window.location.href = window.location.href.replace( '@' + packageVersion, '@' + event.target.value ); } const breadcrumbs = []; if (filename === '/') { breadcrumbs.push(packageName); } else { let url = `/browse/${packageName}@${packageVersion}`; breadcrumbs.push( {packageName} ); const segments = filename .replace(/^\/+/, '') .replace(/\/+$/, '') .split('/'); const lastSegment = segments.pop(); segments.forEach(segment => { url += `/${segment}`; breadcrumbs.push( {segment} ); }); breadcrumbs.push(lastSegment); } // TODO: Provide a user pref to go full width? const maxContentWidth = 940; return (

UNPKG

{/* */}

{' '}
{target.type === 'directory' ? ( ) : target.type === 'file' ? ( ) : null}
); } if (process.env.NODE_ENV !== 'production') { const targetType = PropTypes.shape({ path: PropTypes.string.isRequired, type: PropTypes.oneOf(['directory', 'file']).isRequired, details: PropTypes.object.isRequired }); App.propTypes = { packageName: PropTypes.string.isRequired, packageVersion: PropTypes.string.isRequired, availableVersions: PropTypes.arrayOf(PropTypes.string), filename: PropTypes.string.isRequired, target: targetType.isRequired }; }