-
Notifications
You must be signed in to change notification settings - Fork 306
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
66 additions
and
1 deletion.
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
60 changes: 60 additions & 0 deletions
60
petstore/petstoreapp/soulmachines-react-app/src/components/ContentCards/ButtonWithImage.js
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 from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import styled from 'styled-components'; | ||
|
||
function ButtonWithImage({ data, className }) { | ||
const { | ||
title, imageUrl, description, imageAltText, buttonText, | ||
} = data; | ||
return ( | ||
<div className={className}> | ||
<div className="card"> | ||
<div className="d-flex justify-content-center"> | ||
<img src={imageUrl} alt={imageAltText || description} /> | ||
</div> | ||
<div className="card-body"> | ||
<h5>{title}</h5> | ||
<p>{description}</p> | ||
<div className="d-flex justify-content-center"> | ||
{/* open ButtonWithImage in new tab */} | ||
<button type="button"> | ||
{buttonText} | ||
</button> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
ButtonWithImage.propTypes = { | ||
data: PropTypes.objectOf({ | ||
title: PropTypes.string.isRequired, | ||
imageUrl: PropTypes.string.isRequired, | ||
description: PropTypes.string.isRequired, | ||
imageAltText: PropTypes.string, | ||
buttonText: PropTypes.string, | ||
}).isRequired, | ||
className: PropTypes.string.isRequired, | ||
}; | ||
|
||
export default styled(ButtonWithImage)` | ||
width: 20rem; | ||
img { | ||
width: 100%; | ||
height: auto; | ||
} | ||
`; | ||
|
||
// { | ||
// "type": "buttonWithImage", | ||
// "id": "buttonWithImage", | ||
// "data": { | ||
// "title": "Soul Machines", | ||
// "imageUrl": "https://www.soulmachines.com/wp-content/uploads/cropped-sm-favicon-180x180.png", | ||
// "description":"Soul Machines is the leader in astonishing AGI", | ||
// "imageAltText": "some text", | ||
// "buttonText": "push me" | ||
// } | ||
// } |
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