Skip to content

Commit 80842b8

Browse files
authored
Merge pull request #78 from topcoder-platform/PROD-1111_cards
PROD-1111 card component - PROD-1069_re-style
2 parents f6495d1 + 74abe22 commit 80842b8

File tree

10 files changed

+50
-36
lines changed

10 files changed

+50
-36
lines changed

src/lib/styles/_cards.scss renamed to src/lib/card/Card.module.scss

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
@import './palette';
2-
@import './typography';
1+
@import '../styles';
32

43
.card {
5-
padding: 16px 16px 32px 16px;
6-
border: solid 1px $black-10;
7-
border-radius: 8px;
4+
padding: $pad-lg $pad-lg $pad-xxxxl $pad-lg;
5+
border: solid $border-xs $black-10;
6+
border-radius: $pad-sm;
87

98
.card-title {
109
@include font-weight-semi-bold;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import '@testing-library/jest-dom'
22

3-
describe('<Button />', () => {
3+
describe('<Card />', () => {
44

55
test('it should render the content', () => { })
66
})

src/lib/card/Card.tsx

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { FC, ReactNode, SVGProps } from 'react'
2+
3+
import styles from './Card.module.scss'
4+
5+
export interface CardProps {
6+
children: ReactNode
7+
icon?: FC<SVGProps<SVGSVGElement>>
8+
title: string
9+
}
10+
11+
const Card: FC<CardProps> = (props: CardProps) => {
12+
13+
const Icon: FC<SVGProps<SVGSVGElement>> | undefined = props.icon
14+
15+
return (
16+
<div className={styles.card}>
17+
18+
<div className={styles['card-title']}>
19+
<div>
20+
{props.title}
21+
</div>
22+
{!!Icon && <Icon />}
23+
</div>
24+
25+
{props.children}
26+
27+
</div>
28+
)
29+
}
30+
31+
export default Card

src/lib/card/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default as Card } from './Card'

src/lib/content-layout/ContentLayout.module.scss

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@
77
grid-template-columns: 1fr;
88
justify-content: center;
99

10-
@include xxl {
11-
padding: 0;
12-
}
13-
1410
@include md {
1511
padding: 0 $pad-xxl;
1612
}

src/lib/form/form-input/form-field-wrapper/FormFieldWrapper.module.scss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
@import '../../../styles';
22

33
$form-pad-top: calc($pad-md - $border);
4-
$border-xs: 1px;
54
$error-line-height: 14px;
65

76
.form-field-wrapper {

src/lib/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export * from './avatar'
22
export * from './button'
3+
export * from './card'
34
export * from './content-layout'
45
export * from './form'
56
export * from './global-config.model'

src/lib/styles/_layout.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ $left-col-width-xl: calc(1.3 * $header-height);
88
/* TODO: determine which UI library to use and replace below */
99

1010
/* Padding */
11+
$border-xs: 1px;
1112
$border: 2px;
1213
$pad-xs: calc(2 * $border); // 4
1314
$pad-sm: calc(2 * $pad-xs); // 8

src/lib/styles/index.scss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
@import 'breakpoints';
44
@import 'buttons';
5-
@import 'cards';
65
@import 'fonts';
76
@import 'icons';
87
@import 'layout';

src/utils/settings/Settings.tsx

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
authUrlLogin,
99
Avatar,
1010
Button,
11+
Card,
1112
ContentLayout,
1213
IconOutline,
1314
profileContext,
@@ -74,52 +75,38 @@ const Settings: FC<{}> = () => {
7475

7576
<div className={styles['page-content']}>
7677

77-
<div className='card'>
78-
79-
<div className='card-title'>
80-
<div>
81-
Basic Information
82-
</div>
83-
<IconOutline.UserIcon />
84-
</div>
85-
78+
<Card
79+
icon={IconOutline.UserIcon}
80+
title='Basic Information'
81+
>
8682
<Button
8783
label='edit'
8884
onClick={toggleEditProfile}
8985
tabIndex={1}
9086
buttonStyle='link'
9187
/>
92-
93-
</div>
88+
</Card>
9489

9590
<Modal
96-
center
9791
open={editProfileOpen}
9892
onClose={toggleEditProfile}
9993
>
10094
<ProfileUpdate onClose={toggleEditProfile} />
10195
</Modal>
10296

103-
<div className='card'>
104-
105-
<div className='card-title'>
106-
<div>
107-
Reset Password
108-
</div>
109-
<IconOutline.LockClosedIcon />
110-
</div>
111-
97+
<Card
98+
icon={IconOutline.LockClosedIcon}
99+
title='Reset Password'
100+
>
112101
<Button
113102
label='edit'
114103
onClick={toggleResetPassword}
115104
tabIndex={2}
116105
buttonStyle='link'
117106
/>
118-
119-
</div>
107+
</Card>
120108

121109
<Modal
122-
center
123110
open={resetPasswordOpen}
124111
onClose={toggleResetPassword}
125112
>

0 commit comments

Comments
 (0)