1
1
mirror of https://github.com/primer/css.git synced 2024-12-29 17:12:27 +03:00

Variables page cleanup and linting

This commit is contained in:
Michelle Tilley 2019-12-16 14:17:54 -08:00
parent a8d6fbac01
commit 22c778f45d
No known key found for this signature in database
GPG Key ID: 810E3A96D4CF00F4
2 changed files with 9 additions and 7 deletions

View File

@ -13,5 +13,8 @@
"react": { "react": {
"version": "detect" "version": "detect"
} }
},
"globals": {
"__DEV__": "readonly"
} }
} }

View File

@ -24,12 +24,13 @@ const Table = styled(DoctocatTable)`
` `
function useVariables() { function useVariables() {
const deprecations = useDeprecations()
return React.useMemo(() => { return React.useMemo(() => {
let variablesByFile = new Map() let variablesByFile = new Map()
try { try {
const variables = require('../dist/variables.json') const variables = require('../dist/variables.json')
const deprecations = useDeprecations()
for (const name of Object.keys(variables)) { for (const name of Object.keys(variables)) {
if (name.endsWith('-font')) { if (name.endsWith('-font')) {
@ -80,8 +81,6 @@ function useDeprecations() {
function Variables({children, ...props}) { function Variables({children, ...props}) {
const variablesByFile = useVariables() const variablesByFile = useVariables()
console.log(__DEV__)
if (variablesByFile.size === 0) { if (variablesByFile.size === 0) {
return ( return (
<div className="flash flash-error"> <div className="flash flash-error">
@ -97,7 +96,7 @@ function Variables({children, ...props}) {
} }
return Array.from(variablesByFile.entries()).map(([path, variables]) => ( return Array.from(variablesByFile.entries()).map(([path, variables]) => (
<> <React.Fragment key={path}>
{children} {children}
<h3> <h3>
Defined in <Link href={`https://github.com/primer/css/tree/master/${path}`}>{path}</Link> Defined in <Link href={`https://github.com/primer/css/tree/master/${path}`}>{path}</Link>
@ -111,7 +110,7 @@ function Variables({children, ...props}) {
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{variables.map(({name, computed, values, source, refs}) => ( {variables.map(({name, computed, source, refs}) => (
<tr id={name} key={name}> <tr id={name} key={name}>
<th scope="row"> <th scope="row">
<Flex justifyContent="space-between"> <Flex justifyContent="space-between">
@ -139,7 +138,7 @@ function Variables({children, ...props}) {
))} ))}
</tbody> </tbody>
</Table> </Table>
</> </React.Fragment>
)) ))
} }
@ -168,7 +167,7 @@ Swatch.defaultProps = {
function RefList({refs}) { function RefList({refs}) {
const last = refs.length - 1 const last = refs.length - 1
return refs.map((ref, i) => [ return refs.map((ref, i) => [
<Link href={`#${ref}`}> <Link href={`#${ref}`} key={ref}>
<Mono nowrap>{ref}</Mono> <Mono nowrap>{ref}</Mono>
</Link>, </Link>,
i < last ? ', ' : '' i < last ? ', ' : ''