Skip to content

Commit 8c81432

Browse files
committed
Humor-joke light
1 parent 5869987 commit 8c81432

File tree

2 files changed

+35
-5
lines changed

2 files changed

+35
-5
lines changed

src/components/TARSBlock.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -75,17 +75,18 @@ class TARSBlock extends HTMLElement {
7575
background: #444;
7676
}
7777
78-
.face-1::after,
79-
.face-2::after,
80-
.face-5::after,
81-
.face-6::after {
78+
.face-1::before,
79+
.face-2::before,
80+
.face-5::before,
81+
.face-6::before {
8282
content: "";
8383
display: block;
8484
width: 100%;
8585
height: 100%;
8686
background: linear-gradient(to bottom, #fff3, #0003);
8787
position: absolute;
8888
top: 0;
89+
opacity: 1;
8990
}
9091
`;
9192
}

src/components/TARSFaceMain.js

+30-1
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,17 @@ class TARSFaceMain extends HTMLElement {
3333
color: #1BE820;
3434
font-size: 2px;
3535
white-space: pre;
36+
z-index: 1;
37+
position: relative;
3638
}
3739
3840
.black.screen::before {
3941
content: "";
4042
width: 100%;
4143
height: 20%;
4244
display: block;
43-
background: #2225;
45+
background: #222a;
46+
z-index: 2;
4447
}
4548
4649
.text {
@@ -61,6 +64,21 @@ class TARSFaceMain extends HTMLElement {
6164
letter-spacing: -5px;
6265
}
6366
67+
.joke {
68+
background: #9CBEAB;
69+
width: 5px;
70+
height: 5px;
71+
position: absolute;
72+
top: 4px;
73+
left: 2px;
74+
opacity: 0;
75+
transition: opacity: 0.1s;
76+
}
77+
78+
.joke.on {
79+
opacity: 1;
80+
}
81+
6482
.center {
6583
display: grid;
6684
grid-template-columns: 1fr 1fr;
@@ -77,6 +95,7 @@ class TARSFaceMain extends HTMLElement {
7795

7896
getTerminalText() {
7997
return `
98+
<div class="joke"></div>
8099
Welcome to TARS Corporation (TM) Terminal
81100
Copyright (C) 2984-2987, TARS Corp. Software
82101
OS version: 22A1-9166-69
@@ -102,6 +121,16 @@ class TARSFaceMain extends HTMLElement {
102121

103122
connectedCallback() {
104123
this.render();
124+
const time = ~~(Math.random() * 5000);
125+
setTimeout(() => this.enableJoke(), time);
126+
}
127+
128+
enableJoke() {
129+
const joke = this.shadowRoot.querySelector(".joke");
130+
joke.classList.add("on");
131+
setTimeout(() => joke.classList.remove("on"), 2000);
132+
const time = 5000 + ~~(Math.random() * 30000);
133+
setTimeout(() => this.enableJoke(), time);
105134
}
106135

107136
render() {

0 commit comments

Comments
 (0)