diff --git a/research/src/components/component-index.js b/research/src/components/component-index.js new file mode 100644 index 000000000..2664ef8b5 --- /dev/null +++ b/research/src/components/component-index.js @@ -0,0 +1,37 @@ +import React from 'react' +import _ from 'lodash' +import { openUIConceptsByComponent } from '../sources' + +export default function ConceptIndex({ component }) { + if (!openUIConceptsByComponent[component]) return null + + const concepts = _.sortBy( + _.toPairs(openUIConceptsByComponent[component]), + ([openUIName, concepts]) => -concepts.length, + ) + + return ( +
    +
  1. + Names +
  2. +
  3. + Anatomy +
  4. +
  5. + Concepts +
  6. +
      + {concepts.map(([concept]) => { + return ( +
    1. + + {concept} + +
    2. + ) + })} +
    +
+ ) +} diff --git a/research/src/components/concept.js b/research/src/components/concept.js index 2a6319f27..9869d08ac 100644 --- a/research/src/components/concept.js +++ b/research/src/components/concept.js @@ -8,13 +8,7 @@ export default function Concept({ component, uniqueNames, showDescriptions, - initExpand, }) { - const [open, toggleOpen] = React.useState(initExpand) - - React.useEffect(() => { - toggleOpen(initExpand) - }, [initExpand]) return (

- + {conceptOpenUIName} {!hasOtherNames && ( )} - - {open && ( - - )} +

) } diff --git a/research/src/components/concepts.js b/research/src/components/concepts.js index bdf6b3762..5b14f012f 100644 --- a/research/src/components/concepts.js +++ b/research/src/components/concepts.js @@ -6,7 +6,6 @@ import Concept from './concept' const Concepts = ({ component }) => { const [showDescriptions, setShowDescriptions] = React.useState(false) - const [collapseAll, toggleCollapseAll] = React.useState(true) const conceptsForComponent = _.sortBy( _.toPairs(openUIConceptsByComponent[component]), @@ -42,27 +41,6 @@ const Concepts = ({ component }) => { /> Show descriptions - {_.map(conceptsForComponent, ([conceptOpenUIName, concepts]) => { const uniqueNames = _.uniq(_.map(concepts, 'name')) @@ -76,7 +54,6 @@ const Concepts = ({ component }) => { uniqueNames={uniqueNames} showDescriptions={showDescriptions} key={conceptOpenUIName} - initExpand={collapseAll} /> ) })} diff --git a/research/src/components/global.css b/research/src/components/global.css index b0c063965..fe2f7a00b 100644 --- a/research/src/components/global.css +++ b/research/src/components/global.css @@ -1,3 +1,7 @@ +html { + scroll-behavior: smooth; +} + /* Header */ .header-menu-btn[type='button'] { display: none; @@ -50,6 +54,10 @@ display: none; } + .component-index-wrapper { + display: none; + } + .community-links.mobile { display: flex; } diff --git a/research/src/components/layout.js b/research/src/components/layout.js index fcfaf4f11..418b8b244 100644 --- a/research/src/components/layout.js +++ b/research/src/components/layout.js @@ -10,6 +10,7 @@ import './global.css' import Header from './header' import Navigation from './navigation' import ComponentLayout from './component-layout' +import ComponentIndex from './component-index' // Add JSON5 language support to Prism import Prism from 'prism-react-renderer/prism' @@ -94,6 +95,11 @@ const Layout = ({ children, pageContext }) => { children )} + {frontmatter ? ( +
+ +
+ ) : null}