Skip to content
This repository was archived by the owner on Feb 15, 2025. It is now read-only.

Commit 950a770

Browse files
committed
updated readme
1 parent 5320eb5 commit 950a770

File tree

7 files changed

+60
-6
lines changed

7 files changed

+60
-6
lines changed

.github/img/landing.png

109 KB
Loading

README.md

+19-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,22 @@
1-
# Website
2-
3-
This website is built using [Docusaurus 2](https://v2.docusaurus.io/), a modern static website generator.
1+
# agile-ts.org
2+
3+
[This website](https://agile-ts.org) is built using
4+
[Docusaurus 2](https://v2.docusaurus.io/). Pages & components are written in TypeScript, the styles in vanilla CSS with
5+
variables using
6+
[CSS Modules](https://github.com/css-modules/css-modules).
7+
(We would have preferred using [styled-components](https://styled-components.com/) but docusaurus has no ssr support for
8+
it yet)
9+
10+
<div align="center">
11+
<a href="http://questdb.io">
12+
<img src=".github/img/landing.png"/>
13+
</a>
14+
</div>
15+
<div align="center">
16+
<a href="https://agile-ts.org" style="color: #1e2136">
17+
agile-ts.org
18+
</a>
19+
</div>
420

521
## Installation
622

src/_pages/LandingPage/components/HeaderView/components/Astronaut/index.tsx

+39-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { animated, useSpring } from 'react-spring';
2-
import React, { useEffect, useState } from 'react';
2+
import React, { useEffect, useRef, useState } from 'react';
33
import { useAgile } from '@agile-ts/react';
44
import core from '../../../../../../core';
55
import styles from './styles.module.css';
@@ -34,11 +34,48 @@ const Astronaut: React.FC<Props> = (props) => {
3434
return () => clearTimeout(timeoutId);
3535
}, [isRaised, timing]);
3636

37-
const trigger = () => setIsRaised(true);
37+
const imageRef = useRef<HTMLImageElement>(null);
38+
const ctx = document.createElement('canvas').getContext('2d');
39+
40+
// https://medium.com/@pdx.lucasm/canvas-with-react-js-32e133c05258
41+
// https://stackoverflow.com/questions/38487569/click-through-png-image-only-if-clicked-coordinate-is-transparent
42+
function trigger(event: React.MouseEvent<HTMLImageElement, MouseEvent>) {
43+
console.log('on click');
44+
45+
console.log(event);
46+
console.log(ctx);
47+
48+
// Get click coordinates
49+
const x = event.pageX - imageRef.current.offsetLeft;
50+
const y = event.pageY - imageRef.current.offsetTop;
51+
const w = (ctx.canvas.width = imageRef.current.width);
52+
const h = (ctx.canvas.height = imageRef.current.height);
53+
54+
// Draw image to canvas
55+
// and read Alpha channel value
56+
ctx.drawImage(imageRef.current, 0, 0, w, h);
57+
const alpha = ctx.getImageData(x, y, 1, 1).data[3]; // [0]R [1]G [2]B [3]A
58+
59+
console.log(ctx.getImageData(x, y, 1, 1));
60+
61+
// If pixel is transparent,
62+
// retrieve the element underneath and trigger it's click event
63+
if (alpha === 0) {
64+
console.log('alpha0');
65+
imageRef.current.style.pointerEvents = 'none';
66+
const element = document.elementFromPoint(event.clientX, event.clientY);
67+
// element.trigger('click');
68+
imageRef.current.style.pointerEvents = 'auto';
69+
} else {
70+
setIsRaised(true);
71+
console.log('LOGO clicked!');
72+
}
73+
}
3874

3975
return (
4076
<div className={clsx(styles.Container, className)}>
4177
<animated.img
78+
ref={imageRef}
4279
onMouseEnter={trigger}
4380
style={animated_Astronaut}
4481
className={styles.Image}

src/_pages/LandingPage/components/HeaderView/components/Astronaut/styles.module.css

+1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@
1313
.Image {
1414
width: 100%;
1515
max-width: 800px;
16+
background-color: red;
1617
}

src/core/entities/ui/ui.controller.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ export const THEME = App.createState<ThemeInterface>(
2020
});
2121

2222
export const ASTRONAUT_DARK = App.createState<boolean>(false).persist(
23-
'astronaut-color'
23+
'astronaut-dark'
2424
);
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)