Skip to content

Commit

Permalink
feat: add smooth scroll and spacing to page
Browse files Browse the repository at this point in the history
  • Loading branch information
moonbamijam committed May 30, 2024
1 parent 653e384 commit b52c2f8
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 24 deletions.
22 changes: 22 additions & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import Section from "./components/common/section/Section";
import Header from "./components/header/Header";
import Color from "./components/sections/color/Color";

const App = () => {
return (
<>
<Header />
<main>
<Section
id="color_section"
title={"colors"}
desc={"Basic colors ready for use!"}
>
<Color />
</Section>
</main>
</>
);
};

export default App;
9 changes: 2 additions & 7 deletions src/components/common/grid/Grid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,12 @@ import { ReactNode } from "react";
import gridStyles from "./grid.module.scss";

export type GridType = {
id: string;
className?: string;
children: ReactNode;
};

const Grid = ({ id, className, children }: GridType) => {
return (
<div id={id} className={`${gridStyles.grid} ${className}`}>
{children}
</div>
);
const Grid = ({ className, children }: GridType) => {
return <div className={`${gridStyles.grid} ${className}`}>{children}</div>;
};

export default Grid;
7 changes: 4 additions & 3 deletions src/components/common/section/Section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@ import { ReactNode } from "react";
import sectionStyles from "./section.module.scss";

type SectionProps = {
id: string;
children: ReactNode;
title: string;
desc: string;
};

const Section = ({ children, title, desc }: SectionProps) => {
const Section = ({ id, children, title, desc }: SectionProps) => {
return (
<section id={title} className={`container ${sectionStyles.section}`}>
<section id={id} className={`container ${sectionStyles.section}`}>
<div className={`${sectionStyles.heading}`}>
<h2 className={`${sectionStyles.title}`}>{title}</h2>
<h1 className={`${sectionStyles.title}`}>{title}</h1>
<p className={`${sectionStyles.desc}`}>{desc}</p>
</div>
{children}
Expand Down
2 changes: 2 additions & 0 deletions src/components/common/section/section.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
display: flex;
flex-direction: column;
align-items: center;
padding: 100px 0;
.heading {
margin-bottom: 16px;
.title {
text-transform: capitalize;
text-align: center;
font-size: 2.5rem;
}
.desc {
text-align: center;
Expand Down
6 changes: 1 addition & 5 deletions src/components/sections/color/Color.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,7 @@ const Color = () => {
));
};

return (
<Grid id="color_grid" className={`${colorStyles.color_grid}`}>
{renderColors()}
</Grid>
);
return <Grid className={`${colorStyles.color_grid}`}>{renderColors()}</Grid>;
};

export default Color;
12 changes: 6 additions & 6 deletions src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React from 'react'
import ReactDOM from 'react-dom/client'
import App from './App.tsx'
import "./sassy/main.scss";
import React from "react";
import ReactDOM from "react-dom/client";
import App from "./App.tsx";
import "./styles/globals.scss";

ReactDOM.createRoot(document.getElementById('root')!).render(
ReactDOM.createRoot(document.getElementById("root")!).render(
<React.StrictMode>
<App />
</React.StrictMode>,
)
);
8 changes: 5 additions & 3 deletions src/styles/globals.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@
transition: all 150ms ease-in-out;
}

html {
scroll-behavior: smooth;
}

body {
background-color: $background;
height: 1500px;
}
main {
padding: 100px 0;
}

0 comments on commit b52c2f8

Please sign in to comment.