/** @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 FolderViewer from './FolderViewer.js'; import FileViewer from './FileViewer.js'; import { TwitterIcon, GitHubIcon } from './Icons.js'; import SelectDownArrow from './images/SelectDownArrow.png'; const buildId = process.env.BUILD_ID; 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; overflow-wrap: break-word; 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; } `; function Link({ css, ...rest }) { return ( // eslint-disable-next-line jsx-a11y/anchor-has-content ); } function AppHeader() { return (

UNPKG

{/* */}
); } function AppNavigation({ packageName, packageVersion, availableVersions, filename }) { function handleVersionChange(nextVersion) { window.location.href = window.location.href.replace( '@' + packageVersion, '@' + nextVersion ); } let breadcrumbs = []; if (filename === '/') { breadcrumbs.push(packageName); } else { let url = `/browse/${packageName}@${packageVersion}`; breadcrumbs.push({packageName}); let segments = filename .replace(/^\/+/, '') .replace(/\/+$/, '') .split('/'); let lastSegment = segments.pop(); segments.forEach(segment => { url += `/${segment}`; breadcrumbs.push({segment}); }); breadcrumbs.push(lastSegment); } return (

); } function PackageVersionPicker({ packageVersion, availableVersions, onChange }) { function handleChange(event) { if (onChange) onChange(event.target.value); } return (

); } function AppContent({ packageName, packageVersion, target }) { return target.type === 'directory' ? ( ) : target.type === 'file' ? ( ) : null; } export default function App({ packageName, packageVersion, availableVersions = [], filename, target }) { let maxContentWidth = 940; // TODO: Make this changeable let isFullWidth = false; return (
); } 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 }; }