Skip to content

Commit 9a314be

Browse files
HsharmaCodingayushishahh
authored andcommitted
React CSS Basics
0 parents  commit 9a314be

26 files changed

+12197
-0
lines changed

information

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
**************************************Basics of CSS**********************************************
2+
> Styling React Components
3+
1. CSS Stylesheet Regular css stylesheet
4+
2. Inline Styling
5+
3. CSS Modules
6+
4. CSS in js Libraries (Styled Components)
7+
> Here we will cover only first three approaches.
8+
9+
1. CSS Stylesheet (Regular css stylesheet)
10+
> src/Components/Stylesheet.tsx
11+
> src/myStyle.css
12+
> CSS file has been imported to the Stylesheet.tsx
13+
> Stylesheet Component has been calling from the App.tsx
14+
> Applied primay class without condtions.
15+
> Applied promary class with props conditionally. props has been passing from the App.tsx
16+
> If we want to apply multiple class then we have to use the template litterals.
17+
> <h1 className={`${className} font-xl`}>Multiple Class</h1>
18+
19+
2. Inline Styling
20+
> Style name should be in camel case version. (Example: fontSize)
21+
> src/Components/Inline.tsx
22+
> Inline.tsx component has been used in the App.tsx
23+
24+
3. CSS Modules (Available to react version 2.00 or higher)
25+
> There are some file naming convenstions for CSS Modules.
26+
> File name must be suffix with .module.css
27+
> For example create a two style sheet.
28+
> src/applyStyle.css (Regular Stylesheet)
29+
> src/applyStyle.module.css (CSS Modules)
30+
> Import regular style sheet in App.tsx
31+
> import '../src/applyStyle.css';;
32+
> Import CSS Modules style sheet in App.tsx
33+
> import styles from '../src/applyStyle.module.css';
34+
> CSS Modules classes are locally scoped. We can not use the same class in child component.
35+
This classes are bind with styles attribues, Means we can access the classes after importing the styles attribute.
36+
> For Example:
37+
> We have imported applyStyle.css file in parent component (App.tsx). So all the child
38+
component can access the classes of applyStyle.css
39+
> Similar we have imported applyStyle.module.css file in parent component (App.tsx). But
40+
We can not use it's classes in child component, because to use module.css we have to
41+
import styles attribute then we can access it's classes.
42+
43+
44+
45+
46+
47+
48+
49+

react-css-basic-app/.gitignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
11+
# production
12+
/build
13+
14+
# misc
15+
.DS_Store
16+
.env.local
17+
.env.development.local
18+
.env.test.local
19+
.env.production.local
20+
21+
npm-debug.log*
22+
yarn-debug.log*
23+
yarn-error.log*

react-css-basic-app/README.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Getting Started with Create React App
2+
3+
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
4+
5+
## Available Scripts
6+
7+
In the project directory, you can run:
8+
9+
### `npm start`
10+
11+
Runs the app in the development mode.\
12+
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
13+
14+
The page will reload if you make edits.\
15+
You will also see any lint errors in the console.
16+
17+
### `npm test`
18+
19+
Launches the test runner in the interactive watch mode.\
20+
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
21+
22+
### `npm run build`
23+
24+
Builds the app for production to the `build` folder.\
25+
It correctly bundles React in production mode and optimizes the build for the best performance.
26+
27+
The build is minified and the filenames include the hashes.\
28+
Your app is ready to be deployed!
29+
30+
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
31+
32+
### `npm run eject`
33+
34+
**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
35+
36+
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.
37+
38+
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.
39+
40+
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.
41+
42+
## Learn More
43+
44+
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
45+
46+
To learn React, check out the [React documentation](https://reactjs.org/).

0 commit comments

Comments
 (0)