diff --git a/common/config.js b/common/config.js index 60e999e..ddad5a1 100644 --- a/common/config.js +++ b/common/config.js @@ -11,9 +11,11 @@ export const getPageNames = (radar) => { 'overview', 'help', ...quadrants, + ...getItemPageNames(radar.items), ] } +export const getItemPageNames = (items) => items.map(item => `${item.quadrant}/${item.name}`); export const rings = [ 'assess', diff --git a/js/client.js b/js/client.js index 5cc2aa2..4f62663 100644 --- a/js/client.js +++ b/js/client.js @@ -28,7 +28,7 @@ const historyManager = store => { return next => action => { if(action.type === NAVIGATE && action.pushToHistory === true) { - history.push(`${action.pageName}.html`); + history.push(`/${action.pageName}.html`); } return next(action); } diff --git a/js/components/Header.js b/js/components/Header.js index 0163da3..7ac7654 100644 --- a/js/components/Header.js +++ b/js/components/Header.js @@ -1,19 +1,27 @@ import React from 'react'; +import Link from './Link'; -export default function Header({ navigate }) { - const handleClick = (pageName) => (e) => { - e.preventDefault(); - navigate(pageName); - }; - +export default function Header() { return (
- +
-
How to Use Technology Radar?
-
Technologies Overview
-
Search
+
+ + How to Use Technology Radar? + +
+
+ + Technologies Overview + +
+
+ + Search + +
diff --git a/js/components/Item.js b/js/components/Item.js index 24c4680..05b158b 100644 --- a/js/components/Item.js +++ b/js/components/Item.js @@ -1,13 +1,14 @@ import React from 'react'; import classNames from 'classnames'; +import Link from './Link'; export default function Item({ item, noLeadingBorder = false}) { return ( -
{item.title}
{ @@ -15,6 +16,6 @@ export default function Item({ item, noLeadingBorder = false}) {
{item.info}
) } -
+ ); } diff --git a/js/components/Link.js b/js/components/Link.js new file mode 100644 index 0000000..165729c --- /dev/null +++ b/js/components/Link.js @@ -0,0 +1,21 @@ +import React from 'react'; +import { connect } from 'react-redux'; +import actions from '../actions'; + +function Link({ pageName, children, navigate, className}) { + const handleClick = (e) => { + e.preventDefault(); + navigate(pageName); + }; + + return ( + + {children} + + ); +} + +export default connect( + undefined, + actions +)(Link); diff --git a/js/components/PageItem.js b/js/components/PageItem.js new file mode 100644 index 0000000..c038c42 --- /dev/null +++ b/js/components/PageItem.js @@ -0,0 +1,12 @@ +import React from 'react'; +import HeroHeadline from './HeroHeadline'; + +export default function PageItems({ pageName, items }) { + const [quadrantName, itemName] = pageName.split('/'); + const item = items.filter(item => item.quadrant === quadrantName && item.name === itemName)[0]; + return ( +
+ {item.title} +
+ ); +} diff --git a/js/components/PageOverview.js b/js/components/PageOverview.js index f3337e0..8f25937 100644 --- a/js/components/PageOverview.js +++ b/js/components/PageOverview.js @@ -3,6 +3,7 @@ import classNames from 'classnames'; import HeadlineGroup from './HeadlineGroup'; import HeroHeadline from './HeroHeadline'; import Badge from './Badge'; +import Link from './Link'; import { groupByFirstLetter } from '../../common/model'; import { translate } from '../../common/config'; @@ -76,7 +77,11 @@ class PageOverview extends React.Component {
{ items.map((item) => ( - +
{item.title}
@@ -90,7 +95,7 @@ class PageOverview extends React.Component {
- + )) } diff --git a/js/components/QuadrantSection.js b/js/components/QuadrantSection.js index f7d42af..4ab50a8 100644 --- a/js/components/QuadrantSection.js +++ b/js/components/QuadrantSection.js @@ -2,6 +2,7 @@ import React from 'react'; import { translate, rings } from '../../common/config'; import Badge from './Badge'; import Item from './Item'; +import Link from './Link'; const renderList = (ringName, quadrantName, groups, big) => { const itemsInRing = groups[quadrantName][ringName]; @@ -34,7 +35,7 @@ const renderList = (ringName, quadrantName, groups, big) => { key={item.name} className="ring-list__item" > - {item.title} + {item.title} )) } @@ -65,9 +66,9 @@ export default function QuadrantSection({ quadrantName, groups, big = false }) { { !big && (
- + Quadrant Overview - +
) } diff --git a/js/components/Router.js b/js/components/Router.js index d8f69ef..1002355 100644 --- a/js/components/Router.js +++ b/js/components/Router.js @@ -3,10 +3,11 @@ import PageIndex from './PageIndex'; import PageOverview from './PageOverview'; import PageHelp from './PageHelp'; import PageQuadrant from './PageQuadrant'; -import { quadrants } from '../../common/config'; +import PageItem from './PageItem'; +import { quadrants, getItemPageNames } from '../../common/config'; -const getPageByName = (pageName) => { +const getPageByName = (items, pageName) => { if (pageName === 'index') { return PageIndex; } @@ -19,11 +20,14 @@ const getPageByName = (pageName) => { if (quadrants.includes(pageName)) { return PageQuadrant; } + if (getItemPageNames(items).includes(pageName)) { + return PageItem; + } return 'div'; } export default function Router({ pageName, ...props}) { - const Comp = getPageByName(pageName); + const Comp = getPageByName(props.items, pageName); return ; }