This commit is contained in:
@@ -13,7 +13,7 @@
|
||||
* @param {AppuntiCardProps} param0
|
||||
* @returns
|
||||
*/
|
||||
export const AppuntiCard = ({ image, course, title, author, courseYear }) => {
|
||||
export const AppuntiCard = ({ course, title, author, courseYear }) => {
|
||||
return (
|
||||
<div class="appunti-item">
|
||||
<div class="thumbnail"></div>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { effect, useComputed, useSignal } from '@preact/signals'
|
||||
import { useComputed, useSignal } from '@preact/signals'
|
||||
import Fuse from 'fuse.js'
|
||||
import { useEffect } from 'preact/hooks'
|
||||
import { ShowMore } from './Paginate'
|
||||
@@ -67,22 +67,22 @@ export const UtentiPage = () => {
|
||||
$filter.value === 'macchinisti'
|
||||
? $utentiData.value.filter(user => MACCHINISTI.includes(user.uid))
|
||||
: $filter.value === 'rappstud'
|
||||
? $utentiData.value.filter(user => RAPPSTUD.includes(user.uid))
|
||||
: $utentiData.value,
|
||||
? $utentiData.value.filter(user => RAPPSTUD.includes(user.uid))
|
||||
: $utentiData.value
|
||||
)
|
||||
|
||||
const $fuse = useComputed(
|
||||
() =>
|
||||
new Fuse($filteredData.value, {
|
||||
keys: ['gecos', 'uid'],
|
||||
}),
|
||||
})
|
||||
)
|
||||
|
||||
const $searchText = useSignal('')
|
||||
const $searchResults = useComputed(() =>
|
||||
$searchText.value.trim().length > 0
|
||||
? ($fuse.value?.search($searchText.value).map(result => result.item) ?? [])
|
||||
: $filteredData.value,
|
||||
? $fuse.value?.search($searchText.value).map(result => result.item) ?? []
|
||||
: $filteredData.value
|
||||
)
|
||||
|
||||
useEffect(() => {
|
||||
@@ -107,7 +107,7 @@ export const UtentiPage = () => {
|
||||
<>
|
||||
<span class="material-symbols-outlined">{v.icon}</span> {v.label}
|
||||
</>,
|
||||
]),
|
||||
])
|
||||
)}
|
||||
</ComboBox>
|
||||
<div class="search">
|
||||
@@ -130,8 +130,8 @@ export const UtentiPage = () => {
|
||||
{RAPPSTUD.includes(poissonUser.uid)
|
||||
? 'account_balance'
|
||||
: MACCHINISTI.includes(poissonUser.uid)
|
||||
? 'construction'
|
||||
: 'person'}
|
||||
? 'construction'
|
||||
: 'person'}
|
||||
</span>
|
||||
</div>
|
||||
<div class="text">{poissonUser.gecos}</div>
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { useEffect, useMemo, useState } from 'preact/hooks'
|
||||
import { useEffect, useState } from 'preact/hooks'
|
||||
|
||||
export const trottleDebounce = <T extends any[], R>(
|
||||
fn: (...args: T) => R,
|
||||
delay: number,
|
||||
options: { leading?: boolean; trailing?: boolean } = {},
|
||||
options: { leading?: boolean; trailing?: boolean } = {}
|
||||
): ((...args: T) => R | undefined) => {
|
||||
let lastCall = 0
|
||||
let lastResult: R | undefined
|
||||
|
||||
+20
-21
@@ -60,8 +60,8 @@ const RENDERER_FPS = 30
|
||||
function setup() {
|
||||
console.log('Setting up circuits art...')
|
||||
|
||||
$canvas.width = $canvas.clientWidth
|
||||
$canvas.height = $canvas.clientHeight
|
||||
$canvas.width = $canvas.clientWidth * window.devicePixelRatio
|
||||
$canvas.height = $canvas.clientHeight * window.devicePixelRatio
|
||||
|
||||
const g = $canvas.getContext('2d')!
|
||||
const state: State = {
|
||||
@@ -75,14 +75,19 @@ function setup() {
|
||||
const handle = window.setInterval(() => {
|
||||
const time = new Date().getTime() - startTime.getTime()
|
||||
|
||||
update(state, g.canvas.width, g.canvas.height, time)
|
||||
update(
|
||||
state,
|
||||
g.canvas.width / window.devicePixelRatio,
|
||||
g.canvas.height / window.devicePixelRatio,
|
||||
time
|
||||
)
|
||||
render(g, state, time)
|
||||
}, 1000 / RENDERER_FPS)
|
||||
|
||||
renderer = { timer: handle }
|
||||
}
|
||||
|
||||
function update(state: State, width: number, height: number, time: number) {
|
||||
function update(state: State, width: number, _height: number, _time: number) {
|
||||
const w = (width / CELL_SIZE) | 0
|
||||
// const h = (height / CELL_SIZE) | 0
|
||||
|
||||
@@ -166,14 +171,20 @@ const RENDER_CELL: Record<WireCell, (g: CanvasRenderingContext2D) => void> = {
|
||||
},
|
||||
}
|
||||
|
||||
function render(g: CanvasRenderingContext2D, state: State, time: number) {
|
||||
function render(g: CanvasRenderingContext2D, state: State, _time: number) {
|
||||
const WIDTH = g.canvas.width / window.devicePixelRatio
|
||||
const HEIGHT = g.canvas.height / window.devicePixelRatio
|
||||
|
||||
g.clearRect(0, 0, g.canvas.width, g.canvas.height)
|
||||
|
||||
g.resetTransform()
|
||||
g.scale(window.devicePixelRatio, window.devicePixelRatio)
|
||||
g.scale(CELL_SIZE, CELL_SIZE)
|
||||
|
||||
g.lineWidth = 3 / CELL_SIZE
|
||||
|
||||
const w = (g.canvas.width / CELL_SIZE) | 0
|
||||
const h = (g.canvas.height / CELL_SIZE) | 0
|
||||
const w = (WIDTH / CELL_SIZE) | 0
|
||||
const h = (HEIGHT / CELL_SIZE) | 0
|
||||
for (let y = 0; y <= h + 1; y++) {
|
||||
for (let x = 0; x <= w + 1; x++) {
|
||||
if (!state.grid.has([x, y])) continue
|
||||
@@ -235,18 +246,6 @@ function randomChoice<T>(choices: T[]): T {
|
||||
return choices[randomInt(0, choices.length - 1)]
|
||||
}
|
||||
|
||||
function randomWeightedChoice<T>(choices: [T, number][]) {
|
||||
return
|
||||
}
|
||||
|
||||
// 3 + 4 + 5 + 6
|
||||
randomWeightedChoice([
|
||||
['a', 3],
|
||||
['b', 4],
|
||||
['c', 5],
|
||||
['d', 6],
|
||||
])
|
||||
|
||||
const DIR_TO_VEC: Record<WireDirection, Point2> = {
|
||||
['down']: [0, 1],
|
||||
['down-left']: [-1, 1],
|
||||
@@ -277,14 +276,14 @@ const DIR_AVAILABLE_PREDICATE: Record<WireDirection, (pos: Point2, grid: Grid<Wi
|
||||
function pruneDirections(
|
||||
grid: Grid<WireCell>,
|
||||
position: Point2,
|
||||
directions: WireDirection[],
|
||||
directions: WireDirection[]
|
||||
): WireDirection[] {
|
||||
return directions.filter(dir => DIR_AVAILABLE_PREDICATE[dir](position, grid))
|
||||
}
|
||||
|
||||
function generateWire(
|
||||
grid: Grid<WireCell>,
|
||||
startingPoint: Point2,
|
||||
startingPoint: Point2
|
||||
): { position: Point2; direction: WireCell }[] {
|
||||
const segmentLength = Math.floor(1 - Math.random() ** 2) * 10 + 30
|
||||
let currentPosition = startingPoint
|
||||
|
||||
Reference in New Issue
Block a user