Skip to content

Commit

Permalink
feat(AdaptiveCardsComponent): add default props for adaptive cards
Browse files Browse the repository at this point in the history
  • Loading branch information
CoroDaniel authored and cipak committed Dec 21, 2021
1 parent bfba17b commit 222fd98
Show file tree
Hide file tree
Showing 9 changed files with 280 additions and 243 deletions.

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions src/components/adaptive-cards/Column/Column.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,8 @@ Column.acPropTypes = {
verticalContentAlignment: acPropTypes.verticalContentAlignment,
};

Column.acDefaultProps = {
verticalContentAlignment: 'top',
};

registerComponent('Column', Column, 'vertical');
4 changes: 4 additions & 0 deletions src/components/adaptive-cards/ColumnSet/ColumnSet.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,8 @@ ColumnSet.acPropTypes = {
type: acPropTypes.type,
};

ColumnSet.acDefaultProps = {
horizontalAlignment: 'left',
};

registerComponent('ColumnSet', ColumnSet, 'horizontal');
4 changes: 3 additions & 1 deletion src/components/adaptive-cards/Component/Component.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ export default function Component({data}) {
const getClass = (propType, value) => `wxc-ac-${propType}--${value}`;
const style = {};

for (const [prop, value] of Object.entries(data)) {
const dataWithDefaults = {...C.acDefaultProps, ...data};

for (const [prop, value] of Object.entries(dataWithDefaults)) {
const propType = (C.acPropTypes && C.acPropTypes[prop]) || undefined;

switch (propType) {
Expand Down
4 changes: 4 additions & 0 deletions src/components/adaptive-cards/Container/Container.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,8 @@ Container.acPropTypes = {
verticalContentAlignment: acPropTypes.verticalContentAlignment,
};

Container.acDefaultProps = {
verticalContentAlignment: 'top',
};

registerComponent('Container', Container, 'vertical');
5 changes: 5 additions & 0 deletions src/components/adaptive-cards/Image/Image.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,9 @@ Image.acPropTypes = {
style: acPropTypes.imageStyle,
};

Image.acDefaultProps = {
horizontalAlignment: 'left',
size: 'medium',
};

registerComponent('Image', Image);
4 changes: 2 additions & 2 deletions src/components/adaptive-cards/ImageSet/ImageSet.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ export default function ImageSet({data, className}) {
return (
<div className={cssClasses}>
{/* eslint-disable react/no-array-index-key */}
{data.images.map((item, index) => {
const itemData = {size: item.size || data.imageSize || 'medium', ...item};
{data.images.map((image, index) => {
const itemData = {size: data.imageSize, ...image};

return (
<Component data={itemData} key={index} />
Expand Down
16 changes: 15 additions & 1 deletion src/components/adaptive-cards/RichTextBlock/RichTextBlock.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import webexComponentClasses from '../../helpers';
import Component, {registerComponent} from '../Component/Component';
import Component, {acPropTypes, registerComponent} from '../Component/Component';

/**
* Adaptive Cards RichTextBlock component
Expand Down Expand Up @@ -40,4 +40,18 @@ RichTextBlock.defaultProps = {
className: '',
};

RichTextBlock.acPropTypes = {
horizontalAlignment: acPropTypes.horizontalAlignment,
id: acPropTypes.id,
inlines: acPropTypes.children,
isVisible: acPropTypes.isVisible,
separator: acPropTypes.separator,
spacing: acPropTypes.spacing,
type: acPropTypes.type,
};

RichTextBlock.acDefaultProps = {
horizontalAlignment: 'left',
};

registerComponent('RichTextBlock', RichTextBlock);
4 changes: 4 additions & 0 deletions src/components/adaptive-cards/TextBlock/TextBlock.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,8 @@ TextBlock.acPropTypes = {
wrap: acPropTypes.wrap,
};

TextBlock.acDefaultProps = {
horizontalAlignment: 'left',
};

registerComponent('TextBlock', TextBlock);

0 comments on commit 222fd98

Please sign in to comment.