can not reduce zurb foundation form input width - reactjs

I am new to Zurb Foundation, and using it in my React 16 project. And just not been able to reduce the width of the form-input and button within a component named CountdownForm.jsx. These two elements (form-input and button) are taking the entire width of the page. And I would like to keep them centred and 30% width.
Would highly appreciate any help.
I have the following code in my Main.jsx
var Main = (props) => {
return (
<div>
<Navigation/>
<div className="row">
<div className="column small-centered medium-6 large-4">
{props.children}
</div>
</div>
</div>
);
};
module.exports = Main;
And then in my child component named CountdownForm.jsx I have written as below
render: function () {
return (
<div>
<form ref="form" onSubmit={this.onSubmit} className="countdown-form">
<input type="text" ref="seconds" placeholder="Enter time in seconds"/>
<button className="button expanded">Start</button>
</form>
</div>
);
}
});
module.exports = CountdownForm;
I also have a file named _countdownForm.scss for styling the form and I have included the below in this file
.countdown-form {
width: 30%;
justify-content: center;
}
the width of the form-input was supposed to be set by foundation's grid system which I am defining in my Main.jsx (the below part)
<div className="row">
<div className="column small-centered medium-6 large-4">
{props.children}
</div>
I am using "foundation-sites": "6.4.4-rc1" and "react": "^16.0.0". The github of the project https://github.com/rohan-paul/ReactCountdownTimer

Never Mind.. Got it resolved..
I had to adjust the Countdown.jsx component to fix this, not the Main.jsx” ( and .coutdownForm CSS class defined in _countdownForm.scss had no impact at this point of the app in resolving this issue, as the centering of form-input was handled in the render section of the component Countdown.jsx )
So, I just changed Countdown.jsx as follows:
FROM
else {
return <CountdownForm onSetCountdown={this.handleSetCountdown}/>;
}
TO
else {
return (
<div className="grid-container">
<div className="cell small-centered medium-6 large-4">
<CountdownForm onSetCountdown={this.handleSetCountdown} />
</div>
</div>
);
https://github.com/rohan-paul/ReactCountdownTimer/blob/master/app/components/Countdown.jsx

Related

Flexbox can't use 'justify-content' horizontally in Reactive.js

I need some help with flexbox. I'm not able to evenly distribute all components in a row with 'justify-content' - the components only stay in a column. It seems that React does not consider the 2 components that were generated from props - it treats all as just one component.
App.js
const App=()=> {
return(
<>
<Header />
<div className="containerHeader">
<h1>RECEIVE THE BEST DENTAL TREATMENT TO AVOID CROOKED-TEETH PROBLEM</h1>
<h2>We will give you the accurate assessment to find out which braces best suit you.</h2>
</div>
{Data.map((values)=>{
return(
<>
<Meeting
key={values.id}
imgsrc={values.imgsrc}
text={values.text}
/>
</>
)
})}
</>
);
};
Meeting.js
const Meeting=(props)=> {
return(
<div className="containerMeeting">
<div className="containerCard">
<img src={props.imgsrc} alt="Girl" />
<p>{props.text}</p>
</div>
</div>
);
};
Meeting.css
.containerMeeting {
padding: 0px 20px;
display: flex;
flex-direction: row;
justify-content: space-between;
}
MeetingData.js
const Data=[
{
id:1,
imgsrc:"../Images/1.jpg ",
text:"Well-aligned teeth and fresher breath always leave a good impression when meeting a person for the first time."
},
{
id:2,
imgsrc:"../Images/2.jpg ",
text:"Even in a job interview your smile can lead to a favourable situation"
}
]
export default Data;
I hope that React considers the 2 components and distribute them horizontally.
"It seems that React does not consider the 2 components that were generated from props", there is only one containerCardelement inside the containerMeeting element. Thus nothing to align in a row.
When you map over Data what it will return will look like this
<div className="containerMeeting">
<div className="containerCard">
<img src="../Images/1.jpg " alt="Girl" />
<p>Well-aligned teeth and fresher breath always leave a good impression when meeting a person for the first time.</p>
</div>
</div>
<div className="containerMeeting">
<div className="containerCard">
<img src="../Images/2.jpg " alt="Girl" />
<p>Even in a job interview your smile can lead to a favourable situation</p>
</div>
</div>
If you want to make your containerCard elements appear in a row you should move the containerMeeting element out of the Meeting component and use it to surround Data.map
const Meeting = (props) => {
return (
<div className="containerCard">
<img src={props.imgsrc} alt="Girl" />
<p>{props.text}</p>
</div>
);
};
<div className="containerMeeting">
{Data.map((values) => {
return (
<Meeting key={values.id} imgsrc={values.imgsrc} text={values.text} />
);
})}
</div>

UI Kit Icon Not Rendering on Load

I have a nextjs blog that I'm working on and one of the components I'm using is this card component:
function Card(props) {
return (
<div className="uk-card uk-card-default uk-width-1-2#m">
<div className="uk-card-header">
<div
className="uk-grid-small uk-flex-middle"
uk-grid
uk-scrollspy="cls: uk-animation-slide-left; repeat: true"
>
<div className="uk-width-auto">
<Image
alt="Profile Picture"
className="uk-border-circle"
src={props.pic}
height={200}
width={200}
/>
</div>
<div className="uk-width-expand">
<h3 className="uk-card-title uk-margin-remove-bottom">
{props.name}
</h3>
</div>
</div>
</div>
<div className="uk-card-body">
<p>{props.description}</p>
</div>
<div className="uk-card-footer">
</div>
</div>
)
}
I take that component and use it in the page like so:
export default Main =()=> {
return(
<Card
pic={placeholderpic}
linkedin='https://www.linkedin.com/'
name="Harry Truman"
description="Lorem ipsum"
/>
)
}
The icon in the footer does not render until the page is refreshed 3-4 times. All the rest of the card renders properly on first load. Ideally I'd like to know 3 things:
A. Why this is occurring?
B. How to troubleshoot this in the future?
C. What the most appropriate fix is for this.
Edit:
This question is essentially the same as mine:
Uikit Icons with React and Next.js
The solution for me is less than ideal, I don't want to wrap everything in a custom "UIKit" component.

React Hover to display information but hidden before hover

This is my code so far
class PortfolioList extends Component{
render(){
const {column , styevariation } = this.props;
const list = PortfolioListContent.slice(0 , this.props.item);
return(
<React.Fragment>
{list.map((value , index) => (
<div className={`${column}`} key={index}>
<div className={`portfolio ${styevariation}`}>
<div className="thumbnail-inner">
<div className={`thumbnail ${value.image}`}></div>
<div className={`bg-blr-image ${value.image}`}></div>
</div>
<div className="content" >
<div className="inner">
<h3>{value.category}</h3>
<p>{value.title}</p>
<div className="portfolio-button">
<a className="rn-btn" href="/portfolio-details">Live</a>
</div>
<div className="portfolio-button">
<a className="rn-btn" href="/portfolio-details">GitHub</a>
</div>
</div>
</div>
</div>
</div>
))}
</React.Fragment>
)
}
}
This is displaying my portfolio section of my website I want to display the title of the each application and details only when i want to hover.
Also How can i make my buttons wrap next to each other? instead of taking up the new line?
Thank you
You can use onMouseEnter and onMouseLeave event to handle hovering. Bind a function to this event on title and keep a local boolean state shouldShowDetails with default value false. When the function is called, change this boolean to true and conditionally render the details.
For the second part, make your buttons container a flex and set flex-wrap to wrap.

How do you change content of page when the link is inside of the component?

Sorry in advance if I seem confused, it's because I am.
So from my App.js file which is like the main file where I call all my components and query my DB, which is then called by the index.js file.
this is my render method.
render() {
return (
<div className="site" >
{
!!!this.state.done ? (
<LoadingSVG />
) : (
<div className="page">
<div className="header-wrapper">
<Header data={this.state.dataHeader} />
</div>
<div className="project-list-wrapper">
<ProjectList data={this.state.dataProjects} />
</div>
</div>
)
}
</div >
)
}
Inside the Projectlist component I loop through every items and create a project.
render() {
return (
<div className="project-list module">
<div className="sectionTitle">Project I've worked on</div>
{this.props.data.map((res, i) => (
<div className="project-wrapper">
<div className="inner-ctn">
<div className="header">
<div className="number">0{res.id + 1}</div>
<div className="name">{res.nomProjet}</div>
</div>
<div className="item-ctn">
<div className="categ">{res.categProjet}</div>
<div className="roles">{res.roles}</div>
<div className="date">{res.date}</div>
</div>
</div>
</div>
))
}
</div>
);
}
What I want to do is with the use of transition-groups, render another component.. let's call it Project-1. Project 1 would refresh my App.js content so that the new component would render. But I can't do that since App.js is parent to ProjectList. I also want to keep a well structure project so I don't want to put everything in a single file..
I tried reading the documentation and basically every article about how to do this, I can't seem to wrap my mind around how this should work. This should be easy stuff, yet it's weirdly complicated to have a transition or even a link between two pages..

React not able to render an array(state) in a single row

The state
state = {
posts: [],
}
The posts gets an API value of
{
"authors": [
{
"authorName": "Sideney Sheldon",
"authorImageURL": "http..."
},
{
"authorName": "Sideney Sheldon",
"authorImageURL": "http..."
},
....
]
}
code
render(){
const postList = posts.length ? (
posts.map(post => {
return (
<div className="" key={this.state.key}>
<div className="containerimager">
<img style={imgb} src={post.authorImageURL} />
</div>
<h6 style={{ marginTop:"23px"}} >{post.authorName}</h6>
</div>
)
})
) :
(
<div className="center">No posts to show</div>
);
return(
{postList}
)
}
The {postlist} returns objects but it returns each object in a new row in the webpage
I want all the results(images) in the same row
can anyone please help?
If you want multiple elements in the same row, you could achieve that with css. Use display: flex(by default flex-direction is row which is what you need) on the wrapper to postList. You can either pass it as a style though JSX or add a class that specifies this property
render(){
const postList = posts.length ? (
posts.map(post => {
return (
<div className="" key={this.state.key}>
<div className="containerimager">
<img style={imgb} src={post.authorImageURL} />
</div>
<h6 style={{ marginTop:"23px"}} >{post.authorName}</h6>
</div>
)
})
) : (
<div className="center">No posts to show</div>
);
return(
<div style={{display: 'flex'}}>{postList}</div>
)
}
Here's a CodeSandbox sample I created using your code.
If you're trying to line up the users horizontally (from left to right), CSS is the way to go. In particular, the <div> that is being mapped has, by default, the display: block style which makes it occupy its own row in the page.
To line up divs side by side, you need to somehow apply the display: inline-block style. In my example I used a style prop, but you will likely want to do it in CSS directly.
This is a CSS problem, you should use display: flex together with flex-direction: row on the parent div which will provide the desired result.
posts.map(post,index => {
return (
<div className="" key={this.state.key}>
<div className="containerimager">
<img style={imgb} src={post.authors[index].authorImageURL} />
</div>
<h6 style={{ marginTop:"23px"}} >{post.authors[index].authorName}</h6>
</div>
)
})
) : (
<div className="center">No posts to show</div>
);
Try this

Resources