Skip to content

Commit

Permalink
Section Header Cleanup
Browse files Browse the repository at this point in the history
improved behavior when empty
  • Loading branch information
tom22ger committed Aug 14, 2019
1 parent 0795792 commit 7737c5a
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 51 deletions.
4 changes: 4 additions & 0 deletions src/components/SectionHeader/ExpandingMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ export default class ExpandingMenu extends React.Component {
color: #ffffff;
cursor: pointer;
@media (min-width: 600px) {
color: #000000;
}
`}
onClick={this.expandMenu}
>
Expand Down
21 changes: 6 additions & 15 deletions src/components/SectionHeader/ExpandingTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,8 @@ import { css } from 'react-emotion'
export default class ExpandingTab extends React.Component<ExpandingTabProps> {
constructor(props: ExpandingTabProps) {
super(props)
this.state = {
underlined: 'none',
}
this.underlineHovered = this.underlineHovered.bind(this)
this.underlineClear = this.underlineClear.bind(this)
}
public underlineHovered() {
this.setState({ underlined: 'underline' })
}
public underlineClear() {
this.setState({ underlined: 'none' })
}

public render() {
return (
<li
Expand All @@ -33,7 +23,7 @@ export default class ExpandingTab extends React.Component<ExpandingTabProps> {
`}
>
<a
href={this.props.section.link}
href={this.props.section.url}
className={css`
display: block;
font-family: Source Sans Pro;
Expand All @@ -43,10 +33,11 @@ export default class ExpandingTab extends React.Component<ExpandingTabProps> {
text-transform: uppercase;
text-align: left;
color: #ffffff;
text-decoration: none;
&:hover {
text-decoration: underline;
}
`}
style={{ textDecoration: this.state.underlined }}
onMouseEnter={this.underlineHovered}
onMouseLeave={this.underlineClear}
>
{this.props.section.name}
</a>
Expand Down
10 changes: 0 additions & 10 deletions src/components/SectionHeader/ExpandingTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,6 @@ export default class ExpandingTabs extends React.Component<ExpandingTabsProps> {
constructor(props: ExpandingTabsProps) {
super(props)
}
public underlineHovered(idTitle: string) {
document.getElementById(
'SectionHeaderExpandingTab' + idTitle
).style.textDecoration = 'underline'
}
public underlineClear(idTitle: string) {
document.getElementById(
'SectionHeaderExpandingTab' + idTitle
).style.textDecoration = 'none'
}
public render() {
const sections = this.props.sectionList
const sectionTabList = []
Expand Down
22 changes: 5 additions & 17 deletions src/components/SectionHeader/SectionTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,20 @@ import { css } from 'react-emotion'
export default class SectionTab extends React.Component<SectionTabProps> {
constructor(props: SectionTabProps) {
super(props)
this.state = {
underlined: 'none',
}
this.underlineHovered = this.underlineHovered.bind(this)
this.underlineClear = this.underlineClear.bind(this)
}
public underlineHovered() {
this.setState({ underlined: 'underline' })
}
public underlineClear() {
this.setState({ underlined: 'none' })
}
public render() {
const { underlineState = 'underline' } = this.state.underlined
return (
<li
className={css`
box-sizing: border-box;
text-decoration: none;
height: 38px;
display: inline-block;
padding: 7px 10px;
background-color: #000000;
`}
>
<a
href={this.props.section.link}
href={this.props.section.url}
className={css`
color: #ffffff;
font-family: Source Sans Pro;
Expand All @@ -39,10 +26,11 @@ export default class SectionTab extends React.Component<SectionTabProps> {
line-height: normal;
font-size: 18px;
text-transform: uppercase;
text-decoration: none;
&:hover {
text-decoration: underline;
}
`}
style={{ textDecoration: this.state.underlined }}
onMouseEnter={this.underlineHovered}
onMouseLeave={this.underlineClear}
>
{this.props.section.name}
</a>
Expand Down
2 changes: 1 addition & 1 deletion src/components/SectionHeader/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import SectionHeader from '.'

A header to describe the current section the viewer is in

Note that `SectionHeader` expects an array of `SectionLink` objects which include `name` and `link` values.
Note that `SectionHeader` expects an array of `Link` objects which include `name` and `url` values.

<Props of={SectionHeader} />

Expand Down
10 changes: 5 additions & 5 deletions src/components/SectionHeader/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ import { css } from 'react-emotion'
import SectionTabs from './SectionTabs'
import ExpandingMenu from './ExpandingMenu'

interface SectionLink {
interface Link {
name: string
link: string
}

interface SectionHeaderProps {
name: string
sectionList: SectionLink[]
sectionList: Link[]
}

interface ExpandingTabsProps {
sectionList: SectionLink[]
sectionList: Link[]
}

interface SectionTabProps {
Expand Down Expand Up @@ -57,9 +57,9 @@ export default class SectionHeader extends React.Component<SectionHeaderProps> {
line-height: 62px;
height: 55px;
font-family: Archivo Black, Arial, sans-serif;
font-family: Archivo Black, sans-serif;
font-style: normal;
font-weight: normal;
font-weight: 900;
line-height: normal;
font-size: 48px;
text-transform: uppercase;
Expand Down
8 changes: 5 additions & 3 deletions src/components/StoryList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ interface StoryListProps {
/** An image relating to the most popular story (i.e. the first in the list). */
image?: ImageContent
/** Determines the title of the black top-bar (see example below). Defaults to popular stories. */
type: StoryListType
// type: StoryListType
type: string
}

class StoryList extends React.Component<StoryListProps> {
Expand Down Expand Up @@ -58,11 +59,12 @@ class StoryList extends React.Component<StoryListProps> {
>
<TopBar
title={
!!this.props.image
/* !!this.props.image
? 'IN THE NEWS'
: this.props.type === StoryListType.Popular
? 'POPULAR'
: 'IN THE PRINT'
: 'IN THE PRINT' */
this.props.type
}
/>
{!!this.props.image && (
Expand Down
1 change: 1 addition & 0 deletions src/globals/mainsiteGlobalStyles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ if (typeof window !== 'undefined') {
'Lora:700',
'Lora:400',
'PT Serif:400',
'Source Sans Pro:400',
'Source Sans Pro:700',
'Source Sans Pro:900',
],
Expand Down

0 comments on commit 7737c5a

Please sign in to comment.