Skip to content

Commit 65db678

Browse files
committed
wip: pixel frid
1 parent e465663 commit 65db678

File tree

6 files changed

+107
-185
lines changed

6 files changed

+107
-185
lines changed

src/components/pixel-grid/index.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import './styles.css';
2+
3+
// --------------------------------------------------------------------------------
4+
5+
export function createPixelGrid(options: {
6+
rows: number;
7+
cols: number;
8+
pixelSize: number;
9+
colors: string[];
10+
emptyBias?: 'left' | 'right' | 'none';
11+
emptyRatio?: number; // 0 to 1, how many cells are empty in the biased area
12+
}) {
13+
const { rows, cols, pixelSize, colors, emptyBias = 'none', emptyRatio = 0.5 } = options;
14+
const grid = document.createElement('div');
15+
grid.className = 'pixel-grid';
16+
grid.style.gridTemplateRows = `repeat(${rows}, ${pixelSize}px)`;
17+
grid.style.gridTemplateColumns = `repeat(${cols}, ${pixelSize}px)`;
18+
19+
for (let r = 0; r < rows; r++) {
20+
for (let c = 0; c < cols; c++) {
21+
let isEmpty = false;
22+
if (emptyBias === 'left' && c < cols / 2) {
23+
isEmpty = Math.random() < emptyRatio;
24+
} else if (emptyBias === 'right' && c >= cols / 2) {
25+
isEmpty = Math.random() < emptyRatio;
26+
}
27+
if (!isEmpty) {
28+
const pixel = document.createElement('div');
29+
pixel.className = 'pixel';
30+
pixel.style.background = colors[Math.floor(Math.random() * colors.length)];
31+
grid.appendChild(pixel);
32+
} else {
33+
const empty = document.createElement('div');
34+
empty.className = 'pixel pixel-empty';
35+
grid.appendChild(empty);
36+
}
37+
}
38+
}
39+
return grid;
40+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
.pixel-grid {
2+
position: absolute;
3+
top: 0;
4+
left: 0;
5+
width: 100%;
6+
height: 100%;
7+
display: grid;
8+
pointer-events: none;
9+
z-index: 1;
10+
}
11+
12+
.pixel {
13+
width: 100%;
14+
height: 100%;
15+
opacity: 0.7;
16+
transition: background 0.2s;
17+
}
18+
.pixel-empty {
19+
background: transparent !important;
20+
opacity: 0;
21+
}

src/views/home/index.ts

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import './styles.css';
22
import {arrowButton, createVideoBackground, createWrapper, writeParagraph, writeTitle} from "../utils";
33
import {homePageContent} from "../../content/home";
4+
import { createPixelGrid } from '../../components/pixel-grid';
45

56
export type HomePageContentStructure = {
67
readonly hookHeading: string;
@@ -62,18 +63,28 @@ function philosophySection() {
6263

6364
section.className = 'philosophy';
6465
section.style.backgroundImage = `url('${homePageContent.philosophy.sectionBG}')`;
65-
article.appendChild(title);
6666

67+
// Create pixel grid using the component
68+
const pixelGrid = createPixelGrid({
69+
rows: 18,
70+
cols: 36,
71+
pixelSize: 24,
72+
colors: ['#3BFFC5', '#222', '#fff'],
73+
emptyBias: 'left',
74+
emptyRatio: 0.7
75+
});
76+
77+
78+
79+
section.appendChild(pixelGrid);
80+
81+
article.appendChild(title);
6782
homePageContent.philosophy.paragraphs.forEach(paragraph => {
6883
const p = writeParagraph(paragraph);
6984
article.appendChild(p);
7085
})
71-
7286
wrapper.appendChild(article);
7387
section.appendChild(wrapper);
7488

7589
return section;
7690
}
77-
78-
79-

src/views/home/styles.css

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
#home-page {
22

3+
#wrapper {
4+
z-index: 2;
5+
}
6+
7+
h2 {
8+
margin-bottom: 50px;
9+
}
10+
311
section {
412
width: 100%;
513
min-height: 100vh;
@@ -9,16 +17,16 @@
917
box-sizing: border-box;
1018
}
1119

20+
.highlight {
21+
text-decoration: underline;
22+
text-decoration-color: #3BFFC5;
23+
text-underline-offset: 20px;
24+
}
25+
1226
.hook {
1327
h1, p {
1428
text-shadow: 0 4px 55px rgba(0, 0, 0, 0.65);
1529
max-width: 1160px;
16-
17-
.highlight {
18-
text-decoration: underline;
19-
text-decoration-color: #3BFFC5;
20-
text-underline-offset: 20px;
21-
}
2230
}
2331

2432
article {
@@ -31,6 +39,7 @@
3139
height: 100vh;
3240

3341
.hook-text {
42+
font-size: 1.5em;
3443
margin-top: 75px;
3544
margin-bottom: 20px;
3645
max-width: 630px;
@@ -40,8 +49,19 @@
4049

4150
.philosophy {
4251
article {
43-
52+
position: relative;
53+
display: flex;
54+
width: 45%;
55+
flex-direction: column;
56+
justify-content: center;
57+
align-items: flex-start; /* <-- left-align children */
58+
height: 100vh;
4459
}
4560

61+
p {
62+
max-width: 60%;
63+
margin-bottom: 30px;
64+
text-align: left;
65+
}
4666
}
4767
}

src/views/styles.css

Lines changed: 1 addition & 171 deletions
Original file line numberDiff line numberDiff line change
@@ -4,182 +4,12 @@
44
font-family: 'Inter', sans-serif;
55

66
#wrapper {
7-
width: 95%;
7+
width: 90%;
88
margin: 0 auto;
99
}
1010
}
1111

12-
#view-box {
13-
height: 100%;
14-
font-family: "Cabin", sans-serif;
15-
16-
17-
#view-wrapper {
18-
width: 95%;
19-
margin: 0 auto;
20-
padding-top: 60px;
21-
22-
section {
23-
margin:0;
24-
padding: 58px 0;
25-
clear: both;
26-
}
27-
28-
.showcase {
29-
margin: 50px 0;
30-
width: 100%;
31-
border: #080808 solid 3px;
32-
}
33-
34-
.video-showcase::before, .video-showcase::after {
35-
content: "";
36-
display: block;
37-
width: 100%;
38-
padding-top: 65px;
39-
z-index: -2;
40-
background-image: url("utils/assets/video-showcase-decoration.png");
41-
background-blend-mode: multiply;
42-
background-repeat: repeat-x;
43-
filter: invert(100%) sepia(100%) hue-rotate(240deg) saturate(100%);
44-
}
45-
46-
.video-showcase::before {
47-
margin-bottom: -15px;
48-
}
49-
50-
.video-showcase::after {
51-
margin-top: -15px;
52-
transform: scaleY(-1);
53-
}
54-
55-
.video-showcase video {
56-
width: 100%;
57-
border-radius: 15px;
58-
z-index: 5;
59-
position: relative;
60-
}
61-
62-
.gallery-content {
63-
padding-top: 20px;
64-
}
65-
66-
.gallery-content img {
67-
object-fit: cover;
68-
width: 45%;
69-
aspect-ratio:1/1;
70-
margin: 10px 0;
71-
margin-right: 4%;
72-
border: 2px solid #505050;
73-
border-radius: 10px;
74-
}
75-
76-
.link {
77-
font-family: "Handjet", serif;
78-
display: inline-block;
79-
color: #828282;;
80-
font-size: 2.5em;
81-
font-weight: normal;
82-
padding: 0 30px 15px 0;
83-
text-align: center;
84-
text-decoration-color: #3BFFC5;
85-
}
86-
87-
#home-page {
88-
.cd-covers-selection {
89-
display: grid;
90-
grid-template-columns: repeat(3, 1fr);
91-
gap: 40px;
92-
justify-items: center;
93-
align-items: center;
94-
width: 170%; /* wider than wrapper */
95-
max-width: none;
96-
margin-left: -35%; /* center and overflow */
97-
position: relative;
98-
z-index: 1;
99-
padding: 40px 0;
100-
101-
}
102-
}
103-
104-
#about-page {
105-
106-
.intro {
107-
text-align: center;
108-
padding-bottom: 50px;
109-
display: block;
110-
}
111-
112-
.title {
113-
font-family: "Handjet", serif;
114-
font-size: 2.5em;
115-
font-weight: 600;
116-
color: #3BFFC5;
117-
text-transform: lowercase;
118-
}
11912

120-
.grid-category {
121-
display: grid;
122-
padding: 50px 0 0 0;
123-
margin: 0 0 25px 0;
124-
border-top: 2px dashed #505050;
125-
grid-template-columns: repeat(6, 1fr);
126-
gap: 2%;
127-
128-
h2 {
129-
grid-column: span 6;
130-
}
131-
132-
.grid-item {
133-
margin: 0 0 50px 0;
134-
grid-column: span 3;
135-
136-
137-
.subtitle {
138-
color: white;
139-
}
140-
141-
.text {
142-
font-size: 1em;
143-
}
144-
}
145-
}
146-
147-
.achievements, .profile-links {
148-
border-top: 2px dashed #505050;
149-
padding: 50px 0 0 0;
150-
margin: 0 0 25px 0;
151-
152-
.item {
153-
margin: 0 0 50px 0;
154-
}
155-
}
156-
157-
}
158-
159-
#home-page {
160-
161-
h1 {
162-
margin: 0 auto 50px auto;
163-
164-
}
165-
166-
.intro-block {
167-
text-align: center;
168-
}
169-
170-
}
171-
}
172-
173-
.three-background {
174-
position: fixed;
175-
background-color: #000000;
176-
top: 0;
177-
left: 0;
178-
width: 100%;
179-
height: 100%;
180-
z-index: -15;
181-
}
182-
}
18313

18414

18515

src/views/utils/styles.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ h6 {
3737
}
3838

3939
p {
40-
font-size: 1.5em;
40+
font-size: 1em;
4141
font-weight: normal;
4242
color: white;
43-
line-height: 110%;
43+
line-height: 130%;
4444
margin: 0;
4545
}
4646

0 commit comments

Comments
 (0)