diff --git a/shared/_tokenSnippet.jsx b/shared/_tokenSnippet.jsx index 621e5a1..cedd799 100644 --- a/shared/_tokenSnippet.jsx +++ b/shared/_tokenSnippet.jsx @@ -1,4 +1,5 @@ import React from 'react'; +import './tokenSnippet.css'; const BASE_URL = 'https://stream-calls-dogfood.vercel.app/api/call/sample?'; @@ -22,6 +23,7 @@ export class TokenSnippet extends React.Component { constructor(props) { super(props); this.state = { + loadingFinished: false, sampleApp: props.sampleApp, userId: 'Loading ...', userName: 'Creating user name ...', @@ -30,7 +32,7 @@ export class TokenSnippet extends React.Component { apiKey: 'Waiting for an API key ...', token: 'Token is generated ...', deepLink: 'Link is created ...', - displayStyle: props.displayStyle ?? 'full' + displayStyle: props.displayStyle ?? 'full', }; } @@ -38,115 +40,78 @@ export class TokenSnippet extends React.Component { callAPI(this.state.sampleApp).then((result) => { this.setState({ ...this.state, + loadingFinished: true, ...result, }); }); } render() { + const showTable = + this.state.displayStyle === 'full' || + this.state.displayStyle === 'credentials'; - const snippetStyle = { - padding: '2rem', - border: '2px solid #e3e3e3', - borderRadius: '1rem', - margin: '2rem 0', - }; - - const tableStyles = { - width: '100%', - overflowX: 'scroll', - }; - - const textStyle = { - display: 'inline-block', - marginBottom: '1rem', - }; - - const spanStyle = { - display: 'flex', - alignItems: 'center', - justifyContent: 'space-between', - }; - - const linkStyle = { - display: 'inline-block', - background: '#005fff', - color: 'white', - padding: '0.25rem 1rem', - borderRadius: '0.5rem', - }; - const labelColumnStyle = { - white_space: 'nowrap', - width: '120px' - } - const valueColumnStyle = { - width: '99%', - } - - const joinCallSpan = ( - - For testing you can join the call on our web-app:{' '} - - Join Call - - - - ); - - const credentialsTable = ( -
- - Here are credentials to try out the app with: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PropertyValue
API Key{this.state.apiKey}
Token{this.state.token}
User ID{this.state.userId}
Call ID{this.state.callId}
Call Type{this.state.callType}
- -
- ); + const showJoinLink = + this.state.displayStyle === 'full' || this.state.displayStyle === 'join'; return ( -
- { this.state.displayStyle === 'full' && credentialsTable } - { this.state.displayStyle === 'credentials' && credentialsTable } - - { this.state.displayStyle === 'full' && joinCallSpan } - { this.state.displayStyle === 'join' && joinCallSpan } +
+ {showTable && ( +
+

Here are credentials to try out the app with:

+ + + + + + + + + + + + + + + + + + + + + + + + + +
PropertyValue
API Key{this.state.apiKey}
Token + {this.state.token} + {this.state.loadingFinished && ( + + )} +
User ID{this.state.userId}
Call ID{this.state.callId}
+
+ )} + + {showJoinLink && ( + + For testing you can join the call on our web-app:{' '} + + Join Call + + + )}
); } diff --git a/shared/tokenSnippet.css b/shared/tokenSnippet.css new file mode 100644 index 0000000..6a0f784 --- /dev/null +++ b/shared/tokenSnippet.css @@ -0,0 +1,71 @@ +.snippetStyle { + padding: 2rem; + border: 2px solid #e3e3e3; + border-radius: 1rem; + margin: 2rem 0; +} + +.snippetStyle:not(:last-child) { + margin-bottom: 1rem; +} + +.snippetTable { + width: 100%; +} + +.snippetTable tr { + display: grid; + grid-template-columns: 120px 1fr; +} + +.tokenStyle { + width: 100%; + overflow-x: scroll; + display: grid; + grid-template-columns: 1fr auto; + gap: 1rem; +} + +.tokenStyle span { + overflow-x: hidden; + white-space: nowrap; + text-overflow: ellipsis; +} + +.tokenStyle button { + background: transparent; + border: 1px solid transparent; + border-radius: 0.25rem; + color: #005fff; + cursor: pointer; + font-weight: bold; + transition: all 200ms ease-in-out; +} + +.tokenStyle button:hover { + background: hsl(218, 100%, 30%); + color: white; +} + +.joinCallLink { + display: inline-block; + background: hsl(218, 100%, 50%); + color: white; + padding: 0.25rem 1rem; + border-radius: 0.5rem; + font-weight: bold; + transition: all 200ms ease-in-out; +} + +.joinCallRow { + display: flex; + align-items: center; + justify-content: space-between; +} + +.joinCallLink:hover { + background: hsl(218, 100%, 30%); + color: white; + text-decoration: none; + font-weight: bold; +}