text:
Q: Populating Modals From Mapped Cards in React (ES6/ES7) tl;dr new to coding. 1 card = 1 pokémon name. Mapped out 898+ cards, listed in increments of 20. How can I set a modal to pop up when a card is clicked, and have it display the data in Pokemon.js?
Currently a developer in training. I have individual pokémon names mapped out onto 898+ cards (paginated 20 at a time). When a specific card is clicked, it loads that pokémon's information and wipes out the list of cards. When you go back to the main page, the names reset back to the first 20. How do I implement modals to load the pokémon's information instead when a card is clicked? I've watched a bunch of tutorials but am a bit confused as to where to even place the modal in the build (I have components on top of components). I'm also trying to avoid adding buttons on the cards for designating an onClick. I'm assuming this process isn't as complex as I'm making it, but any instruction on how to do it based on the code I've provided would be immensely appreciated. I'll include the individual components and my App.js file.
App.js
import React from 'react';
import { HashRouter as Router, Route, Switch } from 'react-router-dom';
import NavBar from '../src/components/layout/NavBar';
import Dashboard from './components/layout/Dashboard';
import Pokemon from './components/pokemon/Pokemon';
import backgroundImage from './pokeball.png';
import 'bootstrap/dist/css/bootstrap.min.css';
import './App.css';

function App() {
  return (
    <Router>
      <div
        className='App'
        style={{
          background: `url(${backgroundImage})`
        }}
      >
        <NavBar />

          <Switch>
            <Route
              exact path='/'
              component={Dashboard}
            />
            <Route
              exact path='/pokemon/:indexNum'
              render={(props) => <Pokemon {...props} />}
            />
          </Switch>

    </Router>
  );
}

export default App;

Dashboard.js
import React from 'react';
import PokemonList from '../pokemon/PokemonList';

const Dashboard = () => {
  return (

        <PokemonList />

  )
}

export default Dashboard

PokemonList.js
import React, { useState, useEffect } from 'react';
import PokemonCard from './PokemonCard';
import Pagination from '../layout/Pagination';
import axios from 'axios';

const PokemonList = () => {
  const [pokemon, setPokemon] = useState([])
  const [currentPageUrl, setCurrentPageUrl] = useState('https://pokeapi.co/api/v2/pokemon')
  const [loading, setLoading] = useState(true)
  const [nextPageUrl, setNextPageUrl] = useState()
  const [prevPageUrl, setPrevPageUrl] = useState()

  useEffect(() => {
    setLoading(true)
    let cancel
    axios.get(currentPageUrl, {
      cancelToken: new axios.CancelToken(c => cancel = c)
    }).then(res => {
      setLoading(false)
      // console.log(res.data.results)
      setPokemon(res.data.results)
      setNextPageUrl(res.data.next)
      setPrevPageUrl(res.data.previous)
    })

    return () => cancel()

  }, [currentPageUrl])

  const goToNextPage = () => {
    setCurrentPageUrl(nextPageUrl)
  }

  const goToPrevPage = () => {
    setCurrentPageUrl(prevPageUrl)
  }

  if (loading) return "Loading Your Pokémon..."

  return (
    <>
      {pokemon ? (

          {pokemon.map((i) => (
            <PokemonCard
              key={i.name}
              pokemon={i.name}
              url={i.url}
            />
          ))}

      ) : (

Loading

      )}

          <Pagination
            goToNextPage={nextPageUrl ? goToNextPage : null}
            goToPrevPage={prevPageUrl ? goToPrevPage : null}
          />

    </>
  )
}

export default PokemonList

Pagination.js
import React from 'react';
import { ChevronDoubleLeft, ChevronDoubleRight } from 'react-bootstrap-icons';

const Pagination = ({ goToNextPage, goToPrevPage }) => {
  return (

      {
        goToPrevPage &&
        <button
          className='badge badge-pill badge-danger'
          type='button'
          onClick={goToPrevPage}
          style={{
            marginBottom: '20px',
            padding: '10px'
          }}
        >
          <ChevronDoubleLeft />
        </button>
      }

      {
        goToNextPage &&
        <button
          className='badge badge-pill badge-danger'
          type='button'
          onClick={goToNextPage}
          style={{
            marginBottom: '20px',
            padding: '10px'
          }}
        >
          <ChevronDoubleRight />
        </button>
      }

  )
}

export default Pagination

PokemonCard.js
import React, { useState, useEffect } from 'react';
import { Link } from 'react-router-dom';
import axios from 'axios';
import styled from 'styled-components';
import gif from '../../loading-wheel.gif';

const Sprite = styled.img`
  width: 5em;
  height: 5em;
`;

const Card = styled.div`
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  &:hover {
    box-shadow: 0 14px 28px rgba(0, 0, 0, 0.25), 0 10px 10px rgba(0, 0, 0, 0.22);
  }
  -moz-user-select: none;
  -website-user-select: none;
  user-select: none;
  -o-user-select: none;
`;

const StyledLink = styled(Link)`
  text-decoration: none;
  color: black;
  &:focus,
  &:hover,
  &:visited,
  &:link,
  &:active {
    text-decoration: none;
  }
`;

const PokemonCard = ({ pokemon, url }) => {
  const [sprite, setSprite] = useState('')
  const [loadImage, setLoadImage] = useState(true)
  const [tooManyRequests, setTooManyRequests] = useState(false)
  const [didMount, setDidMount] = useState(false)
  const [indexNum] = useState(url.split('/')[url.split('/').length - 2])

  useEffect(() => {
    axios.get('https://pokeapi.co/api/v2/pokemon/' + pokemon)
      .then (res => {
        setSprite(res.data.sprites.front_default)
      })
      setDidMount(true);
      return () => setDidMount(false)
  }, [pokemon])

  if (!didMount) {
    return null;
  }

  return (

  )

}

export default PokemonCard

Pokemon.js
import React, { useState, useEffect } from 'react';
import axios from 'axios';
import gif from '../../loading-wheel.gif';

const type_colors = {
  bug: 'B1C12E',
  dark: '4F3A2D',
  dragon: '755EDF',
  electric: 'FCBC17',
  fairy: 'F4B1F4',
  fighting: '823551D',
  fire: 'E73B0C',
  flying: 'A3B3F7',
  ghost: '6060B2',
  grass: '74C236',
  ground: 'D3B357',
  ice: 'A3E7FD',
  normal: 'C8C4BC',
  poison: '934594',
  psychic: 'ED4882',
  rock: 'B9A156',
  steel: 'B5B5C3',
  water: '3295F6'
};

const Pokemon = (props) => {
  const { match } = props
  const { params } = match
  const { indexNum } = params

  const [pokemon, setPokemon] = useState(undefined)
  const [bio, setBio] = useState('')
  const [genderRatioMale, setGenderRatioMale] = useState(0)
  const [genderRatioFemale, setGenderRatioFemale] = useState(0)
  const [catchRate, setCatchRate] = useState(0)
  const [growthRate, setGrowthRate] = useState('')
  const [hatchSteps, setHatchSteps] = useState(0)

  useEffect(() => {
    axios.get(`https://pokeapi.co/api/v2/pokemon/${indexNum}/`)
      .then (res => {
        const { data } = res
        // console.log(data)
        setPokemon(data)
      })
      .catch(err => {
        setPokemon(false)
      })
  }, [indexNum])

  useEffect(() => {
    axios.get(`https://pokeapi.co/api/v2/pokemon-species/${indexNum}/`)
      .then(res => {
        const { data } = res
        let description = '';
        // console.log(data)
        data.flavor_text_entries
          .some(flavor => {
            const { flavor_text, language } = flavor
            const { name } = language
            if (name === 'en') {
              description = flavor_text
              // console.log(description)
              setBio(description)
            }
            const affirm1 = console.log('Description set as state for bio')
            return affirm1
          })

        const femaleRate = data.gender_rate
        setGenderRatioFemale(12.5 * femaleRate)
        setGenderRatioMale(12.5 * (8 - femaleRate))

        setCatchRate(data.capture_rate)

        setGrowthRate(data.growth_rate.name)

        setHatchSteps(255 * (data.hatch_counter) + 1)
      })
  }, [indexNum])

  const loadPokemonJsx = () => {
    const {
      name,
      id,
      abilities,
      height,
      weight,
      types,
      stats,
      sprites
    } = pokemon

    const {front_default} = sprites
    const fullImageUrl = `https://pokeres.bastionbot.org/images/pokemon/${id}.png`

    let [
      hp,
      attack,
      defense,
      speed,
      specialAttack,
      specialDefense
    ] = ''

    stats.map(stat => {
      switch (stat.stat.name) {
        case 'hp':
          hp = stat['base_stat'];
          // console.log(`HP: ${hp}`)
          break;
        case 'attack':
          attack = stat['base_stat'];
          // console.log(`ATK: ${attack}`)
          break;
        case 'defense':
          defense = stat['base_stat'];
          // console.log(`DEF: ${defense}`)
          break;
        case 'speed':
          speed = stat['base_stat'];
          // console.log(`SPEED: ${speed}`)
          break;
        case 'special-attack':
          specialAttack = stat['base_stat'];
          // console.log(`SP. ATK: ${specialAttack}`)
          break;
        case 'special-defense':
          specialDefense = stat['base_stat'];
          // console.log(`SP. DEF: ${specialDefense}`)
          break;
        default:
          break;
      }
      const affirm2 = console.log('Variables from switch case are set')
      return affirm2
    })

    return (
      <>

                    {indexNum}

                    { types.map(typeInfo => {
                      const { type } = typeInfo;
                      const { name } = type;
                      return <span
                        key={name}
                        className='badge badge-primary badge-pill mr-1'
                        style={{
                          backgroundColor: `#${type_colors[name]}`,
                          color: 'white'
                        }}
                      >
                        {`${name
                            .toLowerCase()
                            .split(' ')
                            .map(letter => letter.charAt(0).toUpperCase() + letter.substring(1))
                            .join(' ')
                          }`
                        }

                    }) }

                    { name
                      .toLowerCase()
                      .split('-')
                      .map(letter => letter.charAt(0).toUpperCase() + letter.substring(1))
                      .join(' ')
                    }

HP

                        <div
                          className='progress-bar'
                          role='progressbar'
                          style={{
                            width: `${hp}%`
                          }}
                          aria-valuenow='25'
                          aria-valuemin='0'
                          aria-valuemax='100'
                        >
                          {hp}

Attack

                        <div
                          className='progress-bar'
                          role='progressbar'
                          style={{
                            width: `${attack}%`
                          }}
                          aria-valuenow='25'
                          aria-valuemin='0'
                          aria-valuemax='100'
                        >
                          {attack}

Sp. Attack

                        <div
                          className='progress-bar'
                          role='progressbar'
                          style={{
                            width: `${specialAttack}%`
                          }}
                          aria-valuenow='25'
                          aria-valuemin='0'
                          aria-valuemax='100'
                        >
                          {specialAttack}

Defense

                        <div
                          className='progress-bar'
                          role='progressbar'
                          style={{
                            width: `${defense}%`
                          }}
                          aria-valuenow='25'
                          aria-valuemin='0'
                          aria-valuemax='100'
                        >
                          {defense}

Sp. Defense

                        <div
                          className='progress-bar'
                          role='progressbar'
                          style={{
                            width: `${specialDefense}%`
                          }}
                          aria-valuenow='25'
                          aria-valuemin='0'
                          aria-valuemax='100'
                        >
                          {specialDefense}

Speed

                        <div
                          className='progress-bar'
                          role='progressbar'
                          style={{
                            width: `${speed}%`
                          }}
                          aria-valuenow='25'
                          aria-valuemin='0'
                          aria-valuemax='100'
                        >
                          {speed}

{bio}

Profile

Approx. Height:

                        {
                          (Math.round((height * 0.328084 + 0.0001) * 100) / 100) + ' ft / ' +
                          (Math.round((height * 10 + 0.0001) * 100) / 100) + ' cm'
                        }

Approx. Weight:

                        {
                          (Math.round((weight * 0.220462 + 0.0001) * 100) / 100) + ' lbs / ' +
                          (Math.round((weight * 0.1 + 0.0001) * 100) / 100) + ' kg'
                        }

Catch Rate:

                        { `${catchRate}%` }

Gender Ratio:

                        <div
                          className='progress-bar'
                          role='progressbar'
                          style={{
                            width: `${genderRatioFemale}%`,
                            backgroundColor: '#C2185B',
                          }}
                          aria-valuenow='15'
                          aria-valuemin='0'
                          aria-valuemax='100'
                        >
                          {`${genderRatioFemale}%`}

                        <div
                          className='progress-bar'
                          role='progressbar'
                          style={{
                            width: `${genderRatioMale}%`,
                            backgroundColor: '#1976D2'
                          }}
                          aria-valuenow='30'
                          aria-valuemin='0'
                          aria-valuemax='100'
                        >
                          {`${genderRatioMale}%`}

Growth Rate:

                        {growthRate
                          .toLowerCase()
                          .split('-')
                          .map(letter => letter.charAt(0).toUpperCase() + letter.substring(1))
                          .join(' ')
                        }

Hatch Steps:

                        {hatchSteps}

Effort Values:

                        {
                          stats.filter(stat => {
                            if (stat.effort > 0) {
                              return true;
                            }
                            return false;
                          })
                          .map(statInfo => {
                            const { effort, stat } = statInfo
                            const { name } = stat

                            return `${effort} ${name
                              .toLowerCase()
                              .split('-')
                              .map(letter => letter.charAt(0).toUpperCase() + letter.substring(1))
                              .join(' ')
                            }`
                          }).join(', ')
                        }

Abilities:

                        {
                          abilities.map(abilityInfo => {
                            const { ability } = abilityInfo;
                            const { name } = ability;
                            return `${name
                              .toLowerCase()
                              .split('-')
                              .map(letter => letter.charAt(0).toUpperCase() + letter.substring(1))
                              .join(' ')
                            }`
                          }).join(', ')
                        }

      </>
    )
  }

  return (
    <>
      {pokemon === undefined &&

      }
      {pokemon !== undefined && pokemon && loadPokemonJsx(pokemon)}
      {pokemon === false &&
 Pokémon Not Found
}
    </>
  )
}

export default Pokemon

Sorry this is such a long post. Thanks again!

redpajama_set_name: RedPajamaStackExchange


Coldstores made from insulated panels are complemented by a range of doors and frames which help to create an efficient and reliable chilled environment. Insulated doors are quite often one of the most vital elements of a coldstore, so we explore some of their features here and consider what you should be looking for when choosing doors of this nature.
A quality insulated door should be constructed from quality materials and have a good level of polyurethane density for superior insulation purposes. For example, here at Polysec, we manufacture doors with a polyurethane thickness of 75, 100 & 125mm so they are suitable for any type of cold room application, whether this is to preserve or ripen foods.
Insulated doors should be constructed to the highest possible standards and be fully assembled during the manufacturing process so they can be tested before they leave the processing plant. This will ensure the door is fit for purpose and ready to fit, so once it has been delivered to site it can simply be interlocked with other modular panels and therefore be ready to start working straight away.
Of course, this is just a small sample of the many industries that use chilled storage as part of their business operations – many others find cold rooms constructed from insulated panels and doors to be an invaluable asset.
If you are looking to add insulated doors to a cold store environment we have the perfect collection here at Polysec. Find out more and contact us today, you can leave a message or simply call us on 01905 458551.


It works efficiently with big treatment capacity, especially with lower noise. Compared with our former other shale shakers, this is the outstanding one.
The system is user friendly and simple for our needs. We hope we can work together for more projects in future.


Shades of LA's celebrated avant-garde past lit up the new-music present at Santa Monica's 1st Presbyterian Church -- yes, at this location, a pristinely modern church.
Instead of Igor Stravinsky presiding, as he once did at historic Monday Evening Concerts, we had Thomas Adès (arguably his 21st century successor) at the host church's Jacaranda -- which is the reincarnation of our city's sanctum sanctorum of current music.
And I can't tell you what a feast it was.
If ever we needed to puncture the myth that contemporary music is laborious to listen to or so much doodling and noodling, this would do it.
Neither were Gerald Barry's works anything but extraordinary -- dense, profoundly structured, breathless -- courtesy of musicians Joel Pargman, Louise Thomas and others.
But no matter how well-cued impresario Patrick Scott's all-British program, his celebratory nod to Peter Maxwell Davies' 80th birthday had a downside in the revival of "Vesalii Icones." Perhaps nostalgia got the better of Scott whose local performance art group 40 years ago, Eyes Wide Open, brought it to the public.
The problem here and now was that someone miscalculated badly and opted for cockamamie cornball -- to wit, the musicians played in hospital OR garb (gowns and masks) signifying Vesalius as the father of modern anatomy, while his intricate illustrations were projected on the stage wall. More's the pity because the sleek wood beam crucifix made a brilliant backdrop for the artist's drawings as Stations of the Cross, a theme Davies parodies. But with so much crowding onstage, dancer Jones Welsh's flailings seemed out of place, despite his perfect musculature, which depicted the anatomical images.
Well, it did, thanks to Schubert and Karina Canellakis (right) who led the sparklingly responsive LA Chamber Orchestra at Royce Hall -- all sunny smiles all around with deliciously curving phrases and suffused warmth that could drive away any semblance of a sober, down-turned mouth.
But that's not all. Canellakis is a young American maestra of multiple, exceptional gifts -- though too young, probably, to know she's come a long way, baby, since the day of that then-novelty Antonia Brico at the LA Phil podium, her skirts swaying in the Hollywood Bowl breeze.
And now, just look at Disney Hall's distaff line-up this month: conductors Susanna Mälkki, Xian Zhang and the Phil's newly appointed assistant conductor Mirga Grazinyte-Tyla (just call her Mirga!) -- all of them most masterly in pants and this one, with her energetic stick technique, meticulously tailored.
Canellakis opened as a superb violin soloist, standing among the also upright string players, and cue-ing them in vibrant Vivaldi that almost danced off the stage with gusto. But her baton-wielding instincts go quite beyond this earlier music to embrace John Adams, whose "Shaker Loops" got the most forcefully motoric, bone-jolting performance I've ever heard.
And then there were the Russians. That current elite duo, pianist Daniil Trifonov and violinist Gidon Kremer, touring major cities worldwide, stopped off at Disney Hall, courtesy of the Philharmonic and wowed the cognoscenti in attendance.
At 67 Kremer has been dropping into LA for decades with one self-styled contingency or another -- remember his Kremerata Baltica? Last heard here in an unforgettable amalgam of the ubiquitous "Four Seasons" co-mingled with Piazzolla tango versions of same, he and his string players kicked the weary Vivaldi into sensual over-drive as the violinist led and strolled among the seated women musicians who gazed soulfully at him.
With Trifonov (above), the 24-year-old phenom whose Carnegie Hall piano recital was beamed internationally, he seemed to be showcasing the new talent. Indeed with reason.
Because hearing/seeing Trifonov via the Medici.TV streaming -- with cameras zooming in to every last strand of sweat-drenched hair framing his face, thus causing a sight distraction to the sound -- bore little resemblance to the full-dimension concert-hall experience of lucky witnesses here.
Something about that in-person physical presence allows perceptions not easily had through electronic transmission. His technique, for example: astounding, unimaginable -- so you hear what he did with a Mozart sonata, namely, squeeze from it sweet juice, in a very fine, gentle stream that Kremer actually got to duplicate in the second movement. And that was but one small part of their wondrous music-making.


text:
Home Asia Pacific Report Guam's Vice-Speaker Cruz raises concerns over FestPac costs
Guam's Vice-Speaker Cruz raises concerns over FestPac costs
Now that the Festival of Pacific Arts is over, what happens next? The promotion and preservation of culture doesn't stop, reports Kuam News in this video.
Guam's Vice-Speaker Benjamin Cruz has expressed concern over the government's financial responsibility to host the two-week Festival of Pacific Arts, which concluded on Saturday, reports the Pacific Daily News.
Vice-Speaker Benjamin Cruz … "being a gracious host can be costly." Image: Pacific Daily News
"Everything has been excellent, I've been to all the venues, and it's been phenomenal," Cruz said.
"Every time I go, I just fear how much extra is this costing.
"I'm sure I'll get the bill when this is over."
Cruz said being a gracious host can be costly and would probably affect government operations elsewhere.
He said he recently received a letter from the head of a government of Guam agency, telling him that the department hasn't been getting its monthly budget allotments since December, reports Pacific Daily News.
"The general manager of that one agency is saying they may have a pay-less payday in the upcoming pay period," Cruz said, while refusing to disclose which agency hasn't been getting funding.
He also said: "I'd like to say this one agency has been able to survive since December because they've been able to use reserves (and) it doesn't have that large of payroll."
Executive branch agencies were authorised last week to give every employee up to four days of paid administrative leave to attend FestPac — so long as it didn't compromise daily operations.
The Pacific Daily News obtained a letter from Governor Eddie Calvo dated May 27, in which he encouraged such employees to "cheer" for their friends, family and co-workers participating in the festival.
"To those of you behind the scenes, to those of you who are part of the show, to all of you who have encouraged and cheered them on, I am grateful to all of you for your effort," Calvo wrote.
"Please use this the opportunity to enjoy the festival, which is only held every four years – and this is the first time Guam has had the honor of hosting."
Previous articleUPNG medical students at Taurama continue boycott for 'patriotism'
Next articleNew 'Resource Roulette' report exposes deep-sea mining risks for Pacific

redpajama_set_name: RedPajamaCommonCrawl


Daddy Owen and wife Farida Wambui are in mourning after losing a loved one. Taking to Instagram, Owen posted a sad announcement sharing that just days after welcoming their second child, a baby boy, Wambui has lost her brother.
Owen didn't reveal what exactly happened to Farida's brother but asked his fans to put them in their prayers during the trying times.