-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(AdaptiveCardsFactSet): create FactSet component
- Loading branch information
1 parent
61744e1
commit cd7e0ec
Showing
6 changed files
with
216 additions
and
30 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
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,53 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import webexComponentClasses from '../../helpers'; | ||
import {acPropTypes, registerComponent} from '../Component/Component'; | ||
|
||
/** | ||
* Adaptive Cards FactSet component | ||
* https://adaptivecards.io/explorer/FactSet.html | ||
* | ||
* @param {object} props React props passed to the component | ||
* @param {object} props.data Active cards definition | ||
* @param {string} [props.className] Custom CSS class to apply | ||
* @returns {object} JSX of the component | ||
*/ | ||
export default function FactSet({data, className}) { | ||
const [cssClasses, sc] = webexComponentClasses('adaptive-cards-fact-set', className); | ||
|
||
return ( | ||
<div className={cssClasses}> | ||
<table> | ||
<tbody> | ||
{data.facts.map((fact, index) => ( | ||
// eslint-disable-next-line react/no-array-index-key | ||
<tr key={index}> | ||
<th className={sc('fact-title')}>{fact.title}</th> | ||
<td>{fact.value}</td> | ||
</tr> | ||
))} | ||
</tbody> | ||
</table> | ||
</div> | ||
); | ||
} | ||
|
||
FactSet.propTypes = { | ||
data: PropTypes.shape().isRequired, | ||
className: PropTypes.string, | ||
}; | ||
|
||
FactSet.defaultProps = { | ||
className: '', | ||
}; | ||
|
||
FactSet.acPropTypes = { | ||
facts: acPropTypes.children, | ||
id: acPropTypes.id, | ||
isVisible: acPropTypes.isVisible, | ||
separator: acPropTypes.separator, | ||
spacing: acPropTypes.spacing, | ||
type: acPropTypes.type, | ||
}; | ||
|
||
registerComponent('FactSet', FactSet); |
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,8 @@ | ||
$C: #{$WEBEX_COMPONENTS_CLASS_PREFIX}-adaptive-cards-fact-set; | ||
|
||
.#{$C} { | ||
.#{$C}__fact-title { | ||
padding-right: 0.5rem; | ||
text-align: left; | ||
} | ||
} |
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,3 +1,4 @@ | ||
@import 'AdaptiveCard/AdaptiveCard'; | ||
@import 'Component/Component'; | ||
@import 'ImageSet/ImageSet'; | ||
@import 'FactSet/FactSet'; |