Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow to specify button's mode in CardAction #3276

Merged
merged 1 commit into from
Aug 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/components/Card/CardActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ const CardActions = (props: Props) => {
return React.isValidElement(child)
? React.cloneElement(child, {
compact: !isV3 && child.props.compact !== false,
mode: isV3 && (i === 0 ? 'outlined' : 'contained'),
mode:
child.props.mode ||
(isV3 && (i === 0 ? 'outlined' : 'contained')),
style: isV3 && styles.button,
})
: child;
Expand Down
17 changes: 17 additions & 0 deletions src/components/__tests__/Card/Card.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import renderer from 'react-test-renderer';
import { render } from 'react-native-testing-library';
import color from 'color';
import Card from '../../Card/Card';
import Button from '../../Button/Button';
import { black, white } from '../../../styles/themes/v2/colors';
import { getCardColors } from '../../Card/utils';
import { getTheme } from '../../../core/theming';
Expand All @@ -29,6 +30,22 @@ describe('Card', () => {
});
});

describe('CardActions', () => {
it('renders button with passed mode', () => {
const { getByTestId } = render(
<Card>
<Card.Actions>
<Button mode="contained" testID="card-action-button">
Agree
</Button>
</Card.Actions>
</Card>
);

expect(getByTestId('card-action-button').props.mode).toBe('contained');
});
});

describe('getCardColors - background color', () => {
it('should return correct theme color, for theme version 3, contained mode', () => {
expect(
Expand Down