forked from keep-starknet-strange/joyboy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create dialog component (keep-starknet-strange#144)
* added dialogpage * added icons * added modal component * added dialog page * yarn formatted the code * fixed spelling error * removed the componenets to show the products working * added button props from button component and added current colr to colors * deleted the dialog page * removed linking to router * formatted page * yarn lint * made some fixes * yarn formatted code * Remove unused icons, fix props, fix button text --------- Co-authored-by: Uğur Eren <[email protected]>
- Loading branch information
1 parent
8841127
commit a82608b
Showing
3 changed files
with
143 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
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,61 @@ | ||
import React from 'react'; | ||
import {Portal} from 'react-native-portalize'; | ||
|
||
import {LineIcon} from '../../assets/icons'; | ||
import {Button} from '../button'; | ||
import { | ||
Container, | ||
Content, | ||
getButtonColor, | ||
getTextColor, | ||
IconContainer, | ||
ModalContainer, | ||
Overlay, | ||
Title, | ||
} from './styled'; | ||
|
||
export type ModalProps = { | ||
name: string; | ||
icon: React.ReactNode; | ||
description: string; | ||
visible: boolean; | ||
buttons: { | ||
label: string; | ||
type: 'primary' | 'secondary' | 'dangerous'; | ||
onPress: () => void; | ||
}[]; | ||
}; | ||
|
||
const Modal: React.FC<ModalProps> = ({name, icon, description, visible, buttons}) => { | ||
if (!visible) return null; | ||
|
||
return ( | ||
<Portal> | ||
<Overlay> | ||
<ModalContainer> | ||
<Container> | ||
<LineIcon color="#3C3C43" /> | ||
<IconContainer>{icon}</IconContainer> | ||
<Title>{name}</Title> | ||
<Content>{description}</Content> | ||
</Container> | ||
|
||
<Container> | ||
{buttons.map((button, index) => ( | ||
<Button | ||
key={index.toString()} | ||
onPress={button.onPress} | ||
style={{backgroundColor: getButtonColor(button.type)}} | ||
textStyle={{color: getTextColor(button.type)}} | ||
> | ||
{button.label} | ||
</Button> | ||
))} | ||
</Container> | ||
</ModalContainer> | ||
</Overlay> | ||
</Portal> | ||
); | ||
}; | ||
|
||
export default Modal; |
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,75 @@ | ||
import {Text, View} from 'react-native'; | ||
import styled from 'styled-components/native'; | ||
|
||
export const Overlay = styled(View)` | ||
flex: 1; | ||
justify-content: center; | ||
align-items: center; | ||
background-color: rgba(0, 0, 0, 0.5); | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
right: 0; | ||
bottom: 0; | ||
`; | ||
|
||
export const ModalContainer = styled(View)` | ||
width: 85%; | ||
display: flex; | ||
flex-direction: column; | ||
padding: 0 20px; | ||
background-color: white; | ||
border-radius: 10px; | ||
align-items: center; | ||
`; | ||
|
||
export const Container = styled(View)` | ||
flex-direction: column; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
padding-top: 20px; | ||
margin-bottom: 20px; | ||
`; | ||
|
||
export const Title = styled(Text)` | ||
font-size: 21px; | ||
font-weight: 700; | ||
line-height: 24px; | ||
margin-bottom: 12px; | ||
margin-top: 12px; | ||
`; | ||
export const IconContainer = styled(View)` | ||
margin-bottom: 10px; | ||
margin-top: 16px; | ||
`; | ||
|
||
export const Content = styled(Text)` | ||
font-size: 16px; | ||
text-align: center; | ||
color: #8f979e; | ||
`; | ||
|
||
export const getButtonColor = (type: string) => { | ||
switch (type) { | ||
case 'dangerous': | ||
return '#0C0C4F'; | ||
case 'primary': | ||
return '#EC796B'; | ||
case 'secondary': | ||
return '#0c0c4f1a'; | ||
default: | ||
return '#ccc'; | ||
} | ||
}; | ||
|
||
export const getTextColor = (type: string) => { | ||
switch (type) { | ||
case 'dangerous': | ||
return '#ffff'; | ||
case 'primary': | ||
return '#fff'; | ||
case 'secondary': | ||
return '#14142C'; | ||
} | ||
}; |