Skip to content

Instantly share code, notes, and snippets.

View tonkec's full-sized avatar
🚀
focusing

Antonija Šimić tonkec

🚀
focusing
View GitHub Profile
type FC<P = {}> = FunctionComponent<P>;
interface FunctionComponent<P = {}> {
(props: PropsWithChildren<P>, context?: any): ReactElement<any, any> | null;
propTypes?: WeakValidationMap<P> | undefined;
contextTypes?: ValidationMap<any> | undefined;
defaultProps?: Partial<P> | undefined;
displayName?: string | undefined;
}
@tonkec
tonkec / index.jsx
Created August 27, 2024 12:09
toggling-audio-in-react-without-re-rendering-component
import React, { useRef, useEffect } from 'react';
import p5 from 'p5';
function Game() {
const audioRef = useRef(new Audio('/path/to/your/audio/file.mp3'));
let audioButton;
useEffect(() => {
// Using p5.js to create the audio toggle button
const sketch = (p) => {
@tonkec
tonkec / index.html
Created June 14, 2022 18:24
Prvo predavanje za HTML i CSS
<html>
<head>
<title>Nasa prva web stranica</title>
</head>
<body>
<h1> Moj prvi heading. </h1>
<h2> Moj drugi heading. </h2>
</body>
</html>
//why is es6 important
/*
lots of syntax sugar
faster solutions
cleaner solutions
*/
// arrow functions
  • Centering 101
    • vertical and horizontal centering in any situation
  • Import vs link
  • flexbox vs grid
  • Pseudo elements
    • what, how and why
  • bem vs. smacss
  • oocss
  • Intro to Bulma
  • family.scss and other cool libraries
@tonkec
tonkec / Filter.js
Created March 18, 2019 15:49
test_feature_for_xircles
import React from 'react';
const KeywordHighlighter = (props) => {
const allowedKeywords = ["dosage", "happy", "sunny"]; // just some random words that would be highlighted
const filteredKeywords = allowedKeywords.filter((word) => props.value.includes(word));
return (
<div>
<textarea
type="text"
name="keyword"
const incrementCount = ( {incrementBy = 1 } = {} ) => {
return {
type: 'INCREMENT',
incrementBy
}
}
@tonkec
tonkec / step3.js
Created March 6, 2019 11:41
default value is set to 1
const incrementCount = ( {incrementBy = 1 } = {} ) => {
console.log(incrementBy) // propery on the payload object
/*
payload = {
incrementBy: 5
}
*/
return {
type: 'INCREMENT',
incrementBy: incrementBy
const incrementCount = ( {incrementBy} = {} ) => {
console.log(incrementBy) // propery on the payload object
/*
payload = {
incrementBy: 5
}
*/
return {
type: 'INCREMENT',
incrementBy: typeof incrementBy === "number" ? incrementBy : 1
// action generator returns action object!!
const incrementCount = ( payload = {} ) => {
// if payload doesn't exist it defaults to {}
// calling property on undefined object will throw an error
// payload is an object passed to incrementCount
return {
// returns new action object!
type: 'INCREMENT',
incrementBy: typeof payload.incrementBy === "number" ? payload.incrementBy : 1
}