Skip to content

Commit

Permalink
Fetched data from json and rendered in list
Browse files Browse the repository at this point in the history
  • Loading branch information
nashvail committed Oct 21, 2016
1 parent 0c6c4c3 commit d994ae0
Show file tree
Hide file tree
Showing 30 changed files with 200 additions and 26 deletions.
Binary file modified .sass-cache/17d2fd42d2a8b8246274bfafbcb6155d7a2357dd/_App.scssc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified .sass-cache/a6eaa19a82fe0ae3c0fcc97867972db8213ead42/main.scssc
Binary file not shown.
15 changes: 7 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,15 @@ Compiles SASS into `public/css/main.css`.
Edit the `public/data.json` file in accordance with the following format.
```javascript
{
'name': 'Name of the company',
'location': {
'city': 'City',
'country': 'Country'
"name": "Name of the company",
"location": {
"city": "City",
"country": "Country"
},
'openings': [
"openings": [
{
'role': 'Name of the role',
'applyLink': 'Link to apply for the role' // Could be a :mailto
"role": "Name of the role",
"applyLink": "Link to apply for the role (could be a :mailto link)"
}
]
}
`
2 changes: 1 addition & 1 deletion public/css/main.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 36 additions & 0 deletions public/data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
[
{
"name": "Razorpay",
"location": {
"city": "Bangalore",
"country": "India"
},
"openings": [
{
"role": "Design Intern - Summer 2017",
"applyLink": "http://www.google.com"
},
{
"role": "Backend Intern - Winter 2016",
"applyLink": "http://www.google.com"
},
{
"role": "Front End Intern - Summer 2017",
"applyLink": "http://www.google.com"
}
]
},
{
"name": "Flipkart",
"location": {
"city": "Bangalore",
"country": "India"
},
"openings": [
{
"role": "Marketing Intern - Summer 2017",
"applyLink": "http://www.google.com"
}
]
}
]
4 changes: 2 additions & 2 deletions src/Components/App.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React, { Component } from 'react';
import logo from '../logo.svg';

// Components
import CompanyList from './CompanyList';

// We need to pull all the data here

class App extends Component {
render() {
return (
Expand Down
30 changes: 19 additions & 11 deletions src/Components/Company.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
import React, { Component, PropTypes } from 'react';

import Openings from './Openings';
import CompanyInfo from './CompanyInfo';

class Company extends Component {
static propTypes = {
className: PropTypes.string,
};
static propTypes = {
className: PropTypes.string,
data: PropTypes.object
};

constructor(props) {
super(props);
}
constructor(props) {
super(props);
}

render() {
return (
<h1>This is a company</h1>
);
}
render() {
var {name, location} = this.props.data;
return (
<div className="company">
<CompanyInfo name={name} location={location}/>
<Openings data={this.props.data.openings}/>
</div>
);
}
}

export default Company;
7 changes: 6 additions & 1 deletion src/Components/CompanyInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import React, { Component, PropTypes } from 'react';
class CompanyInfo extends Component {
static propTypes = {
className: PropTypes.string,
name: PropTypes.string,
location: PropTypes.object
};

constructor(props) {
Expand All @@ -11,7 +13,10 @@ class CompanyInfo extends Component {

render() {
return (
<h1>This is the company info right here</h1>
<div className="companyInfo">
<span className="companyName">{this.props.name}</span>
<span className="companyLocation">{this.props.location.city}, {this.props.location.country}</span>
</div>
);
}
}
Expand Down
33 changes: 32 additions & 1 deletion src/Components/CompanyList.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,48 @@
import React, { Component, PropTypes } from 'react';

// Components
import Company from './Company';

class CompanyList extends Component {
static propTypes = {
className: PropTypes.string,
};

constructor(props) {
super(props);
this.state = {
data: null
};
}

componentDidMount() {
this.fetchCompanyData();
}

fetchCompanyData(){
var url = './data.json';
fetch(url)
.then( response => response.json() )
.then( jsonData => {
this.setState({
data: jsonData
});
})
.catch( error => console.log('JSON Fetch error : ' + error) );
}

render() {
var {data} = this.state;
return (
<h1>I am the company list</h1>
<div className="companyList">
{
data && data.map( (company, i) => {
return(
<Company key={i} data={company} />
);
})
}
</div>
);
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/Components/Opening.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React, { Component, PropTypes } from 'react';
class Opening extends Component {
static propTypes = {
className: PropTypes.string,
data: PropTypes.object
};

constructor(props) {
Expand All @@ -11,7 +12,7 @@ class Opening extends Component {

render() {
return (
<h1>Opening</h1>
<li className="opening">{this.props.data.role}</li>
);
}
}
Expand Down
30 changes: 30 additions & 0 deletions src/Components/Openings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import React, { Component, PropTypes } from 'react';

import Opening from './Opening';

class Openings extends Component {
static propTypes = {
className: PropTypes.string,
data: PropTypes.array
};

constructor(props) {
super(props);
}

render() {
return (
<ul className="openings">
{
this.props.data.map( (opening, i) => {
return(
<Opening key={i} data={opening}/>
);
})
}
</ul>
);
}
}

export default Openings;
8 changes: 8 additions & 0 deletions src/Styles/Components/_App.scss
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
// Delcare App wide styles here
* {
box-sizing: border-box;
}

html, body {
font-size: 62.5%;
font-family: 'Roboto', 'sans-serif';
}
10 changes: 10 additions & 0 deletions src/Styles/Components/_Company.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.company {
color: $color-main-text;
}

.company:first-child {
& .companyInfo {
border-top: none;
}
}

18 changes: 18 additions & 0 deletions src/Styles/Components/_CompanyInfo.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
.companyInfo {
padding: 30px 25px 30px 25px;
border-top: 1px solid $color-main-border;
border-bottom: 1px solid $color-main-border;
}

.companyName {
font-size: 2rem;
letter-spacing: 0.15rem;
display: block;
}

.companyLocation {
margin-top: 0.5rem;
font-size: 1.6rem;
letter-spacing: 0.12rem;
display: block;
}
8 changes: 8 additions & 0 deletions src/Styles/Components/_CompanyList.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.companyList {
background-color: $color-main;
border-radius: 2px;
border: 1px solid $color-main-border;
width: 750px;
margin: 50px auto 0px auto;
font-size: 4.8rem;
}
Empty file.
11 changes: 11 additions & 0 deletions src/Styles/Components/_Opening.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.opening {
padding: 25px;
font-size: 1.8rem;
font-family: 'Roboto', 'sans-serif';
background-color: $color-opening-base;
border-bottom: 1px solid $color-main-border;
}

.opening:last-child {
border-bottom: none;
}
3 changes: 3 additions & 0 deletions src/Styles/Components/_Openings.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.openings {

}
5 changes: 5 additions & 0 deletions src/Styles/_variables.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
$color-main: #FAFAFB;
$color-button-primary: #52A1ED;
$color-main-text: #515357;
$color-opening-base: #FFFFFF;
$color-main-border: #B9BCC6;
3 changes: 2 additions & 1 deletion src/Styles/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@

@import "compass";
@import "compass/reset";
@import "variables";
@import "Components/App";
@import "Components/CompanyList";
@import "Components/Company";
@import "Components/CompanyInfo";
@import "Components/CompanyOpenings";
@import "Components/Openings";
@import "Components/Opening";
@import "Components/OpeningInfo";
@import "Components/ButtonPrimary";

0 comments on commit d994ae0

Please sign in to comment.