Skip to content

Commit f907dd2

Browse files
committed
fix: move all mdx components to one file
1 parent 004cd67 commit f907dd2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+571
-631
lines changed

.eslintrc.js

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,17 @@ module.exports = {
1212
'plugin:import/recommended',
1313
'prettier',
1414
],
15+
settings: {
16+
import: {
17+
ignore: ['^theme$'],
18+
},
19+
},
1520
rules: {
1621
'react/prop-types': 'off',
22+
// our theme use exports which dont work with import/no-unresolved
23+
'import/no-unresolved': ['error', {ignore: ['^theme$']}],
1724
},
1825
overrides: [
19-
// {
20-
// files: ['**/src/**/*.js'],
21-
// // env: {
22-
// // commonjs: false,
23-
// // browser: true,
24-
// // },
25-
// // parserOptions: {
26-
// // sourceType: 'module',
27-
// // },
28-
// },
29-
// {
30-
// files: ['**/gatsby-*.js'],
31-
// // env: {node: true},
32-
// },
33-
// {
34-
// files: ['**/test/*', '**/__tests__/*'],
35-
// env: {jest: true},
36-
// },
3726
{
3827
files: ['src/shared.js'],
3928
rules: {

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
!/CONTRIBUTING.md
2525
!/docs/
2626
!/gatsby-*.js
27+
!/jest*.js
2728
!/lib/
2829
!/LICENSE*
2930
!/map.js
@@ -33,7 +34,7 @@
3334
!/release-please-config.json
3435
!/scripts/
3536
!/SECURITY.md
36-
!/src/
37+
!/src
3738
!/static/
3839
!/tap-snapshots/
3940
!/test/

content/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: npm Documentation
33
edit_on_github: false
44
---
55

6-
import HeroLayout from 'theme/src/layout-hero'
6+
import HeroLayout from 'theme/layout/hero.js'
77
export default HeroLayout
88

99
<Index depth='1' />
File renamed without changes.
File renamed without changes.
File renamed without changes.

scripts/template-oss/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,13 @@ module.exports = {
3838
devDependencies: [],
3939
},
4040
allowPaths: [
41+
'/src',
4142
'/.reuse/',
42-
'/src/',
4343
'/static/',
4444
'/content/',
4545
'/LICENSE*',
4646
'/gatsby-*.js',
47+
'/jest*.js',
4748
'/CODE_OF_CONDUCT.md',
4849
'/CONTRIBUTING.md',
4950
'/CONTENT-MODEL.md',

src/shared.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import React from 'react'
2-
import {Link} from '@primer/react'
3-
import Screenshot from 'theme/src/mdx/screenshot'
4-
import Note from 'theme/src/mdx/note'
2+
import {Link, Note, Screenshot} from 'theme'
53

64
const shared = {
75
/* User login */

theme/.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
!/CHANGELOG*
1313
!/docs/
1414
!/gatsby-*.js
15-
!/jest*.js
1615
!/lib/
1716
!/LICENSE*
1817
!/map.js

theme/gatsby-config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ module.exports = ({icon}) => ({
5353
options: {
5454
extensions: ['.mdx', '.md'],
5555
defaultLayouts: {
56-
default: require.resolve('./src/layout-default.js'),
56+
default: require.resolve('./src/layout/default.js'),
5757
},
5858
},
5959
},

theme/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77
"type": "git"
88
},
99
"private": true,
10-
"main": "index.js",
10+
"exports": {
11+
".": "./src/mdx/index.js",
12+
"./layout/*.js": "./src/layout/*.js"
13+
},
1114
"license": "MIT",
1215
"scripts": {
1316
"test": "jest",

theme/scripts/template-oss/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
module.exports = {
22
...require('../../../scripts/template-oss'),
3-
allowPaths: ['/src', '/gatsby-*.js', '/jest*.js'],
3+
allowPaths: ['/src', '/gatsby-*.js'],
44
}

theme/src/components/contributors.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import {Avatar, Link, Text, Tooltip} from '@primer/react'
1+
import {Box, Avatar, Link, Text, Tooltip} from '@primer/react'
22
import React from 'react'
3-
import Flex from '../components/flex'
43

54
const pluralize = (word, count) => `${word}${count === 1 ? '' : 's'}`
65

@@ -23,7 +22,7 @@ const format = d => `${months[d.getMonth()]} ${d.getDate()}, ${d.getFullYear()}`
2322
function Contributors({logins, latestCommit}) {
2423
return (
2524
<div>
26-
<Flex alignItems="center">
25+
<Box display="flex" alignItems="center">
2726
<Text mr={2}>
2827
{logins.length} {pluralize('contributor', logins.length)}
2928
</Text>
@@ -35,7 +34,7 @@ function Contributors({logins, latestCommit}) {
3534
</Tooltip>
3635
</Link>
3736
))}
38-
</Flex>
37+
</Box>
3938
{latestCommit ? (
4039
<Text fontSize={1} color="gray.7" mt={1}>
4140
Last edited by <Link href={`https://github.com/${latestCommit.login}`}>{latestCommit.login}</Link> on{' '}

theme/src/components/flex.js

Lines changed: 0 additions & 6 deletions
This file was deleted.

theme/src/components/header.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import MobileSearch from './mobile-search'
66
import NavDrawer from './nav-drawer'
77
import Search from './search'
88
import NpmLogo from './npm-logo'
9-
import Flex from './flex'
109
import useSearch from '../hooks/use-search'
1110
import useSiteMetadata from '../hooks/use-site-metadata'
1211
import headerNavItems from '../header-nav.yml'
@@ -33,45 +32,46 @@ function Header({location, repositoryUrl}) {
3332
return (
3433
<Box position="sticky" role="banner">
3534
<NpmHeaderBar />
36-
<Flex
35+
<Box
36+
display="flex"
3737
height={HEADER_HEIGHT}
3838
px={[3, null, null, 4]}
3939
alignItems="center"
4040
justifyContent="space-between"
4141
bg="#333333"
4242
>
43-
<Flex alignItems="center">
43+
<Box display="flex" alignItems="center">
4444
<Link as={GatsbyLink} to="/" style={titleStyle} sx={{mr: 4}}>
4545
<NpmLogo size="32" style={logoStyle} />
4646
{siteMetadata.title}
4747
</Link>
4848
<Box display={['none', null, null, 'block']} ml={4}>
4949
<Search {...search} />
5050
</Box>
51-
</Flex>
52-
<Flex>
51+
</Box>
52+
<Box display="flex">
5353
<Box display={['none', null, null, 'block']}>
5454
<HeaderNavItems items={headerNavItems} />
5555
</Box>
56-
<Flex display={['flex', null, null, 'none']}>
56+
<Box display={['flex', null, null, 'none']}>
5757
<MobileSearch {...search} />
5858
<NavDrawer location={location} repositoryUrl={repositoryUrl} />
59-
</Flex>
60-
</Flex>
61-
</Flex>
59+
</Box>
60+
</Box>
61+
</Box>
6262
</Box>
6363
)
6464
}
6565

6666
function HeaderNavItems({items}) {
6767
return (
68-
<Flex alignItems="center" color="gray.2">
68+
<Box display="flex" alignItems="center" color="gray.2">
6969
{items.map((item, index) => (
7070
<Link key={index} href={item.url} sx={{display: 'block', color: 'inherit', ml: 4}}>
7171
{item.title}
7272
</Link>
7373
))}
74-
</Flex>
74+
</Box>
7575
)
7676
}
7777

theme/src/components/mobile-search.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import {Box} from '@primer/react'
33
import {XIcon, SearchIcon} from '@primer/octicons-react'
44
import {AnimatePresence, motion} from 'framer-motion'
55
import {FocusOn} from 'react-focus-on'
6-
import Flex from './flex'
76
import DarkButton from './dark-button'
87
import DarkTextInput from './dark-text-input'
98
import SearchResults from './search-results'
@@ -35,8 +34,8 @@ function MobileSearch({onDismiss, ...props}) {
3534
zIndex={-1}
3635
onClick={handleDismiss}
3736
/>
38-
<Flex flexDirection="column" height={isOpen ? '100%' : 'auto'}>
39-
<Flex bg="gray.9" color="white" p={3} flex="0 0 auto">
37+
<Box display="flex" flexDirection="column" height={isOpen ? '100%' : 'auto'}>
38+
<Box display="flex" bg="gray.9" color="white" p={3} flex="0 0 auto">
4039
<motion.div
4140
initial={{scaleX: 0.1}}
4241
animate={{scaleX: 1}}
@@ -55,8 +54,9 @@ function MobileSearch({onDismiss, ...props}) {
5554
<DarkButton ml={3} aria-label="Cancel" onClick={handleDismiss}>
5655
<XIcon />
5756
</DarkButton>
58-
</Flex>
59-
<Flex
57+
</Box>
58+
<Box
59+
display="flex"
6060
{...getMenuProps({
6161
bg: 'white',
6262
py: isOpen ? 1 : 0,
@@ -69,8 +69,8 @@ function MobileSearch({onDismiss, ...props}) {
6969
})}
7070
>
7171
{isOpen ? <SearchResults {...{results, getItemProps, highlightedIndex}} /> : null}
72-
</Flex>
73-
</Flex>
72+
</Box>
73+
</Box>
7474
</Box>
7575
</FocusOn>
7676
)

theme/src/components/nav-drawer.js

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import React from 'react'
2-
import {Link} from '@primer/react'
2+
import {Box, Link} from '@primer/react'
33
import BorderBox from './border-box'
44
import {XIcon, ThreeBarsIcon} from '@primer/octicons-react'
55
import {Link as GatsbyLink} from 'gatsby'
66
import DarkButton from './dark-button'
77
import Drawer from './drawer'
88
import NavItems from './nav-items'
9-
import Flex from './flex'
109
import navItems from '../nav.yml'
1110
import headerNavItems from '../header-nav.yml'
1211
import useSiteMetadata from '../hooks/use-site-metadata'
@@ -37,35 +36,45 @@ function NavDrawer({location, repositoryUrl}) {
3736
<ThreeBarsIcon />
3837
</DarkButton>
3938
<Drawer isOpen={isOpen} onDismiss={setClose}>
40-
<Flex
39+
<Box
40+
display="flex"
4141
flexDirection="column"
4242
height="100%"
4343
bg="gray.0"
4444
style={{overflow: 'auto', WebkitOverflowScrolling: 'touch'}}
4545
>
46-
<Flex flexDirection="column" flex="1 0 auto" color="gray.7" bg="gray.0">
46+
<Box display="flex" flexDirection="column" flex="1 0 auto" color="gray.7" bg="gray.0">
4747
<BorderBox borderWidth={0} borderRadius={0} borderBottomWidth={1} borderColor="gray.7">
48-
<Flex py={3} pl={4} pr={3} alignItems="center" justifyContent="space-between" color="gray.1" bg="gray.9">
48+
<Box
49+
display="flex"
50+
py={3}
51+
pl={4}
52+
pr={3}
53+
alignItems="center"
54+
justifyContent="space-between"
55+
color="gray.1"
56+
bg="gray.9"
57+
>
4958
<Link as={GatsbyLink} to="/" sx={{display: 'inline-block', color: 'inherit'}}>
5059
{siteMetadata.title}
5160
</Link>
5261
<DarkButton aria-label="Close" onClick={setClose}>
5362
<XIcon />
5463
</DarkButton>
55-
</Flex>
64+
</Box>
5665
</BorderBox>
5766
{navItems.length > 0 ? (
58-
<Flex flexDirection="column">
67+
<Box display="flex" flexDirection="column">
5968
<NavItems location={location} items={navItems} repositoryUrl={repositoryUrl} />
60-
</Flex>
69+
</Box>
6170
) : null}
62-
</Flex>
71+
</Box>
6372
{headerNavItems.length > 0 ? (
64-
<Flex flexDirection="column" flex="1 0 auto" color="gray.1" bg="gray.9">
73+
<Box display="flex" flexDirection="column" flex="1 0 auto" color="gray.1" bg="gray.9">
6574
<HeaderNavItems items={headerNavItems} />
66-
</Flex>
75+
</Box>
6776
) : null}
68-
</Flex>
77+
</Box>
6978
</Drawer>
7079
</>
7180
)

0 commit comments

Comments
 (0)