This repository has been archived by the owner on Apr 27, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds component Block.Bordered. A simple component that provides a bordered block with the primary use-case to show text.
- Loading branch information
Showing
5 changed files
with
101 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import React, { PropTypes } from 'react' | ||
import compose from 'ramda/src/compose' | ||
import classNamesBind from 'classnames/bind' | ||
import childrenPropType from '../../propTypes/children' | ||
import defaultStyles from './styles.scss' | ||
import { | ||
overridable, | ||
themeable | ||
} from '@klarna/higher-order-components' | ||
|
||
const baseClass = 'block--bordered' | ||
|
||
function Bordered (props) { | ||
const { | ||
children, | ||
className, | ||
customize, | ||
style, | ||
styles, | ||
...remainingProps | ||
} = props | ||
const classNames = classNamesBind.bind({ ...defaultStyles, ...styles }) | ||
|
||
const customizations = customize | ||
? { | ||
borderRadius: customize.borderRadius | ||
} : {} | ||
|
||
return ( | ||
<div | ||
className={classNames(baseClass, className)} | ||
style={{ | ||
...customizations, | ||
...style | ||
}} | ||
{...remainingProps} | ||
> | ||
{children} | ||
</div> | ||
) | ||
} | ||
|
||
Bordered.displayName = 'Block.Bordered' | ||
|
||
Bordered.propTypes = { | ||
children: childrenPropType, | ||
className: PropTypes.string, | ||
id: PropTypes.string, | ||
styles: PropTypes.object | ||
} | ||
|
||
export default compose( | ||
themeable((customizations, {customize}) => ({ | ||
customize: { | ||
borderRadius: customizations.radius_border, | ||
...customize | ||
} | ||
})), | ||
overridable(defaultStyles) | ||
)(Bordered) |
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,14 @@ | ||
@import '../../css/settings'; | ||
@import '../../css/mixins/index'; | ||
|
||
.block--bordered { | ||
background: map-get($colors, white); | ||
border: ($grid * .2) solid $border-color; | ||
border-radius: $border-radius; | ||
box-sizing: border-box; | ||
display: block; | ||
margin: 0 auto; | ||
max-width: ($grid * 128); | ||
overflow: auto; | ||
padding: ($grid * 1.8) ($grid * 3); | ||
} |
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
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