Skip to content
This repository has been archived by the owner on Oct 13, 2020. It is now read-only.

[feat] Name Card Component Closes #45 #53

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 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
3 changes: 3 additions & 0 deletions packages/react-silk-docs/src/components/Anchors.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,8 @@ export default () => (
<NavItem>
<Link to="/components/input_pins">Input Pins</Link>
</NavItem>
<NavItem>
<Link to="/components/namecard">Name Card</Link>
</NavItem>
</NavItems>
)
30 changes: 30 additions & 0 deletions packages/react-silk-docs/src/demo/NameCardDemo.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import * as React from 'react'
import { NameCard } from 'react-silk-ui'
import styled from 'styled-components'

const NameCardWrapper = styled.div`
display: flex;
> div > div {
margin-bottom: 0.5rem;
}
`

export default () => (
<div>
<NameCardWrapper>
<div>
<NameCard
image="https://vnn-imgs-f.vgcloud.vn/2018/04/12/17/bill-gates-la-nguoi-dan-ong-duoc-nguong-mo-nhat-the-gioi.jpg"
title="Bill Gate"
subTitle="[email protected]"
/>
<NameCard
image="https://media.laodong.vn/storage/newsportal/2018/9/28/633320/CEO-Facebook.jpg"
title="Mark Zuckerberg"
subTitle="[email protected]"
rtl={true}
/>
</div>
</NameCardWrapper>
</div>
)
9 changes: 9 additions & 0 deletions packages/react-silk-docs/src/pages/components/namecard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import * as React from 'react'
import MyMom from '.'
import NameCardDemo from '../../demo/NameCardDemo'

export default () => (
<MyMom>
<NameCardDemo />
</MyMom>
)
89 changes: 89 additions & 0 deletions packages/react-silk-ui/src/components/NameCard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import * as React from 'react'
import { View, Image, StyleSheet, Dimensions } from 'react-native'
import { Text } from './Text'
import Colors from './Colors'

const styles = StyleSheet.create({
container: {
flex: 1,
paddingVertical: 30,
paddingHorizontal: 10,
backgroundColor: Colors.white,
flexDirection: 'row',
borderWidth: 1,
borderRadius: 2,
borderColor: Colors.smokeWhite,
borderBottomWidth: 0,
shadowColor: Colors.gray,
shadowOffset: { width: 0, height: 1 },
shadowOpacity: 0.5,
shadowRadius: 2,
elevation: 1,
},
imageWrapper: {
flex: 3,
},
contentWrapper: {
flex: 7,
},
image: {
width: '100%',
phongpv marked this conversation as resolved.
Show resolved Hide resolved
height: '100%',
},
title: {
fontSize: 20,
color: Colors.dark,
fontWeight: '500',
},
subTitle: {
fontSize: 16,
color: Colors.gray,
},
})

export interface Props {
image?: string
title: string
subTitle?: string
rtl?: boolean
}

export const NameCard = ({ image, title, subTitle, rtl }: Props) => {
return (
<View style={{ flex: 1 }}>
phongpv marked this conversation as resolved.
Show resolved Hide resolved
{rtl ? (
phongpv marked this conversation as resolved.
Show resolved Hide resolved
<View style={styles.container}>
<View style={[styles.contentWrapper, { paddingRight: 10 }]}>
<Text style={styles.title}>{title}</Text>
<Text style={styles.subTitle}>{subTitle}</Text>
</View>
<View style={styles.imageWrapper}>
<Image
style={styles.image}
resizeMode="contain"
source={{ uri: image }}
/>
</View>
</View>
) : (
<View style={styles.container}>
<View style={styles.imageWrapper}>
<Image
style={styles.image}
resizeMode="contain"
source={{ uri: image }}
/>
</View>
<View style={[styles.contentWrapper, { paddingLeft: 10 }]}>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nếu mà xài nhiều thì làm ra cái style paddingLeft10, paddingRight10.. kiểu utilities trong bootstrap ý ý

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cái này e làm ko biết đúng hay ko a @hieuhani check nhé

<Text style={styles.title}>{title}</Text>
<Text style={styles.subTitle}>{subTitle}</Text>
phongpv marked this conversation as resolved.
Show resolved Hide resolved
</View>
</View>
)}
</View>
)
}

NameCard.defaultProps = {
rtl: false,
}
3 changes: 3 additions & 0 deletions packages/react-silk-ui/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { DropdownItem } from './components/Dropdown/Item'
import { Carousel } from './components/Carousel'
import * as Colors from './components/Colors'
import { InputPin } from './components/InputPin'
import { NameCard } from './components/NameCard'

export {
Text,
Expand All @@ -39,6 +40,7 @@ export {
DropdownItem,
Carousel,
InputPin,
NameCard,
}

export default {
Expand All @@ -61,4 +63,5 @@ export default {
DropdownItem,
Carousel,
InputPin,
NameCard,
}