{"version":3,"sources":["components/Race.js","components/App.js","serviceWorker.js","index.js"],"names":["filter","name","data","d","state","voting","map","race","tickFormatter","value","Race","makeStyles","theme","formControl","minWidth","maxWidth","props","changeTitle","newTitle","setState","selectedState","filteredData","console","log","this","onChange","selected","width","height","margin","top","right","left","bottom","strokeDasharray","dataKey","domain","angle","fill","React","Component","Title","names","Set","titleCase","id","event","target","toUpperCase","key","str","toLowerCase","split","i","length","charAt","slice","join","App","Boolean","window","location","hostname","match","ReactDOM","render","document","getElementById","navigator","serviceWorker","ready","then","registration","unregister"],"mappings":"6SASMA,EAAS,SAACC,GAWZ,MAVa,WAATA,IACAA,EAAO,MACIC,EAAKF,QAAO,SAAAG,GAAC,OAAIA,EAAEC,QAAUH,IAAsB,IAAdE,EAAEE,UAAeC,KAAI,SAAAH,GACrE,MACI,CACII,KAAMJ,EAAEI,KACRF,OAAQF,EAAEE,YAMpBG,EAAgB,SAACC,GAAD,OAAWA,EAAQ,KAOnCC,GANYC,aAAW,SAAAC,GAAK,MAAK,CACnCC,YAAa,CACTC,SAAU,IACVC,SAAU,S,YAKd,WAAYC,GAAQ,IAAD,8BACf,4CAAMA,KAOVC,YAAc,SAACC,GACX,EAAKC,SAAS,CAACC,cAAeF,EACtBG,aAAcrB,EAAOkB,MAR7B,EAAKd,MAAQ,CACTgB,cAAe,SACfC,aAAcrB,EAAO,OAJV,E,sEAgBf,OADAsB,QAAQC,IAAIC,KAAKpB,MAAMiB,cAEnB,6BACI,kBAAC,EAAD,CAAOI,SAAUD,KAAKP,YAAaS,SAAUF,KAAKpB,MAAMgB,gBACxD,kBAAC,IAAD,CAAqBO,MAAO,OAAQC,OAAQ,KACxC,kBAAC,IAAD,CACI1B,KAAMsB,KAAKpB,MAAMiB,aACjBQ,OAAQ,CACJC,IAAK,EAAGC,MAAO,GAAIC,MAAO,GAAIC,OAAQ,IAG1C,kBAAC,IAAD,CAAeC,gBAAgB,QAC/B,kBAAC,IAAD,CAAOC,QAAS,SAChB,kBAAC,IAAD,CAAOR,MAAO,IAAKS,OAAQ,CAAC,EAAG,KAAM5B,cAAeA,GAChD,kBAAC,IAAD,CAAOC,MAAO,cAAe4B,OAAQ,MAEzC,kBAAC,IAAD,CAAKF,QAAS,SAAUG,KAtDhC,mB,GAqBGC,IAAMC,YAyCnBC,EAAQ,SAACzB,GACX,IAAI0B,EAAK,YAAO,IAAIC,IAAIzC,EAAKI,KAAI,SAAAH,GAAC,OAAIyC,EAAUzC,EAAEC,YAElD,OADAsC,EAAM,GAAK,SAEP,6BACA,yBAAKG,GAAI,SACL,wDACA,6BACI,4BAAQpB,SAAU,SAACqB,GAAD,OAAW9B,EAAMS,SAAUqB,EAAMC,OAAOtC,MAAOuC,gBAAgBH,GAAI,YAChFH,EAAMpC,KAAI,SAAAL,GAAI,OACX,4BAAQgD,IAAKhD,GAAOA,SAKhC,sCAKN2C,EAAY,SAACM,GACfA,EAAMA,EAAIC,cAAcC,MAAM,KAC9B,IAAK,IAAIC,EAAI,EAAGA,EAAIH,EAAII,OAAQD,IAC5BH,EAAIG,GAAKH,EAAIG,GAAGE,OAAO,GAAGP,cAAgBE,EAAIG,GAAGG,MAAM,GAE3D,OAAON,EAAIO,KAAK,MAGL/C,ICrFAgD,E,iLAPP,OACI,kBAAC,EAAD,U,GAJMnB,IAAMC,WCSJmB,QACW,cAA7BC,OAAOC,SAASC,UAEe,UAA7BF,OAAOC,SAASC,UAEhBF,OAAOC,SAASC,SAASC,MACvB,2DCZNC,IAASC,OACT,kBAAC,EAAD,MACGC,SAASC,eAAe,SDyHrB,kBAAmBC,WACrBA,UAAUC,cAAcC,MAAMC,MAAK,SAAAC,GACjCA,EAAaC,iB","file":"static/js/main.46b82401.chunk.js","sourcesContent":["import React from 'react';\r\nimport {\r\n BarChart, Bar, XAxis, YAxis, CartesianGrid, ResponsiveContainer, Tooltip, Label,\r\n} from \"recharts\";\r\nimport { Select, FormControl, InputLabel, MenuItem } from '@material-ui/core';\r\nimport { makeStyles } from '@material-ui/core/styles';\r\nimport data from '../data/race.json';\r\n\r\nconst magenta = \"#E3007D\";\r\nconst filter = (name) => {\r\n if (name === \"THE US\")\r\n name = \"US\";\r\n let filtered = data.filter(d => d.state === name && d.voting !== -1).map(d => {\r\n return (\r\n {\r\n race: d.race,\r\n voting: d.voting\r\n }\r\n )\r\n })\r\n return filtered;\r\n}\r\nconst tickFormatter = (value) => value + \"%\";\r\nconst useStyles = makeStyles(theme => ({\r\n formControl: {\r\n minWidth: 200,\r\n maxWidth: 400,\r\n }\r\n}));\r\nclass Race extends React.Component {\r\n\r\n constructor(props) {\r\n super(props);\r\n this.state = {\r\n selectedState: \"the US\",\r\n filteredData: filter(\"US\")\r\n };\r\n }\r\n\r\n changeTitle = (newTitle) => {\r\n this.setState({selectedState: newTitle,\r\n filteredData: filter(newTitle)\r\n });\r\n }\r\n\r\n render() {\r\n console.log(this.state.filteredData);\r\n return (\r\n
\r\n \r\n <ResponsiveContainer width={\"100%\"} height={500}>\r\n <BarChart\r\n data={this.state.filteredData}\r\n margin={{\r\n top: 5, right: 30, left: -50, bottom: 5,\r\n }}\r\n >\r\n <CartesianGrid strokeDasharray=\"3 3\" />\r\n <XAxis dataKey={'race'}/>\r\n <YAxis width={110} domain={[0, 100]} tickFormatter={tickFormatter}>\r\n <Label value={\"Voting Rate\"} angle={-90}/>\r\n </YAxis>\r\n <Bar dataKey={'voting'} fill={magenta}/>\r\n </BarChart>\r\n </ResponsiveContainer>\r\n </div>\r\n )\r\n }\r\n}\r\n\r\nconst Title = (props) => {\r\n let names = [...new Set(data.map(d => titleCase(d.state)))];\r\n names[0] = \"the US\";\r\n return (\r\n <div>\r\n <div id={\"title\"}>\r\n <h1>Voting rates by race in </h1>\r\n <div>\r\n <select onChange={(event) => props.onChange((event.target.value).toUpperCase())} id={\"selector\"}>\r\n {names.map(name => (\r\n <option key={name}>{name}</option>\r\n ))}\r\n </select>\r\n </div>\r\n </div>\r\n <h2>2016</h2>\r\n </div>\r\n )\r\n}\r\n\r\nconst titleCase = (str) => {\r\n str = str.toLowerCase().split(' ');\r\n for (var i = 0; i < str.length; i++) {\r\n str[i] = str[i].charAt(0).toUpperCase() + str[i].slice(1);\r\n }\r\n return str.join(' ');\r\n}\r\n\r\nexport default Race;","import React from 'react';\r\nimport Race from './Race';\r\n\r\nclass App extends React.Component {\r\n\r\n render() {\r\n return (\r\n <Race />\r\n )\r\n }\r\n}\r\n\r\n\r\nexport default App;","// This optional code is used to register a service worker.\n// register() is not called by default.\n\n// This lets the app load faster on subsequent visits in production, and gives\n// it offline capabilities. However, it also means that developers (and users)\n// will only see deployed updates on subsequent visits to a page, after all the\n// existing tabs open on the page have been closed, since previously cached\n// resources are updated in the background.\n\n// To learn more about the benefits of this model and instructions on how to\n// opt-in, read https://bit.ly/CRA-PWA\n\nconst isLocalhost = Boolean(\n window.location.hostname === 'localhost' ||\n // [::1] is the IPv6 localhost address.\n window.location.hostname === '[::1]' ||\n // 127.0.0.1/8 is considered localhost for IPv4.\n window.location.hostname.match(\n /^127(?:\\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/\n )\n);\n\nexport function register(config) {\n if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {\n // The URL constructor is available in all browsers that support SW.\n const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href);\n if (publicUrl.origin !== window.location.origin) {\n // Our service worker won't work if PUBLIC_URL is on a different origin\n // from what our page is served on. This might happen if a CDN is used to\n // serve assets; see https://github.com/facebook/create-react-app/issues/2374\n return;\n }\n\n window.addEventListener('load', () => {\n const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;\n\n if (isLocalhost) {\n // This is running on localhost. Let's check if a service worker still exists or not.\n checkValidServiceWorker(swUrl, config);\n\n // Add some additional logging to localhost, pointing developers to the\n // service worker/PWA documentation.\n navigator.serviceWorker.ready.then(() => {\n console.log(\n 'This web app is being served cache-first by a service ' +\n 'worker. To learn more, visit https://bit.ly/CRA-PWA'\n );\n });\n } else {\n // Is not localhost. Just register service worker\n registerValidSW(swUrl, config);\n }\n });\n }\n}\n\nfunction registerValidSW(swUrl, config) {\n navigator.serviceWorker\n .register(swUrl)\n .then(registration => {\n registration.onupdatefound = () => {\n const installingWorker = registration.installing;\n if (installingWorker == null) {\n return;\n }\n installingWorker.onstatechange = () => {\n if (installingWorker.state === 'installed') {\n if (navigator.serviceWorker.controller) {\n // At this point, the updated precached content has been fetched,\n // but the previous service worker will still serve the older\n // content until all client tabs are closed.\n console.log(\n 'New content is available and will be used when all ' +\n 'tabs for this page are closed. See https://bit.ly/CRA-PWA.'\n );\n\n // Execute callback\n if (config && config.onUpdate) {\n config.onUpdate(registration);\n }\n } else {\n // At this point, everything has been precached.\n // It's the perfect time to display a\n // \"Content is cached for offline use.\" message.\n console.log('Content is cached for offline use.');\n\n // Execute callback\n if (config && config.onSuccess) {\n config.onSuccess(registration);\n }\n }\n }\n };\n };\n })\n .catch(error => {\n console.error('Error during service worker registration:', error);\n });\n}\n\nfunction checkValidServiceWorker(swUrl, config) {\n // Check if the service worker can be found. If it can't reload the page.\n fetch(swUrl)\n .then(response => {\n // Ensure service worker exists, and that we really are getting a JS file.\n const contentType = response.headers.get('content-type');\n if (\n response.status === 404 ||\n (contentType != null && contentType.indexOf('javascript') === -1)\n ) {\n // No service worker found. Probably a different app. Reload the page.\n navigator.serviceWorker.ready.then(registration => {\n registration.unregister().then(() => {\n window.location.reload();\n });\n });\n } else {\n // Service worker found. Proceed as normal.\n registerValidSW(swUrl, config);\n }\n })\n .catch(() => {\n console.log(\n 'No internet connection found. App is running in offline mode.'\n );\n });\n}\n\nexport function unregister() {\n if ('serviceWorker' in navigator) {\n navigator.serviceWorker.ready.then(registration => {\n registration.unregister();\n });\n }\n}\n","import React from 'react';\nimport ReactDOM from 'react-dom';\nimport './index.css';\nimport App from './components/App.js';\nimport * as serviceWorker from './serviceWorker';\n\nReactDOM.render((\n<App />\n), document.getElementById('root'));\n\n// If you want your app to work offline and load faster, you can change\n// unregister() to register() below. Note this comes with some pitfalls.\n// Learn more about service workers: https://bit.ly/CRA-PWA\nserviceWorker.unregister();\n"],"sourceRoot":""}