-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
47 additions
and
2 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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import * as React from "react"; | ||
import * as PropTypes from "prop-types"; | ||
|
||
import ElementState, { ElementStateProps } from "./ElementState"; | ||
import spreadObject from "./common/spreadObject"; | ||
|
||
const pseudoClassesNames = ["&:hover", "&:active", "&:visited", "&:focus", "&:disabled"]; | ||
|
||
export class PseudoClassesComponent extends React.Component<any> { | ||
static contextTypes = { theme: PropTypes.object }; | ||
context: { theme: ReactUWP.ThemeType }; | ||
|
||
render () { | ||
const { style, children, ...attributes } = this.props; | ||
|
||
if (style) { | ||
const { primaryObject, secondaryObject } = spreadObject(this.props, pseudoClassesNames); | ||
return ( | ||
<ElementState | ||
{...attributes} | ||
style={primaryObject} | ||
{...{ | ||
hoverStyle: secondaryObject["&:hover"], | ||
activeStyle: secondaryObject["&:active"], | ||
visitedStyle: secondaryObject["&:visited"], | ||
focusStyle: secondaryObject["&:focus"], | ||
disabledStyle: secondaryObject["&:disabled"] | ||
}} | ||
> | ||
{children} | ||
</ElementState> | ||
); | ||
} else { | ||
return ( | ||
<ElementState {...attributes}> | ||
{children} | ||
</ElementState> | ||
); | ||
} | ||
} | ||
} | ||
|
||
export default PseudoClassesComponent; |
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