How do I change my twitter widget to have a responsive height

yotube
0

Issue

I am using react-twitter-widgets to embed a twitter timeline on my application. Currently, everything renders correctly, however, the timelines height stretches down the entire page. How do I get the widget height so that it only takes up the available view height? enter image description here

The underlying DOM structure for the main dashboard is:

<div className="col-md-9 ml-sm-auto col-lg-10 pt-2 px-3">
<div className="row">
<div className="col">
<TitleBar title={this.props.ticker} status={this.props.status}/>
</div>
</div>
<div className="row">
<div className="col-lg-8">
<div className="row">
<div className="col-lg-12 mb-2">
<div className="card border-0">
<div className="card-body">
<Chart chart={this.props.predictionChart} />
</div>
</div>
</div>
<div className="col-lg-6">
<div className="card border-0">
<div className="card-body">
<Chart chart={this.props.errorChart}/>
</div>
</div>
</div>
<div className="col-lg-6">
<div className="card border-0">
<div className="card-body">
<Chart chart={this.props.volumeChart} />
</div>
</div>
</div>
</div>
</div>
<div className="col-lg-4">
<TwitterCard href={this.props.twitter} ticker={this.props.ticker}/>
</div>
</div>
</div>

With the TwitterCard being in the following format:

import React from "react";
import { Timeline } from 'react-twitter-widgets';

export class TwitterCard extends React.Component{
constructor(props){
super();
this.state = {
ticker: props.ticker,
href: props.href
}
}
render() {
return (
<Timeline dataSource={{sourceType: 'URL', url: this.props.href}}/>
)
}
}

The main/only css file is as follows:

body {
font-size: .875rem;
background-color: #f7f7f7;
}

/*
* Title bar
*/
.title-bar {
padding-right: 15px;
}

/*
* Connection status
*/
#connection-status {
height: 20px;
width: 20px;
border-radius: 50%;
-webkit-border-radius: 50%;
display: block;
}

#connection-status.connected {
background-color: green;
}

#connection-status.disconnected {
background-color: red;
}

/*
* Sidebar
*/
.sidebar {
position: fixed;
top: 0;
bottom: 0;
left: 0;
z-index: 100; /* Behind the navbar */
padding: 0;
box-shadow: inset -1px 0 0 rgba(0, 0, 0, .1);
}

.sidebar-sticky {
position: sticky;
top: 48px; /* Height of navbar */
height: calc(100vh - 48px);
padding-top: .5rem;
overflow-x: hidden;
}

.sidebar .nav-link {
font-weight: 500;
color: #333;
}

.sidebar .nav-link{
margin-right: 4px;
color: #999;
}

.sidebar .nav-link.active {
color: #007bff;
}

.sidebar .nav-link:hover,
.sidebar .nav-link.active{
color: inherit;
}

.sidebar-heading {
font-size: .75rem;
text-transform: uppercase;
}

/*
* Navbar
*/
.navbar-brand {
padding-top: .75rem;
padding-bottom: .75rem;
font-size: 1rem;
background-color: rgba(0, 0, 0, .25);
box-shadow: inset -1px 0 0 rgba(0, 0, 0, .25);
}

.navbar .form-control {
padding: .75rem 1rem;
border-width: 0;
border-radius: 0;
}

.form-control-dark {
color: #fff;
background-color: rgba(255, 255, 255, .1);
border-color: rgba(255, 255, 255, .1);
}

.form-control-dark:focus {
border-color: transparent;
box-shadow: 0 0 0 3px rgba(255, 255, 255, .25);
}

.full-screen{
height: 100vh !important;
}

/*
* Utilities
*/
.border-top { border-top: 1px solid #e5e5e5; }
.border-bottom { border-bottom: 1px solid #e5e5e5; }

Solution

Please specify the JavaScript for rendering the widget. If it is same as below, you can adjust the height within the attribute.

ReactDOM.render((
<Timeline
dataSource={{
sourceType: 'profile',
screenName: 'twitterdev'
}}
options={{
username: 'TwitterDev',
height: '400'
}}
onLoad={() => console.log('Timeline is loaded!')}
/>


Answered By - kanwal019

Post a Comment

0Comments
Post a Comment (0)

#buttons=(Accept !) #days=(20)

Our website uses cookies to enhance your experience. Learn More
Accept !
To Top