Skip to content
This repository was archived by the owner on Mar 4, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- Menu `onClick` handler moved from `li` to `a` (accessibility) @miroslavstastny ([#61](https://github.com/stardust-ui/react/pull/61))


### Features
- Add `color` variables to Header and Header.Description @kuzhelov ([#72](https://github.com/stardust-ui/react/pull/72))

<!--------------------------------[ v0.2.6 ]------------------------------- -->
## [v0.2.6](https://github.com/stardust-ui/react/tree/v0.2.6) (2018-08-09)
[Compare changes](https://github.com/stardust-ui/react/compare/v0.2.5...v0.2.6)
Expand Down
16 changes: 15 additions & 1 deletion src/components/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import * as React from 'react'
import { childrenExist, customPropTypes, UIComponent } from '../../lib'
import HeaderDescription from './HeaderDescription'
import headerStyles from '../../themes/teams/components/Header/headerStyles'
import headerVariables from './headerVariables'

/**
* A header provides a short summary of content
Expand Down Expand Up @@ -34,16 +35,29 @@ class Header extends UIComponent<any, any> {

/** Align header content. */
textAlign: PropTypes.oneOf(['left', 'center', 'right', 'justified']),

/** Custom values for styling variables. */
variables: PropTypes.object,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it necessary to add the variables prop? We don't have it added in any of the other components.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually, this thing turns out to be necessary for the sake of preventing variables being passed further to the child DOM tree - otherwise we can end up with the following thing:

image

For the sake of preventing this to happen the variables property has been declared as handled.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it! We should address this in the other components as well. Approving this PR.

}

static defaultProps = {
as: 'h1',
}

static handledProps = ['as', 'children', 'className', 'content', 'description', 'textAlign']
static handledProps = [
'as',
'children',
'className',
'content',
'description',
'textAlign',
'variables',
]

static styles = headerStyles

static variables = headerVariables

static Description = HeaderDescription

renderComponent({ ElementType, classes, rest }) {
Expand Down
8 changes: 7 additions & 1 deletion src/components/Header/HeaderDescription.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import * as React from 'react'
import { childrenExist, createShorthandFactory, customPropTypes, UIComponent } from '../../lib'

import headerDescriptionStyles from '../../themes/teams/components/Header/headerDescriptionStyles'
import headerDescriptionVariables from './headerDescriptionVariables'

/**
* Headers may contain description.
Expand All @@ -27,16 +28,21 @@ class HeaderDescription extends UIComponent<any, any> {

/** Shorthand for primary content. */
content: customPropTypes.contentShorthand,

/** Custom values for styling variables. */
variables: PropTypes.object,
}

static defaultProps = {
as: 'p',
}

static handledProps = ['as', 'children', 'className', 'content']
static handledProps = ['as', 'children', 'className', 'content', 'variables']

static styles = headerDescriptionStyles

static variables = headerDescriptionVariables

renderComponent({ ElementType, classes, rest }) {
const { children, content } = this.props
return (
Expand Down
3 changes: 3 additions & 0 deletions src/components/Header/headerDescriptionVariables.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default siteVariables => ({
color: 'rgba(0,0,0,.6)',
})
3 changes: 3 additions & 0 deletions src/components/Header/headerVariables.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default siteVariables => ({
color: 'black',
})
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { pxToRem } from '../../../../lib'

export default {
root: () => ({
root: ({ variables: v }) => ({
display: 'block',
fontSize: pxToRem(22),
color: 'rgba(0,0,0,.6)',
color: v.color,
fontWeight: 400,
}),
}
3 changes: 2 additions & 1 deletion src/themes/teams/components/Header/headerStyles.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export default {
root: ({ props }) => ({
root: ({ props, variables: v }) => ({
color: v.color,
textAlign: props.textAlign,
display: 'block',
...(props.description && { marginBottom: 0 }),
Expand Down