Skip to content
This repository has been archived by the owner on Aug 21, 2023. It is now read-only.

Commit

Permalink
Merge dc9a9bc into 6025e77
Browse files Browse the repository at this point in the history
  • Loading branch information
tinkertrain committed Jan 9, 2019
2 parents 6025e77 + dc9a9bc commit 01f8507
Show file tree
Hide file tree
Showing 27 changed files with 799 additions and 381 deletions.
35 changes: 15 additions & 20 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@helpscout/hsds-react",
"version": "2.5.7",
"version": "2.5.8-page-beta-0",
"private": false,
"main": "dist/index.js",
"module": "dist/index.es.js",
Expand Down
13 changes: 2 additions & 11 deletions src/components/Page/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,13 @@ import { COMPONENT_KEY } from './utils'
export interface Props {
children?: any
className?: string
isResponsive: boolean
}

class Card extends React.PureComponent<Props> {
static defaultProps = {
isResponsive: false,
}

render() {
const { children, className, isResponsive, ...rest } = this.props
const { children, className, ...rest } = this.props

const componentClassName = classNames(
'c-PageCard',
isResponsive && 'is-responsive',
className
)
const componentClassName = classNames('c-PageCard', className)

return (
<CardUI {...getValidProps(rest)} className={componentClassName}>
Expand Down
55 changes: 36 additions & 19 deletions src/components/Page/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,44 @@ import getValidProps from '@helpscout/react-utils/dist/getValidProps'
import Text from '../Text'
import { classNames } from '../../utilities/classNames'
import { namespaceComponent } from '../../utilities/component'
import { HeaderUI, TitleUI, SubTitleUI } from './styles/Header.css'
import Heading from './Heading'
import { HeaderUI, TitleUI, SubTitleUI, HeadingUI } from './styles/Header.css'
import { COMPONENT_KEY } from './utils'

export interface Props {
children?: any
className?: string
isResponsive: boolean
title: string
render?: any
title?: string
subtitle?: string
withBorder: boolean
withBottomMargin: boolean
}

const Title = props => {
const { headingLevel, isSecondary, className, children, ...rest } = props
const componentClassName = classNames('c-PageHeading', className)

return (
<TitleUI className="c-PageHeader__title">
<HeadingUI
{...getValidProps(rest)}
selector={headingLevel || 'h1'}
size={isSecondary ? 'h4' : 'md'}
className={componentClassName}
>
{children}
</HeadingUI>
</TitleUI>
)
}

const Subtitle = ({ children }) => (
<SubTitleUI className="c-PageHeader__subtitle">
<Text shade="muted">{children}</Text>
</SubTitleUI>
)

class Header extends React.PureComponent<Props> {
static defaultProps = {
isResponsive: false,
Expand All @@ -27,9 +51,9 @@ class Header extends React.PureComponent<Props> {

render() {
const {
children,
className,
isResponsive,
render,
title,
subtitle,
withBorder,
Expand All @@ -45,23 +69,16 @@ class Header extends React.PureComponent<Props> {
className
)

const titleMarkup = title && (
<TitleUI className="c-PageHeader__title">
<Heading className="c-PageHeader__titleHeading">{title}</Heading>
</TitleUI>
)
const subtitleMarkup = subtitle && (
<SubTitleUI className="c-PageHeader__subtitle">
<Text className="c-PageHeader__subtitleText" shade="muted">
{subtitle}
</Text>
</SubTitleUI>
)

return (
<HeaderUI {...getValidProps(rest)} className={componentClassName}>
{titleMarkup}
{subtitleMarkup}
{render ? (
render({ Title, Subtitle })
) : (
<div>
<Title>{title}</Title>
{subtitle && <Subtitle>{subtitle}</Subtitle>}
</div>
)}
</HeaderUI>
)
}
Expand Down
51 changes: 0 additions & 51 deletions src/components/Page/Heading.tsx

This file was deleted.

9 changes: 6 additions & 3 deletions src/components/Page/Page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Actions from './Actions'
import Card from './Card'
import Content from './Content'
import Header from './Header'
import Heading from './Heading'
import Section from './Section'
import PropProvider from '../PropProvider'
import { classNames } from '../../utilities/classNames'
import { namespaceComponent } from '../../utilities/component'
Expand All @@ -25,19 +25,22 @@ class Page extends React.PureComponent<Props> {
static Card = Card
static Content = Content
static Header = Header
static Heading = Heading
static Section = Section

getPropProviderProps = () => {
const { isResponsive } = this.props

return {
Accordion: { isPage: true, isSeamless: true },
[COMPONENT_KEY.Card]: {
[COMPONENT_KEY.Section]: {
isResponsive,
},
[COMPONENT_KEY.Header]: {
isResponsive,
},
[COMPONENT_KEY.Content]: {
isResponsive,
},
}
}

Expand Down
37 changes: 37 additions & 0 deletions src/components/Page/Section.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import * as React from 'react'
import { COMPONENT_KEY } from './utils'
import { classNames } from '../../utilities/classNames'
import { namespaceComponent } from '../../utilities/component'
import { SectionUI } from './styles/Section.css'

export interface Props {
children?: any
className?: string
isResponsive?: boolean
}

class Section extends React.PureComponent<Props> {
static defaultProps = {
isResponsive: false,
}

render() {
const { children, className, isResponsive, ...rest } = this.props

const componentClassName = classNames(
'c-PageSection',
isResponsive && 'is-responsive',
className
)

return (
<SectionUI className={componentClassName}>
{this.props.children}
</SectionUI>
)
}
}

namespaceComponent(COMPONENT_KEY.Section)(Section)

export default Section

0 comments on commit 01f8507

Please sign in to comment.