From 33d9fbb2366adfaed6c9a5db61cfe083ad7f896e Mon Sep 17 00:00:00 2001 From: Michal Bartosik Date: Fri, 14 May 2021 10:20:23 +0200 Subject: [PATCH] set up project with CRA --- .gitignore | 4 ++ README.md | 83 +++++++++++++++++++++++++++++------------- src/App.css | 38 ------------------- src/App.tsx | 23 +----------- src/index.css | 13 ------- src/index.tsx | 15 ++------ src/logo.svg | 1 - src/reportWebVitals.ts | 15 -------- style-guide.md | 41 +++++++++++++++++++++ 9 files changed, 107 insertions(+), 126 deletions(-) delete mode 100644 src/App.css delete mode 100644 src/index.css delete mode 100644 src/logo.svg delete mode 100644 src/reportWebVitals.ts create mode 100644 style-guide.md diff --git a/.gitignore b/.gitignore index 4d29575..a281131 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,7 @@ npm-debug.log* yarn-debug.log* yarn-error.log* + +*.sketch +*.xd +*.fig diff --git a/README.md b/README.md index b58e0af..e160a36 100644 --- a/README.md +++ b/README.md @@ -1,46 +1,77 @@ -# Getting Started with Create React App +# Frontend Mentor - REST Countries API with color theme switcher -This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). +![Design preview for the REST Countries API with color theme switcher coding challenge](./design/desktop-preview.jpg) -## Available Scripts +## Welcome! 👋 -In the project directory, you can run: +Thanks for checking out this front-end coding challenge. -### `yarn start` +[Frontend Mentor](https://www.frontendmentor.io) challenges allow you to improve your skills in a real-life workflow. -Runs the app in the development mode.\ -Open [http://localhost:3000](http://localhost:3000) to view it in the browser. +**To do this challenge, you need a good understanding of JavaScript.** -The page will reload if you make edits.\ -You will also see any lint errors in the console. +## The challenge -### `yarn test` +Your challenge is to integrate with the [REST Countries API](https://restcountries.eu) to pull country data and display it like in the designs. -Launches the test runner in the interactive watch mode.\ -See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. +You can use any JavaScript framework/library on the front-end such as [React](https://reactjs.org) or [Vue](https://vuejs.org). You also have complete control over which packages you use to do things like make HTTP requests or style your project. -### `yarn build` +Your users should be able to: -Builds the app for production to the `build` folder.\ -It correctly bundles React in production mode and optimizes the build for the best performance. +- See all countries from the API on the homepage +- Search for a country using an `input` field +- Filter countries by region +- Click on a country to see more detailed information on a separate page +- Click through to the border countries on the detail page +- Toggle the color scheme between light and dark mode *(optional)* -The build is minified and the filenames include the hashes.\ -Your app is ready to be deployed! +Want some support on the challenge? [Join our Slack community](https://www.frontendmentor.io/slack) and ask questions in the **#help** channel. -See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. +## Where to find everything -### `yarn eject` +Your task is to build out the project to the designs inside the `/design` folder. -**Note: this is a one-way operation. Once you `eject`, you can’t go back!** +In this challenge, you will find mobile and desktop designs in light and dark mode color schemes for both pages. -If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. +The designs are in JPG static format. This will mean that you'll need to use your best judgment for styles such as `font-size`, `padding` and `margin`. This should help train your eye to perceive differences in spacings and sizes. -Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. +If you would like the Sketch file in order to inspect the design in more detail you can [subscribe as a PRO member](https://www.frontendmentor.io/pro). -You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. +There are no assets for this challenge, as the country flags will be pulled from the [REST Countries API](https://restcountries.eu) and you can use an icon font library for the icons. -## Learn More +There is a `style-guide.md` file, which contains the information you'll need, such as color palette and fonts. -You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). +## Building your project -To learn React, check out the [React documentation](https://reactjs.org/). +Feel free to use any workflow that you feel comfortable with. Below is a suggested process, but do not feel like you need to follow these steps: + +1. Initialize your project as a public repository on [GitHub](https://github.com/). This will make it easier to share your code with the community if you need some help. If you're not sure how to do this, [have a read through of this Try Git resource](https://try.github.io/). +2. Configure your repository to publish your code to a URL. This will also be useful if you need some help during a challenge as you can share the URL for your project with your repo URL. There are a number of ways to do this, but we recommend using [Vercel](https://bit.ly/fem-vercel). We've got more information about deploying your project with Vercel below. +3. Look through the designs to start planning out how you'll tackle the project. This step is crucial to help you think ahead for CSS classes that you could create to make reusable styles. +4. Before adding any styles, structure your content with HTML. Writing your HTML first can help focus your attention on creating well-structured content. +5. Write out the base styles for your project, including general content styles, such as `font-family` and `font-size`. +6. Start adding styles to the top of the page and work down. Only move on to the next section once you're happy you've completed the area you're working on. + +## Deploying your project + +As mentioned above, there are a number of ways to host your project for free. We recommend using [Vercel](https://bit.ly/fem-vercel) as it's an amazing service and extremely simple to get set up with. If you'd like to use Vercel, here are some steps to follow to get started: + +1. [Sign up to Vercel](https://bit.ly/fem-vercel-signup) and go through the onboarding flow, ensuring your GitHub account is connected by using their [Vercel for GitHub](https://vercel.com/docs/v2/git-integrations/vercel-for-github) integration. +2. Connect your project to Vercel from the ["Import project" page](https://vercel.com/import), using the "From Git Repository" button and selecting the project you want to deploy. +3. Once connected, every time you `git push`, Vercel will create a new [deployment](https://vercel.com/docs/v2/platform/deployments) and the deployment URL will be shown on your [Dashboard](https://vercel.com/dashboard). You will also receive an email for each deployment with the URL. + +## Sharing your solution + +There are multiple places you can share your solution: + +1. Submit it on the platform so that other users will see your solution on the site. Here's our ["Complete guide to submitting solutions"](https://medium.com/frontend-mentor/a-complete-guide-to-submitting-solutions-on-frontend-mentor-ac6384162248) to help you do that. +2. Share your solution page in the **#finished-projects** channel of the [Slack community](https://www.frontendmentor.io/slack). +3. Tweet [@frontendmentor](https://twitter.com/frontendmentor) and mention **@frontendmentor** including the repo and live URLs in the tweet. We'd love to take a look at what you've built and help share it around. + +## Giving feedback + +Feedback is always welcome, so if you have any to give on this challenge please email hi[at]frontendmentor[dot]io. + +This challenge is completely free. Please share it with anyone who will find it useful for practice. + +**Have fun building!** 🚀 diff --git a/src/App.css b/src/App.css deleted file mode 100644 index 74b5e05..0000000 --- a/src/App.css +++ /dev/null @@ -1,38 +0,0 @@ -.App { - text-align: center; -} - -.App-logo { - height: 40vmin; - pointer-events: none; -} - -@media (prefers-reduced-motion: no-preference) { - .App-logo { - animation: App-logo-spin infinite 20s linear; - } -} - -.App-header { - background-color: #282c34; - min-height: 100vh; - display: flex; - flex-direction: column; - align-items: center; - justify-content: center; - font-size: calc(10px + 2vmin); - color: white; -} - -.App-link { - color: #61dafb; -} - -@keyframes App-logo-spin { - from { - transform: rotate(0deg); - } - to { - transform: rotate(360deg); - } -} diff --git a/src/App.tsx b/src/App.tsx index a53698a..56e22bb 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,26 +1,5 @@ -import React from 'react'; -import logo from './logo.svg'; -import './App.css'; - function App() { - return ( -
-
- logo -

- Edit src/App.tsx and save to reload. -

- - Learn React - -
-
- ); + return

Hello

; } export default App; diff --git a/src/index.css b/src/index.css deleted file mode 100644 index ec2585e..0000000 --- a/src/index.css +++ /dev/null @@ -1,13 +0,0 @@ -body { - margin: 0; - font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', - 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', - sans-serif; - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; -} - -code { - font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', - monospace; -} diff --git a/src/index.tsx b/src/index.tsx index ef2edf8..b1ef1c0 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -1,17 +1,10 @@ -import React from 'react'; -import ReactDOM from 'react-dom'; -import './index.css'; -import App from './App'; -import reportWebVitals from './reportWebVitals'; +import React from "react"; +import ReactDOM from "react-dom"; +import App from "./App"; ReactDOM.render( , - document.getElementById('root') + document.getElementById("root") ); - -// If you want to start measuring performance in your app, pass a function -// to log results (for example: reportWebVitals(console.log)) -// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals -reportWebVitals(); diff --git a/src/logo.svg b/src/logo.svg deleted file mode 100644 index 9dfc1c0..0000000 --- a/src/logo.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/reportWebVitals.ts b/src/reportWebVitals.ts deleted file mode 100644 index 49a2a16..0000000 --- a/src/reportWebVitals.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { ReportHandler } from 'web-vitals'; - -const reportWebVitals = (onPerfEntry?: ReportHandler) => { - if (onPerfEntry && onPerfEntry instanceof Function) { - import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => { - getCLS(onPerfEntry); - getFID(onPerfEntry); - getFCP(onPerfEntry); - getLCP(onPerfEntry); - getTTFB(onPerfEntry); - }); - } -}; - -export default reportWebVitals; diff --git a/style-guide.md b/style-guide.md new file mode 100644 index 0000000..1acc9fb --- /dev/null +++ b/style-guide.md @@ -0,0 +1,41 @@ +# Front-end Style Guide + +## Layout + +The designs were created to the following widths: + +- Mobile: 375px +- Desktop: 1440px + +## Colors + +### Neutral + +- Dark Blue (Dark Mode Elements): hsl(209, 23%, 22%) +- Very Dark Blue (Dark Mode Background): hsl(207, 26%, 17%) +- Very Dark Blue (Light Mode Text): hsl(200, 15%, 8%) +- Dark Gray (Light Mode Input): hsl(0, 0%, 52%) +- Very Light Gray (Light Mode Background): hsl(0, 0%, 98%) +- White (Dark Mode Text & Light Mode Elements): hsl(0, 0%, 100%) + +## Typography + +### Body Copy + +- Homepage Items: 14px +- Detail Page: 16px + +### Fonts + +- Family: [Nunito Sans](https://fonts.google.com/specimen/Nunito+Sans) +- Weights: 300, 600, 800 + +## Icons + +For the icons, you can use a font icon library. Don't worry if the icons that you choose don't look exactly like they do on the design. + +Some suggestions can be found below: + +- [Font Awesome](https://fontawesome.com) +- [IcoMoon](https://icomoon.io) +- [Ionicons](https://ionicons.com) \ No newline at end of file