Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/kaplanh/react-styled-components


https://github.com/kaplanh/react-styled-components

props-drilling react react-icons react-props styled-components themeprovider

Last synced: 3 days ago
JSON representation

Awesome Lists containing this project

README

        

# React Styled Components Example

[:point_right: Click here to see on browser](https://react-styled-components-ten.vercel.app/)

![react styled-components](https://github.com/kaplanh/React-Styled-Components/assets/101884444/c9973af2-a959-421d-ae77-4fb20b17b340)

---

| **What's used in this app ?** | **How use third party libraries** | **Author** |
| ---------------------------------------------------------------------------------- | --------------------------------- | ------------------------------------------------------------- |
| [React Styled Components](https://styled-components.com/docs/basics) | npm i/yarn add styled-components | [Take a look at my portfolio](https://kaplanh.github.io/Portfolio_with_CssFlex/) |
| [React icons](https://www.npmjs.com/package/react-icons) | | [Visit me on Linkedin](https://www.linkedin.com/in/kaplan-h/) |
| [Semantic-Commits](https://gist.github.com/joshbuchea/6f47e86d2510bce28f8e7f42ae84c716) | | |
| Deploy with [Vercel](https://vercel.com/kaplanh) | | |

---

## How To Run This Project πŸš€


### πŸ’» Install React πŸ‘‡

```bash
yarn create react-app . or npx create-react-app .
```

### πŸ’» Install Sass πŸ‘‡

```bash
yarn add sass or npm i sass
```

## πŸ”΄ Delete these files and delete the importsπŸ‘‡

- App.test.js
- reportWebVitals.js
- setupTests.js
- favicon.ico
- logo192.png
- logo512.png
- manifest.json
- robots.txt

### πŸ’» Start the project πŸ‘‡

```bash
yarn start or npm start
```

OR

- Clone the Repo

```sh
git clone
```

- Install NPM packages

```sh
npm install or yarn
```

- Run the project

```sh
npm start or yarn start
```

- Open the project on your browser

```sh
http://localhost:3000/
```

- ### Enjoy! πŸŽ‰

---

## Project Skeleton

```
reaact styleed components-example(folder)
|
|----public (folder)
β”‚ └── index.html
β”‚ └── images(folder)
|----src (folder)
β”‚ β”‚
β”‚ β”œ--- components(folder)
β”‚ | β”œ--- styles (folder)
| | | |
β”‚ | | β”œ---Button.styled.jsx
β”‚ | | β”œ---Card.styled.jsx
β”‚ | | β”œ---Container.styled.jsx
β”‚ | | β”œ---Flex.styled.jsx
β”‚ | | β”œ---Footer.styled.jsx
β”‚ | | β”œ---GlobalStyles.jsx
β”‚ | | β”œ---Header.styled.jsx
β”‚ | | β”œ---SocialIcons.styled.jsx
| | |
| | |--- Card.jsx
| | |--- Footer.jsx
| | |--- Header.jsx
| | |--- SocialIcons.jsx
| |
| |
β”‚ β”œ--- App.js
β”‚ β”œ--- data.js
β”‚ |--- index.js
β”‚
β”‚
|── .gitignore
|── package-lock.json
β”œβ”€β”€ package.json
|── README.md
|── yarn.lock

```

---

### At the end of the project, the following topics are to be covered;

- styled-components ThemeProvider & theme

```jsx
import Header from "./components/Header";
import { ThemeProvider } from "styled-components";
import { GlobalStyles } from "./components/styles/GlobalStyles";
import data from "./data";
import Card from "./components/Card";
import Footer from "./components/Footer";
import Container from "./components/styles/Container.styled";

const theme = {
colors: {
header: "#fff",
body: "#fff",
footer: "#8A1C4A",
primary: "#bebe",
secondary: "#dde0e2ed",
},
responsive: "768px",
breakpoints: { xs: "300px", sm: "500px", md: "700px" },
margin: {},
padding: {},
};
const App = () => {
return (




{data.map((item, index) => {
return ;
})}



);
};

export default App;

2.asama
//Flex.styled.jsx
import styled from "styled-components";

const Flex = styled.div`
display: flex;
align-items: center;
gap: 2rem;
& > div,
& > ul {
/*!TΓΌm elemanlarΔ±n buyumesine izin ver*/
flex-grow: 1;
/* Tüm div'lerin eşit miktarda alan tutabilmesine izin ver.*/
flex-basis: 0;
}
@media (max-width: ${({ theme }) => theme.responsive}) {
flex-direction: column;
text-align: center;
}


`;

export default Flex;

```

- styled-components div

```jsx
1.asama
//Container.styled.jsx

import styled from "styled-components";

const Container = styled.div`
width: 1000px;
max-width: 100%;
padding: 0 20px;
margin: 0 auto;
`;

export default Container;

2.asama
//App.jsx
import Container from "./components/styles/Container.styled";

const App = () => {
return (


{data.map((item, index) => {
return ;
})}

);
};

export default App;

```
- styled-components props & extend & css

```jsx
1.asama
//Button.styled.jsx

//! escb ile buttondan component olusturma kisayolu

import styled, { css } from "styled-components";

const Button = styled.button`
background-color: ${({ bg }) => bg || "#fff"};
color: ${({ color }) => color || "#fff"};
border: 1px solid #a62440;
border-radius: 5px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.15);
padding: 1rem 1.2rem;
font-size: 1.1rem;
margin-right: 0.5rem;
margin: 2rem 0.5rem;
cursor: pointer;
&:hover {
opacity: 0.9;
transform: scale(0.98);
}

/* !bg property e sahip olana css yardimiyla birden fazla ΓΆzellikte verebiliriz */

/* ${({ bg }) =>
bg &&
css`
background-color: #a62440;
color: #fff;
border: 1px solid #a62440;
border-radius: 5px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.15);
padding: 1rem 1.2rem;
font-size: 1.1rem;
margin-right: 0.5rem;
margin: 2rem 0.5rem;
cursor: pointer;
&:hover {
opacity: 0.9;
transform: scale(0.98);
}
`} */
`;

export default Button;

//! extends yukardaki button'un tΓΌm ΓΆzelliklerini alip istediklerimi degistirebiliyor yada ek ΓΆzellik ekleyebiliyorum
// export const DarkButton = styled(Button)`
// background-color: white;
// color: red;
// border: 2px solid red;
// `;

2.asama
//Header.jsx
import Button from "./styles/Button.styled";
import Container from "./styles/Container.styled";
import Flex from "./styles/Flex.styled";
import StyledHeader, { Image, Logo, Nav } from "./styles/Header.styled";

const Header = () => {
return (





Apply Courses
Talk to Adviser



The IT Career of Your Dreams Starts Here!



Clarusway is a leading international software
Bootcamp. Join a micro class online with other
trainees and learn coding skills with a
highly-skilled instructor.


Start Your New Carier





);
};

export default Header;

```

- Semantic Commit Messages
See how a minor change to your commit message style can make you a better programmer.

Format: ():

is optional

- Example

```
feat: add hat wobble
^--^ ^------------^
| |
| +-> Summary in present tense.
|
+-------> Type: chore, docs, feat, fix, refactor, style, or test.
```

- More Examples:
- `feat`: (new feature for the user, not a new feature for build script)
- `fix`: (bug fix for the user, not a fix to a build script)
- `docs`: (changes to the documentation)
- `style`: (formatting, missing semi colons, etc; no production code change)
- `refactor`: (refactoring production code, eg. renaming a variable)
- `test`: (adding missing tests, refactoring tests; no production code change)
- `chore`: (updating grunt tasks etc; no production code change)

---

## Feedback and Collaboration

I value your feedback and suggestions. If you have any comments, questions, or ideas for improvement regarding this project or any of my other projects, please don't hesitate to reach out.
I'm always open to collaboration and welcome the opportunity to work on exciting projects together.
Thank you for visiting my project. I hope you have a wonderful experience exploring it, and I look forward to connecting with you soon!

βŒ› Happy Coding ✍