Dtmf styling
This commit is contained in:
@@ -5,7 +5,7 @@ import Button from './Button/button';
|
|||||||
import DeviceState from './display-device-state';
|
import DeviceState from './display-device-state';
|
||||||
import DtmfButtons from './DtmfButtons/dtmf-buttons';
|
import DtmfButtons from './DtmfButtons/dtmf-buttons';
|
||||||
|
|
||||||
export default function Phone({voice:{ startDevice, answer, reject, hangup, dial, voiceState} }: {voice: Voice})
|
export default function Phone({voice:{ startDevice, answer, reject, hangup, dial, dtmf, voiceState} }: {voice: Voice})
|
||||||
{
|
{
|
||||||
if (voiceState.deviceState === "Offline")
|
if (voiceState.deviceState === "Offline")
|
||||||
{
|
{
|
||||||
@@ -31,8 +31,8 @@ export default function Phone({voice:{ startDevice, answer, reject, hangup, dial
|
|||||||
return (
|
return (
|
||||||
<div className="Phone">
|
<div className="Phone">
|
||||||
<DeviceState deviceState = {voiceState.deviceState}/>
|
<DeviceState deviceState = {voiceState.deviceState}/>
|
||||||
|
<DtmfButtons dtmf = {dtmf} />
|
||||||
<Button title = "hangup" onClick = {() => hangup()}/>
|
<Button title = "hangup" onClick = {() => hangup()}/>
|
||||||
<DtmfButtons/>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ export class MockConnection implements Connection
|
|||||||
|
|
||||||
public sendDigits(digits: string)
|
public sendDigits(digits: string)
|
||||||
{
|
{
|
||||||
|
console.log("Sending digit", digits);
|
||||||
}
|
}
|
||||||
|
|
||||||
public status(): ConnectionStatus
|
public status(): ConnectionStatus
|
||||||
|
|||||||
@@ -10,13 +10,13 @@ export interface Voice
|
|||||||
reject(): void;
|
reject(): void;
|
||||||
hangup(): void;
|
hangup(): void;
|
||||||
dial(phoneNumber: string): void;
|
dial(phoneNumber: string): void;
|
||||||
|
dtmf(digit: string): void;
|
||||||
voiceState: VoiceState;
|
voiceState: VoiceState;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function useVoice()
|
export default function useVoice()
|
||||||
{
|
{
|
||||||
const state = useVoiceState();
|
const state = useVoiceState();
|
||||||
console.log("Creating new voice");
|
|
||||||
|
|
||||||
const [device, setDevice] = useState<Device>();
|
const [device, setDevice] = useState<Device>();
|
||||||
const [connection, setConnection] = useState<Connection>();
|
const [connection, setConnection] = useState<Connection>();
|
||||||
@@ -83,12 +83,18 @@ export default function useVoice()
|
|||||||
setConnection(connection);
|
setConnection(connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const dtmf = (digit: string) =>
|
||||||
|
{
|
||||||
|
connection?.sendDigits(digit);
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
startDevice,
|
startDevice,
|
||||||
answer,
|
answer,
|
||||||
reject,
|
reject,
|
||||||
hangup,
|
hangup,
|
||||||
dial,
|
dial,
|
||||||
|
dtmf,
|
||||||
voiceState: state.voiceState,
|
voiceState: state.voiceState,
|
||||||
} as Voice;
|
} as Voice;
|
||||||
}
|
}
|
||||||
22
src/components/Phone/DtmfButtons/dtmf-buttons.module.css
Normal file
22
src/components/Phone/DtmfButtons/dtmf-buttons.module.css
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
.dtmf-button {
|
||||||
|
border-radius: 50%;
|
||||||
|
border: 1px solid black;
|
||||||
|
width: 70px;
|
||||||
|
height: 70px;
|
||||||
|
margin: 15px;
|
||||||
|
background-color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dtmf-button:hover {
|
||||||
|
background-color: lightgray;
|
||||||
|
}
|
||||||
|
|
||||||
|
.title {
|
||||||
|
font-size: 20px;
|
||||||
|
height: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sub-title {
|
||||||
|
font-size: 15px;
|
||||||
|
height: 15px;
|
||||||
|
}
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { chunk } from 'lodash';
|
import { chunk } from 'lodash';
|
||||||
|
import { Voice } from '../../../wrappers/voice';
|
||||||
|
import styles from './dtmf-buttons.module.css';
|
||||||
|
|
||||||
interface DtmfButton
|
interface DtmfButton
|
||||||
{
|
{
|
||||||
@@ -22,12 +24,16 @@ const buttons: DtmfButton[] = [
|
|||||||
{title: "#", subTitle: " "},
|
{title: "#", subTitle: " "},
|
||||||
];
|
];
|
||||||
|
|
||||||
export default function DtmfButtons() {
|
export default function DtmfButtons({dtmf}: {dtmf: Voice["dtmf"]}) {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
{ chunk(buttons, 3).map((buttonRow, rowIndex) =>
|
{ chunk(buttons, 3).map((buttonRow, rowIndex) =>
|
||||||
<div key={rowIndex}>
|
<div key={rowIndex}>
|
||||||
{ buttonRow.map(({title, subTitle}, index) => <button>{ title }</button>) }
|
{ buttonRow.map(({title, subTitle}, index) =>
|
||||||
|
<button key={title} className={styles["dtmf-button"]} onClick = {() => dtmf(title)}>
|
||||||
|
<div className={styles["title"]}>{ title }</div>
|
||||||
|
<div className={styles["sub-title"]}>{ subTitle }</div>
|
||||||
|
</button>) }
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user