-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add css class to page background with controls
Allow displaying the slim control's shadow along the bottom for pages with player controls. The old solution causes the shadow to be applied twice on audio pages with background video.
- Loading branch information
Showing
5 changed files
with
54 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,32 @@ | ||
import {Component} from 'react'; | ||
import classNames from 'classnames'; | ||
|
||
/** | ||
* @desc Use inside {@link | ||
* pageflow.react.components.PageWrapper|PageWrapper} to build the | ||
* default page structure. | ||
* | ||
* @prop pageHasPlayerControls | ||
* Set to true if player controls are present on the page. This can | ||
* be used by themes to apply different styles to the background. | ||
* | ||
* @alias pageflow.react.components.PageBackground | ||
* @class | ||
* @since 0.1 | ||
*/ | ||
export default class extends Component { | ||
render() { | ||
return ( | ||
<div className="backgroundArea"> | ||
{this.props.children} | ||
</div> | ||
); | ||
} | ||
export default function PageBackground(props) { | ||
return ( | ||
<div className={className(props)}> | ||
{props.children} | ||
</div> | ||
); | ||
} | ||
|
||
PageBackground.propTypes = { | ||
pageHasPlayerControls: React.PropTypes.bool | ||
}; | ||
|
||
function className({pageHasPlayerControls}) { | ||
return classNames('backgroundArea page_background', { | ||
'page_background-for_page_with_player_controls': pageHasPlayerControls | ||
}); | ||
} |
30 changes: 30 additions & 0 deletions
30
node_package/src/components/__spec__/PageBackground-spec.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import PageBackground from '../PageBackground'; | ||
|
||
import {expect} from 'support/chai'; | ||
import {shallow} from 'enzyme'; | ||
|
||
describe('PageBackground', () => { | ||
it('has backgroundArea class', () => { | ||
const wrapper = shallow(<PageBackground />); | ||
|
||
expect(wrapper).to.have.className('backgroundArea'); | ||
}); | ||
|
||
it('has page_background class', () => { | ||
const wrapper = shallow(<PageBackground />); | ||
|
||
expect(wrapper).to.have.className('page_background'); | ||
}); | ||
|
||
it('does not have page_background-for_page_with_player_controls by default', () => { | ||
const wrapper = shallow(<PageBackground />); | ||
|
||
expect(wrapper).not.to.have.className('page_background-for_page_with_player_controls'); | ||
}); | ||
|
||
it('has page_background-for_page_with_player_controls if pageHasPlayerControls is true', () => { | ||
const wrapper = shallow(<PageBackground pageHasPlayerControls={true} />); | ||
|
||
expect(wrapper).to.have.className('page_background-for_page_with_player_controls'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters