Skip to content
This repository was archived by the owner on Jul 1, 2024. It is now read-only.

Commit a1f143a

Browse files
authored
Merge pull request #13 from stellar/feature/component/card
Feature/component/card
2 parents 5c37da3 + ca162aa commit a1f143a

File tree

8 files changed

+109
-4
lines changed

8 files changed

+109
-4
lines changed

Diff for: README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ To use other components, you need to explicity import them. Reference on
2121
<!-- prettier-ignore -->
2222
````jsx
2323
// ```jsx inside Panel/Readme.md or Panel.md
24-
import { all } from 'dog-names'
25-
import { RandomButton } from '../RandomButton'
26-
;<RandomButton variants={all} />
24+
import { all } from 'dog-names';
25+
import { RandomButton } from '../RandomButton';
26+
<RandomButton variants={all} />
2727
````
2828

2929
## Merging in changes

Diff for: src/components/Card.js

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import * as React from "react";
2+
import styled from "styled-components";
3+
import PropTypes from "prop-types";
4+
5+
import { PALETTE } from "../shared";
6+
7+
import Text from "./Text";
8+
import SubsectionHeader from "./SubsectionHeader";
9+
10+
const CardEl = styled.div`
11+
display: flex;
12+
flex-direction: column;
13+
padding: 2rem;
14+
border-radius: 4px;
15+
border: solid 1px ${PALETTE.white80};
16+
box-shadow: 0 8px 16px -8px rgba(19, 12, 51, 0.08);
17+
18+
${SubsectionHeader} {
19+
margin-bottom: 0.5rem;
20+
}
21+
22+
img {
23+
display: block;
24+
overflow: hidden;
25+
width: 3rem;
26+
height: 3rem;
27+
border-radius: 50%;
28+
margin-bottom: 1.5rem;
29+
}
30+
`;
31+
32+
/**
33+
* Note: This exports a React component instead of a styled-component.
34+
* [Design Mockup](https://app.zeplin.io/project/5d5aecf2918cf74d46363015/screen/5d813f575d1398783f61df5b)
35+
*/
36+
37+
const Card = React.forwardRef(function Card(
38+
{ title, icon, children, ...props },
39+
ref,
40+
) {
41+
return (
42+
<CardEl ref={ref} {...props}>
43+
{icon && <img src={icon} alt={title} />}
44+
<SubsectionHeader color={PALETTE.black60}>{title}</SubsectionHeader>
45+
<Text>{children}</Text>
46+
</CardEl>
47+
);
48+
});
49+
50+
Card.propTypes = {
51+
/**
52+
* The title of the card
53+
*/
54+
title: PropTypes.node.isRequired,
55+
/**
56+
* The icon of the card. @TODO
57+
*/
58+
icon: PropTypes.string,
59+
/**
60+
* The copy of the card
61+
*/
62+
children: PropTypes.node.isRequired,
63+
};
64+
65+
/** @component */
66+
export default Card;

Diff for: src/components/Card.md

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
Card with an icon
2+
3+
```jsx
4+
<Card title="Issue assets" icon="https://via.placeholder.com/48/999999">
5+
Start building on the most powerful payment network today.
6+
</Card>
7+
```
8+
9+
Card without an icon
10+
11+
```jsx
12+
<Card title="Digital Asset Stack">
13+
Understand how the Stellar node software (Core), API (Horizon), and ecosystem
14+
standards (Stellar Ecosystem Proposals, or SEPs) work together to help you
15+
issue interoperable assets.
16+
</Card>
17+
```

Diff for: src/components/SubsectionHeader.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const SubsectionHeader = styled.h3`
55
font-size: 1.125rem;
66
line-height: 1.5;
77
font-weight: normal;
8-
color: ${PALETTE.black};
8+
color: ${(props) => (props.color ? props.color : PALETTE.black)};
99
margin: 0;
1010
`;
1111

Diff for: src/components/Text.js

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import styled from "styled-components";
2+
import { PALETTE } from "../shared";
3+
4+
const Text = styled.p`
5+
font-size: 1rem;
6+
line-height: 1.75;
7+
font-weight: normal;
8+
color: ${PALETTE.black60};
9+
margin: 0;
10+
`;
11+
12+
/** @component */
13+
export default Text;

Diff for: src/components/Text.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```jsx
2+
<Text>I am a paragraph tag.</Text>
3+
```

Diff for: src/shared.js

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export const FONT_WEIGHT = {
1212

1313
export const PALETTE = {
1414
white: "#ffffff",
15+
white80: "#fafafa",
1516
black: "#000000",
1617
black30: "#999999",
1718
black60: "#666666",

Diff for: styleguide.config.js

+5
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,18 @@ module.exports = {
1313
"src/components/PageHeader.js",
1414
"src/components/SectionHeader.js",
1515
"src/components/SubsectionHeader.js",
16+
"src/components/Text.js",
1617
],
18+
usageMode: "expand",
1719
},
1820
{
1921
name: "Components",
2022
components: () => [
2123
"src/components/BulletedList.js",
2224
"src/components/Button.js",
25+
"src/components/Card.js",
2326
],
27+
usageMode: "expand",
2428
},
2529
{
2630
name: "Form",
@@ -30,6 +34,7 @@ module.exports = {
3034
"src/components/Select.js",
3135
"src/components/Textarea.js",
3236
],
37+
usageMode: "expand",
3338
},
3439
],
3540
},

0 commit comments

Comments
 (0)