Skip to content

Instantly share code, notes, and snippets.

View newbornfrontender's full-sized avatar
🐣
Time to code

Infant Frontender newbornfrontender

🐣
Time to code
  • Russia
View GitHub Profile
import fs from 'fs/promises';
import path from 'path';
import htmlnano from 'htmlnano';
import html from '@rollup/plugin-html';
const env = process.env.NODE_ENV;
const isProd = env === 'production';
const template = async ({ attributes, files, title }) => {
@newbornfrontender
newbornfrontender / readme.md
Last active April 29, 2020 12:09
Svelte FAQ

Вопрос / Question

RU

Ответ

import { FC, useState, useEffect } from 'react';
import { Count, Timer } from './styled';
interface IProps {
initialTime: number;
}
const Countdown: FC<IProps> = ({ initialTime }) => {
const [strokeDasharray, setStrokeDasharray] = useState('283');
@newbornfrontender
newbornfrontender / index.js
Created March 4, 2020 10:12
React with HTM
import styled from 'reshadow';
import html from './shared';
import { createRoot } from 'react-dom';
import './index.css';
const App = () => styled(null)`
h1 {
color: red;
}
`(html`
@newbornfrontender
newbornfrontender / main.ts
Created January 16, 2020 12:38
microbit - temperature and accelerometer test
const getTemperature = (): number => input.temperature();
const printTemperature = (): void => basic.showNumber(getTemperature())
const showIcon = (name: IconNames): void => basic.showIcon(name)
const isButtonPressed = (button: Button): boolean => input.buttonIsPressed(button)
basic.forever(() => {
const isAPressed = isButtonPressed(Button.A)
const isBPressed = isButtonPressed(Button.B)
if (isAPressed) printTemperature()
@newbornfrontender
newbornfrontender / input.js
Created January 9, 2020 14:31
babel class fields and pipline operator
const Point = class {
x = 0;
y = 0;
};
const serializable = Category => class extends Category {
toString() {
return `[${this.x}, ${this.y}]`;
}
};
@newbornfrontender
newbornfrontender / .eslintrc.js
Last active November 24, 2019 09:42
svelte - testting
module.exports = {
parserOptions: {
sourceType: 'module',
},
env: {
es2020: true,
browser: true,
node: true,
jest: true,
},
@newbornfrontender
newbornfrontender / Table.tsx
Created October 5, 2019 16:34
Redirect example
import React from 'react';
import axios from 'axios';
import { Redirect } from 'react-router-dom';
import { Row } from './Row';
import { createTable } from '../helpers';
export const Table: React.FC = () => {
const url = 'http://localhost:5000';
@newbornfrontender
newbornfrontender / helpers.tsx
Created October 5, 2019 16:28
Game - helpers
export const createTable = (rowNum: number, cellNum: number): number[][] => {
const row: number[] = Array(rowNum).fill(0);
const table: number[][] = Array(cellNum)
.fill(row)
.map((row: number[]) => [...row]);
return table;
};
export const recalculateTable = (table: number[][], index: number, value: number): number[][] => {
@newbornfrontender
newbornfrontender / Cell.tsx
Created September 29, 2019 12:14
4 in a row
import React from 'react';
import styled, { ThemeProvider } from 'styled-components';
type Props = {
children: React.ReactNode;
};
function Cell(props: Props) {
const theme = {
color: convertColor(props.children),