-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add new ButtonCard component (#961)
* feat: add new button-card component * feat(components-demo): add button-card examples * style(card): remove unused class * feat(dashboard): rework wizard using button-card * feat: improve button-card is-small style and add support for chevron * fix: typo
- Loading branch information
1 parent
8347362
commit eff9edf
Showing
8 changed files
with
274 additions
and
135 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,49 @@ | ||
/** | ||
* Button Card | ||
*/ | ||
|
||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { Component } from '@wordpress/element'; | ||
import { Icon, chevronRight } from '@wordpress/icons'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import './style.scss'; | ||
|
||
/** | ||
* External dependencies | ||
*/ | ||
import classnames from 'classnames'; | ||
|
||
class ButtonCard extends Component { | ||
/** | ||
* Render | ||
*/ | ||
render() { | ||
const { chevron, className, desc, grouped, icon, isSmall, title, ...otherProps } = this.props; | ||
const classes = classnames( | ||
'newspack-button-card', | ||
className, | ||
chevron && 'has-chevron', | ||
grouped && 'grouped', | ||
icon && 'has-icon', | ||
isSmall && 'is-small' | ||
); | ||
|
||
return ( | ||
<a className={ classes } { ...otherProps }> | ||
{ icon && <Icon icon={ icon } height={ 48 } width={ 48 } /> } | ||
<div> | ||
{ title && <div className="title">{ title }</div> } | ||
{ desc && <div className="desc">{ desc }</div> } | ||
</div> | ||
{ chevron && <Icon icon={ chevronRight } height={ 24 } width={ 24 } /> } | ||
</a> | ||
); | ||
} | ||
} | ||
|
||
export default ButtonCard; |
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,140 @@ | ||
/** | ||
* Button Card | ||
*/ | ||
|
||
@import '../../../shared/scss/colors'; | ||
@import '~@wordpress/base-styles/colors'; | ||
|
||
.newspack-button-card { | ||
border-radius: 3px; | ||
border: 1px solid $light-gray-500; | ||
box-shadow: inset 0 0 0 2px transparent; | ||
cursor: pointer; | ||
display: block; | ||
margin: 32px 0; | ||
padding: 32px; | ||
text-decoration: none; | ||
transition: background-color 125ms ease-in-out, border-color 125ms ease-in-out, | ||
box-shadow 125ms ease-in-out; | ||
|
||
&:active, | ||
&:focus, | ||
&:hover { | ||
background-color: $light-gray-100; | ||
color: $primary-600; | ||
text-decoration: none; | ||
|
||
.title, | ||
.desc { | ||
color: inherit; | ||
} | ||
} | ||
|
||
&:focus { | ||
border-color: $primary-500; | ||
box-shadow: inset 0 0 0 2px $primary-500 !important; | ||
outline: none !important; | ||
position: relative; | ||
} | ||
|
||
.title, | ||
.desc { | ||
line-height: 24px; | ||
transition: color 125ms ease-in-out; | ||
} | ||
|
||
.title { | ||
color: $dark-gray-900; | ||
font-size: 17px; | ||
font-weight: bold; | ||
} | ||
|
||
.desc { | ||
color: $dark-gray-300; | ||
font-size: 14px; | ||
} | ||
|
||
// Grouped | ||
|
||
&.grouped { | ||
border-radius: 0; | ||
|
||
& + &:not( .br--top ) { | ||
margin-top: -33px; | ||
} | ||
|
||
&.br--bottom { | ||
border-bottom-left-radius: 3px; | ||
border-bottom-right-radius: 3px; | ||
} | ||
|
||
&.br--top { | ||
border-top-left-radius: 3px; | ||
border-top-right-radius: 3px; | ||
} | ||
} | ||
|
||
// Chevron & Icon | ||
|
||
&.has-chevron, | ||
&.has-icon { | ||
align-items: center; | ||
display: grid; | ||
grid-gap: 16px; | ||
grid-template-columns: auto 24px; | ||
|
||
&:active, | ||
&:focus, | ||
&:hover { | ||
svg { | ||
fill: currentColor; | ||
} | ||
} | ||
|
||
svg { | ||
fill: $primary-500; | ||
transition: fill 125ms ease-in-out; | ||
} | ||
} | ||
|
||
&.has-icon { | ||
grid-template-columns: 48px auto; | ||
|
||
&.has-chevron { | ||
grid-template-columns: 48px auto 24px; | ||
} | ||
} | ||
|
||
// Is Small | ||
|
||
&.is-small { | ||
padding: 16px; | ||
|
||
&.has-chevron, | ||
&.has-icon { | ||
grid-gap: 8px; | ||
|
||
svg { | ||
height: 24px; | ||
width: 24px; | ||
} | ||
} | ||
|
||
&.has-icon { | ||
grid-template-columns: 24px auto; | ||
|
||
&.has-chevron { | ||
grid-template-columns: 24px auto 24px; | ||
} | ||
} | ||
|
||
.title { | ||
font-size: 14px; | ||
} | ||
|
||
.desc { | ||
font-size: 12px; | ||
line-height: 16px; | ||
} | ||
} | ||
} |
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
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
Oops, something went wrong.