Skip to content

Commit fd9a20d

Browse files
committed
refactored textimagebox, image display now it's owncomponent, and fixed some css placement issues
1 parent ce3e18f commit fd9a20d

File tree

6 files changed

+81
-29
lines changed

6 files changed

+81
-29
lines changed

src/App.tsx

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,29 @@ import React from 'react';
22
import About from './components/About';
33
import Header from './components/Header';
44

5+
56
const App: React.FC = () => {
67
return (
7-
<div className=" min-h-screen mt-0 flex items-center justify-center">
8-
{/* Top-Left Text for Large Screens */}
9-
<div className="absolute top-0 left-0 p-5 hidden md:block">
10-
<Header text="trsctr.github.io" textSize="text-2xl" className="tracking-widest font-mono" hasGradient gradientColors="from-accent to-primary"/>
11-
</div>
12-
<About title="Hello, my name is Otto" imageUrl="src/assets/meika.jpg" imageOnRight>
13-
<p className="mb-2">
14-
This is my webpage.
15-
</p>
16-
<p>
17-
There are many like it, but this one is mine.
18-
</p>
19-
<p className="mt-2">
20-
Something something something about something and I like cats and good music.</p>
21-
<p className="mt-2">I'm beginning to like Tailwind. It's useful and makes CSS less nervewracking than it could be.</p>
8+
9+
<div className="bg-black min-h-screen mt-0 flex items-center justify-center w-full h-full">
10+
11+
<div className="absolute top-0 left-0 p-5 hidden md:block">
12+
<Header text="trsctr.github.io" textSize="text-2xl" className="tracking-widest font-mono" hasGradient gradientColors="from-primary to-secondary"/>
13+
</div>
14+
<About title="Hello, my name is Otto" imageUrl="src/assets/meika.jpg" imageOnRight>
15+
<p className="mb-2">
16+
This is my webpage.
17+
</p>
18+
<p>
19+
There are many like it, but this one is mine.
20+
</p>
21+
<p className="mt-2">
22+
Something something something about something and I like cats and good music.</p>
23+
<p className="mt-2">I'm beginning to like Tailwind. It's useful and makes CSS less nervewracking than it could be.</p>
2224

23-
<p className="mt-2">Which is nice.</p>
24-
</About>
25-
</div>
25+
<p className="mt-2">Which is nice.</p>
26+
</About>
27+
</div>
2628
);
2729
};
2830

src/components/About.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,27 @@ interface AboutProps {
1111
children?: React.ReactNode;
1212
}
1313

14+
/*
15+
* A component that displays an about section with an image.
16+
*
17+
* @param title The title of the about section.
18+
* @param imageUrl The URL of the image to display.
19+
* @param imageOnRight Whether to display the image on the right side of the text box.
20+
* @param children The content to display in the about section.
21+
*/
1422
const About: React.FC<AboutProps> = ( {title, imageUrl, children, imageOnRight = false}) => {
1523
return (
16-
<div className="absolute left-0 top-0 md:top-1/4 md:left-32 w-full md:w-9/12 max-w-[900px]">
24+
<div className="absolute flex left-0 top-0 md:top-1/4 md:left-32 w-full md:w-9/12 max-w-[900px]">
1725
<ContentBox className="rounded-lg shadow-lg">
1826
{title && <Header text={title} gradientColors="from-primary to-secondary" hasGradient/>}
1927
<TextImageBox imageUrl={imageUrl} imageOnRight={imageOnRight}>
2028
{children}
2129
</TextImageBox>
22-
<Footer/>
30+
<Footer/>
2331
</ContentBox>
32+
2433
</div>
34+
2535
);
2636
};
2737

src/components/ContentBox.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,18 @@ interface ContentBoxProps {
66
children: React.ReactNode
77
}
88

9+
/*
10+
* A component that displays a content box with a background color.
11+
*
12+
* @param background The background color of the content box.
13+
* @param className Additional classes to apply to the content box.
14+
* @param children The content to display in the content box.
15+
*/
916
const ContentBox: React.FC<ContentBoxProps> = ({ background = "bg-background", className, children }) => {
1017
return (
1118
<section className={`${background} relative p-4 flex justify-center ${className}`}>
1219
{/* Content Box */}
13-
<div className="w-full">
20+
<div className="w-full flex-col">
1421
{children}
1522
</div>
1623
</section>

src/components/Footer.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
11
import React from 'react';
22

3+
/*
4+
* A component that displays the footer of the page.
5+
*/
6+
37
const Footer: React.FC = () => {
48
return (
59
<footer className="bg-transparent">
610
<div className="mx-auto w-full pt-2 md:pt-5 md:flex md:items-center md:justify-between">
711
<ul className="flex flex-wrap items-center mt-3 text-sm font-medium text-primary sm:mt-0">
12+
<li>
13+
<a href="http://github.com/trsctr/trsctr.github.io" className="hover:underline hover:text-accent me-4 md:me-12">Source code</a>
14+
</li>
815
<li>
916
<a href="http://github.com/trsctr" className="hover:underline hover:text-accent me-4 md:me-12">GitHub</a>
1017
</li>
18+
1119
<li>
1220
<a href="#" className="hover:underline hover:text-accent me-4 md:me-12">LinkedIn</a>
1321
</li>

src/components/Header.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,18 @@ interface HeaderProps {
99
textSize?: string;
1010
}
1111

12+
/*
13+
* A component that displays a header with optional gradient text.
14+
*
15+
* @param text The text to display in the header.
16+
* @param color The color of the text.
17+
* @param gradientColors The gradient colors to apply to the text.
18+
* @param className Additional classes to apply to the header.
19+
* @param hasGradient Whether to apply a gradient to the text.
20+
* @param textSize The size of the text.
21+
*/
1222
const Header: React.FC<HeaderProps> = ({ text, color = "text-text", gradientColors, className, hasGradient = false, textSize = "text-4xl lg:text-6xl" }) => {
23+
// tsekkaa clsx
1324
let gradientSettings = ""
1425
if (hasGradient && gradientColors)
1526
gradientSettings = "text-transparent bg-clip-text bg-gradient-to-r " + gradientColors;

src/components/TextImageBox.tsx

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,37 @@ interface TextImageBoxProps {
77
altText?: string;
88
}
99

10+
const TextImage: React.FC<Pick<TextImageBoxProps, 'imageUrl' | 'altText'>> = ({ imageUrl, altText = "Image"}) => {
11+
return (
12+
<div className="w-full sm:flex flex-shrink-0 justify-center md:block md:w-1/4 mx-4 mb-0 lg:mb-4">
13+
<img src={`${imageUrl}`} alt={altText} className="w-full max-w-[250px] md:max-w-[200px] mx-auto justify-center rounded" />
14+
</div>
15+
)
16+
};
17+
18+
/*
19+
* A component that displays a text box with an image on the left or right.
20+
*
21+
* @param imageUrl The URL of the image to display.
22+
* @param children The content to display in the text box.
23+
* @param imageOnRight Whether to display the image on the right side of the text box.
24+
* @param altText The alt text for the image.
25+
*/
1026
const TextImageBox: React.FC<TextImageBoxProps> = ({ imageUrl, children, imageOnRight = false, altText = "Image"}) => {
1127
return (
12-
<div className="flex flex-col sm:flex-row text-text text-lg items-start pt-5">
28+
<div className="flex flex-col md:flex-row text-text text-lg items-center md:items-start pt-5">
1329
{!imageOnRight && imageUrl && (
14-
<div className="flex-shrink-0 hidden md:block w-1/4 ml-4 mb-0 lg:mb-4">
15-
<img src={`${imageUrl}`} alt={altText} className="w-full max-w-[200px] h-auto rounded" />
16-
</div>
30+
<TextImage imageUrl={imageUrl} altText={altText}/>
1731
)}
18-
<div className="flex-1 flex-col justify-between">
32+
<div className="flex flex-1 flex-col items-start justify-start">
1933
{children}
2034
</div>
2135
{imageOnRight && imageUrl && (
22-
<div className="flex-shrink-0 hidden md:block w-1/4 ml-4 mb-0 lg:mb-4 mr-0">
23-
<img src={`${imageUrl}`} alt={altText} className="w-full max-w-[200px] h-auto rounded" />
24-
</div>
36+
<TextImage imageUrl={imageUrl} altText={altText}/>
2537
)}
2638
</div>)
2739
};
2840

41+
42+
2943
export default TextImageBox;

0 commit comments

Comments
 (0)