diff --git a/08_Day_States/08_states_boilerplate/src/country.js b/08_Day_States/08_states_boilerplate/src/country.js
new file mode 100644
index 0000000..868e116
--- /dev/null
+++ b/08_Day_States/08_states_boilerplate/src/country.js
@@ -0,0 +1,87 @@
+import React from "react";
+import countriesData from "./data/countries";
+
+const styles = {
+ wrapper : {
+ width : 500,
+ height : 500,
+ backgroundColor: 'red',
+ display: 'flex',
+ justifyContent: 'center',
+ alignItems: 'center',
+ flexDirection: 'column'
+ },
+ buttonStyle : {
+ backgroundColor: 'rebeccapurple',
+ padding: '1rem',
+ color: 'white',
+ borderRadius: 12,
+ border: 'none',
+ cursor:'pointer'
+ }
+}
+
+
+
+export class Country extends React.Component {
+ state = {
+ count: 0,
+ styles: {
+ backgroundColor: 'black',
+ color: 'white',
+ },
+ random: 0
+ }
+
+ changeBackground = () => {
+ let styles = {...this.state.styles};
+
+ if( this.state.styles.backgroundColor === 'black' && this.state.styles.color === 'white' ){
+ styles.backgroundColor = 'white'
+ styles.color = 'black'
+ this.setState({ styles });
+ } else {
+ styles.backgroundColor = 'black'
+ styles.color = 'white'
+ this.setState({ styles });
+ }
+ }
+
+ changeCountry = () => {
+ const randomNumber = Math.floor(Math.random() * countriesData.length);
+ this.setState({ random: randomNumber})
+ }
+
+ render() {
+ return(
+
+ leleley
+
+
+ {
+ countriesData.map( (country, index ) => {
+ if( index === this.state.random ) {
+ return (
+
+

+
+ leblebleb : {country.capital}
+
+
+ );
+ }
+ })
+ }
+
+
+
+ )
+ }
+}
\ No newline at end of file
diff --git a/08_Day_States/08_states_boilerplate/src/data/countries.js b/08_Day_States/08_states_boilerplate/src/data/countries.js
index 153d564..8ba9371 100644
--- a/08_Day_States/08_states_boilerplate/src/data/countries.js
+++ b/08_Day_States/08_states_boilerplate/src/data/countries.js
@@ -1,10 +1,11 @@
-export const countriesData = [
+
+const countriesData = [
{
name: 'Afghanistan',
capital: 'Kabul',
languages: ['Pashto', 'Uzbek', 'Turkmen'],
population: 27657145,
- flag: 'https://restcountries.eu/data/afg.svg',
+ flag: 'https://st.myideasoft.com/idea/gj/33/myassets/products/150/tuzsuz-leblebi.jpg?revision=1598520160',
currency: 'Afghan afghani',
},
{
@@ -2011,3 +2012,5 @@ export const countriesData = [
currency: 'Botswana pula',
},
]
+
+export default countriesData
\ No newline at end of file
diff --git a/08_Day_States/08_states_boilerplate/src/index.js b/08_Day_States/08_states_boilerplate/src/index.js
index b651cb3..d923361 100644
--- a/08_Day_States/08_states_boilerplate/src/index.js
+++ b/08_Day_States/08_states_boilerplate/src/index.js
@@ -3,6 +3,7 @@ import React from 'react'
import ReactDOM from 'react-dom'
import Mine from './mine'
import asabenehImage from './images/asabeneh.jpg'
+import {Country} from "./country";
// Fuction to show month date year
@@ -210,25 +211,14 @@ class App extends React.Component {
minusOne = () => {
this.setState({ count: this.state.count - 1 })
}
+
handleTime = () => {
alert(this.showDate(new Date()))
}
+
greetPeople = () => {
alert('Welcome to 30 Days Of React Challenge, 2020')
}
- changeBackground = () => {
- let styles = {...this.state.styles};
-
- if( this.state.styles.backgroundColor === 'black' && this.state.styles.color === 'white' ){
- styles.backgroundColor = 'white'
- styles.color = 'black'
- this.setState({ styles });
- } else {
- styles.backgroundColor = 'black'
- styles.color = 'white'
- this.setState({ styles });
- }
- }
render() {
const data = {
@@ -247,19 +237,8 @@ class App extends React.Component {
const user = { ...data.author, image: asabenehImage }
return (
-
-
-
-
+
+
)
}
diff --git a/08_Day_States/08_states_boilerplate/src/mine.js b/08_Day_States/08_states_boilerplate/src/mine.js
index 6c02431..a2f42df 100644
--- a/08_Day_States/08_states_boilerplate/src/mine.js
+++ b/08_Day_States/08_states_boilerplate/src/mine.js
@@ -6,6 +6,12 @@ const cat = 'https://www.smithsstationah.com/imagebank/eVetSites/Feline/01.jpg';
export default class Mine extends React.Component {
+ // declaring state
+ state = {
+ count: 0,
+ imgLink: cat
+ }
+
changeUrl = () => {
if( this.state.imgLink === dog ){
this.setState({ imgLink : cat })
@@ -14,14 +20,10 @@ export default class Mine extends React.Component {
}
}
- // declaring state
- state = {
- count: 0,
- imgLink: cat
- }
render() {
// accessing the state value
const count = this.state.count
+
return (