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

Commit

Permalink
feat: make error box dismissable (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
vipin8169 authored May 14, 2020
1 parent 4685d66 commit eff3799
Showing 1 changed file with 36 additions and 13 deletions.
49 changes: 36 additions & 13 deletions src/Chat/components/Error.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,50 @@
import * as React from 'react'
import styled from 'styled-components'
import { ErrorInfo } from '../Twilio/api'
import { useState } from 'react'
import { UIButton } from './ChannelView'

import CloseIcon from 'feather-icons/dist/icons/x-square.svg'

const Header = styled.div`
background-color: #fa0000;
color: #ffffff;
font-weight: 300;
width: 100%;
button {
position: relative;
opacity: 0.75;
float: right;
margin-top: -0.25rem;
}
`

const Text = styled.p`
const Text = styled.div`
margin: 0;
padding: 0.5rem 0.5rem 0.5rem 1rem;
padding: 0.5rem 0.25rem 0.5rem 0.5rem;
`

export const Error = ({ type, message }: ErrorInfo) => (
<Header>
<Text>
<strong>{type}:</strong> {message}
<br />
<small>
UI version: <code>{GLOBAL_VERSION}</code>
</small>
</Text>
</Header>
)
export const Error = ({ type, message }: ErrorInfo) => {
const [visible, setVisible] = useState(true)
if (!visible) return null
else
return (
<Header>
<Text>
<UIButton
type="button"
onClick={() => {
setVisible(false)
}}
>
<CloseIcon />
</UIButton>
<strong>{type}:</strong> {message}
<br />
<small>
UI version: <code>{GLOBAL_VERSION}</code>
</small>
</Text>
</Header>
)
}

0 comments on commit eff3799

Please sign in to comment.