Every block
should be in separated file named as block.
Filename: rating-star.scss
.rating-star {
$font-size: 0.5em;
display: inline-block; // `display` style may be set freely
type ResponseWithData = Response & { data?: any }; | |
interface Fetcher { | |
run(input: RequestInfo, init?: RequestInit): Promise<ResponseWithData>; | |
} | |
class BasicFetcher implements Fetcher { | |
async run(input: RequestInfo, init?: RequestInit): Promise<ResponseWithData> { | |
return await fetch(input, init); | |
} |
import React, { useState, useEffect } from 'react' | |
import { useDebounce } from './use-debounce' | |
const MySearchComponent = props => { | |
const [search, setSearch, { | |
signal, | |
debouncing | |
}] = useDebounce('') | |
const [results, setResults] = useState([]) |
In production, it is recommended to minify any JavaScript code that is included with your application. Minification can help your website load several times faster, especially as the size of your JavaScript source code grows.
Here's one way to set it up:
npm init -y
in your project folder (don't skip this step!)npm install terser
Now, to minify a file called like_button.js
, run in the terminal:
<div class="top" title="Наверх"><i class="fa fa-angle-double-up"></i></div> | |
.top | |
position: fixed | |
bottom: 25px | |
background-color: #E0E0E0 | |
border-radius: 10em | |
color: #666 | |
font-size: 26px | |
width: 50px |
$(".scroll-next").click(function() { | |
var cls = $(this).closest(".section").next().offset().top; | |
$("html, body").animate({scrollTop: cls}, "slow"); | |
}); |
'use strict'; | |
// Требует node.js и пакета mkdirp | |
// Пакет mkdirp: https://www.npmjs.com/package/mkdirp#install — установить глобально или прописать установку в package.json, в секции devDependencies | |
// Использование: | |
// - поместить этот файл в корень проекта | |
// - исправить пути к генерируемым папкам и файлам, если блоки проекта лежат не в ./src/blocks/ | |
// - в терминале, будучи в корневой папке проекта, выполнить node createBlock.js [имя блока] [доп. расширения через пробел] | |
const fs = require('fs'); // будем работать с файловой системой |
{ | |
"name": "foo", | |
"version": "1.0.0", | |
"description": "foo project", | |
"main": "index.js", | |
"scripts": { | |
"start": "npm run serve | npm run watch-css", | |
"serve": "./node_modules/.bin/http-server -p 8080", | |
"build-css": "./node_modules/node-sass/bin/node-sass app/sass/style.scss -o app/css/ && ./node_modules/postcss-cli/bin/postcss --use autoprefixer app/css/style.css -d app/css/", | |
"watch-css": "nodemon -e scss -x 'npm run build-css'" |