Skip to content

Commit

Permalink
Move Octicons website into primer/octicons repo (#377)
Browse files Browse the repository at this point in the history
* Scaffold docs site

* Display icons on homepage

* Import json file directly

* Remove sidebar

* Update doctocat

* Remove example pages

* Disable search on hompage

* Create pages for each icon

* Implement search

* Add aria-label to search input

* Fix icon viewer

* Add start script

* Remove README

* Move index page to content directory
  • Loading branch information
colebemis committed Mar 6, 2020
1 parent 078e2f9 commit e4f54e4
Show file tree
Hide file tree
Showing 13 changed files with 21,216 additions and 1 deletion.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,10 @@ vendor

# Ignore build/export artifacts
lib/**/build/

# Gatsby
public
.cache

# Now
.now
3 changes: 3 additions & 0 deletions docs/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": ["plugin:github/recommended", "plugin:github/es6", "plugin:github/react"]
}
39 changes: 39 additions & 0 deletions docs/content/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import {Flex, Link, TextInput} from '@primer/components'
import {Container, Head, Header, Hero} from '@primer/gatsby-theme-doctocat'
import {Search} from '@primer/octicons-react'
import icons from '../../lib/build/data.json'
import Icon from '../src/components/icon'
import useSearch from '../src/use-search'

export default function IndexPage() {
const [query, setQuery] = React.useState('')
const iconsArray = React.useMemo(() => Object.values(icons), [icons])
const results = useSearch(iconsArray, query, {keys: ['name']})
return (
<Flex flexDirection="column" minHeight="100vh">
<Head />
<Header isSearchEnabled={false} />
<Hero />
<Container>
<TextInput
icon={Search}
aria-label="Search"
value={query}
onChange={event => setQuery(event.target.value)}
placeholder="Search icons..."
width="100%"
mb={5}
/>
<Flex flexWrap="wrap" m={-3}>
{results.map(icon => (
<Link key={icon.name} display="block" p={3} color="inherit" href={icon.name}>
<Flex>
<Icon name={icon.name} />
</Flex>
</Link>
))}
</Flex>
</Container>
</Flex>
)
}
17 changes: 17 additions & 0 deletions docs/gatsby-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module.exports = {
siteMetadata: {
title: 'Octicons',
shortName: 'Octicons',
description: "Your project. GitHub's icons.",
imageUrl: 'https://user-images.githubusercontent.com/10384315/53922681-2f6d3100-402a-11e9-9719-5d1811c8110a.png'
},
pathPrefix: '/octicons',
plugins: [
{
resolve: '@primer/gatsby-theme-doctocat',
options: {
repoRootPath: '..'
}
}
]
}
14 changes: 14 additions & 0 deletions docs/gatsby-node.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const path = require('path')
const icons = require('../lib/build/data.json')

exports.createPages = async ({actions}) => {
const iconPageTemplate = path.resolve(__dirname, 'src/templates/icon-page.mdx')

for (const icon of Object.values(icons)) {
actions.createPage({
path: icon.name,
component: iconPageTemplate,
context: {name: icon.name}
})
}
}
Loading

1 comment on commit e4f54e4

@vercel
Copy link

@vercel vercel bot commented on e4f54e4 Mar 6, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.