Styling Approach
EducaStream uses CSS Modules for component styling, providing scoped styles that prevent naming conflicts and promote maintainability.
CSS Modules Pattern
Every component has its own CSS module file following the naming convention: ComponentName.module.css
File Structure
Components/
└── Button/
├── Button.jsx
└── Button.module.css
Import Pattern
import Styles from "./ComponentName.module.css" ;
const Component = () => {
return < div className = { Styles . containerClass } > Content </ div > ;
};
Component Styling Examples
CSS Custom Properties
EducaStream uses CSS custom properties (variables) for consistent theming:
Color Variables
/* Global CSS variables used throughout components */
var(--color-primary) /* Primary brand color */
var(--color-background) /* Main background color */
var(--color-background-button) /* Button background */
var(--color-background-off-two) /* Secondary background */
var(--color-background-details) /* Detail sections */
var(--color-text-primary) /* Primary text color */
var(--color-text-secondary) /* Secondary text color */
var(--color-text-off) /* Muted text color */
var(--color-hover) /* Hover state color */
Spacing & Layout Variables
var(--radius) /* Border radius */
var(--box-shadow) /* Box shadow */
var(--pd-2) /* Padding level 2 */
These CSS variables enable consistent theming across all components and make it easy to implement dark/light mode switching.
Responsive Design Patterns
Mobile-First Approach Components are styled for mobile by default, with media queries for larger screens: /* Mobile styles (default) */
.navbarLinks {
display : flex ;
flex-direction : column ;
position : absolute ;
opacity : 0 ;
}
/* Desktop styles */
@media screen and ( min-width : 768 px ) {
.navbarLinks {
display : flex ;
opacity : 1 ;
position : relative ;
}
.navbarLinks ul {
display : flex ;
gap : 17 px ;
}
.navbarToggle {
display : none ;
}
}
Common Breakpoints /* Small devices */
@media ( max-width : 425 px ) {
nav {
margin : 0 px ;
justify-content : space-around ;
}
}
/* Tablets and up */
@media screen and ( min-width : 768 px ) {
.navbarLinks {
position : relative ;
}
}
Standard breakpoints:
Mobile: < 425px
Tablet: 768px+
Desktop: 1024px+
Common Styling Patterns
Layout Containers
/* Centered container pattern */
.container {
width : 90 % ;
margin : auto ;
}
/* Flexbox column layout */
.contentContainer {
display : flex ;
flex-direction : column ;
align-items : center ;
padding : var ( --pd-2 );
}
Interactive Elements
/* Hover effects */
.cardContainer:hover {
border : 2 px solid var ( --color-hover );
}
.imgContainer img {
cursor : pointer ;
transition : transform 0.2 s ease ;
}
/* Button transitions */
.cssButtonSharpBlue {
transition : all 0.3 s ease-out ;
}
.cssButtonSharpBlue:hover {
background : var ( --color-background-button );
color : var ( --color-primary );
}
Image Handling
/* Responsive images */
.imgContainer img {
min-width : 100 % ;
min-height : 100 % ;
object-fit : cover ;
}
/* Logo sizing */
.navbarLogo img {
height : 50 px ;
}
/* Profile images */
.imgProfile img {
width : 35 px ;
height : 35 px ;
border-radius : 25 px ;
}
Modal & Overlay Styles
Modal Component Styling .modal {
background-color : var ( --color-background-details );
box-shadow : var ( --box-shadow );
border-radius : 0 0 5 px 5 px ;
position : absolute ;
top : 35 px ;
right : 0 ;
padding : 30 px ;
z-index : 97 ;
min-width : 300 px ;
}
.modalContent {
display : flex ;
flex-direction : column ;
gap : 16 px ;
color : var ( --color-text-primary );
}
Typography Patterns
/* Price display */
.contentTopPrice {
color : var ( --color-primary );
font-weight : bold ;
font-size : 20 px ;
}
/* Discounted price */
.priceWhitOutDiscount {
font-size : 12 px ;
color : var ( --color-text-off );
text-decoration : line-through ;
}
/* Category badges */
.title span {
color : var ( --color-text-secondary );
background-color : var ( --color-background-off-two );
padding : 3 px 7 px ;
border-radius : 25 px ;
font-size : 10 px ;
font-weight : bold ;
}
Best Practices
CSS Modules Always use CSS Modules for scoped styling
Variables Use CSS custom properties for theming
Mobile First Design for mobile, enhance for desktop
Transitions Add smooth transitions for interactions
Avoid inline styles. Use CSS modules to keep styling consistent and maintainable. Inline styles should only be used for dynamic values that cannot be predefined.
Creating Styled Components
When creating a new component:
Create CSS Module
Create a .module.css file alongside your component Components/NewComponent/NewComponent.module.css
Import Styles
Import the CSS module in your component import Styles from "./NewComponent.module.css" ;
Use Class Names
Apply styles using the Styles object < div className = { Styles . container } >
< h2 className = { Styles . title } > Title </ h2 >
</ div >
Use CSS Variables
Leverage existing CSS custom properties .container {
background : var ( --color-background );
color : var ( --color-text-primary );
}