Skip to content

Instantly share code, notes, and snippets.

@Renik07
Renik07 / price.ts
Last active November 6, 2022 20:19
Add spaces between numbers
const price = (value: number) => value.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ' ') + ' $';
// 99 450 $
price(99450);
@Renik07
Renik07 / declension.ts
Created November 6, 2022 20:14
Word declension (склонение слов)
const wordDecl = (number:number, titles:[string, string, string]):string => {
const cases = [2, 0, 1, 1, 1, 2];
return titles[ (number % 100 > 4 && number % 100 < 20) ? 2 : cases[(number % 10 < 5) ? number % 10 : 5] ];
}
wordDecl(product.reviewCount, ["отзыв", "отзыва", "отзывов"])
@Renik07
Renik07 / eng.js
Last active October 18, 2021 14:45
Multilanguages site
// 2
export default {
'cat': 'Cat',
'bird': 'Bird',
'dog': 'Dog',
}
@Renik07
Renik07 / Curved block
Last active September 18, 2021 20:44
Curved block
<body>
<div class="container">
<div class="separator separatop-top">
<svg version="1.1" viewBox="0 0 100 100" preserveAspectRatio="none"><path d="M 0 0 C 40 132 60 132 100 0 Z" style="fill: white;"></path></svg>
</div>
<div class="separator separator-bottom">
<svg version="1.1" viewBox="0 0 100 100" preserveAspectRatio="none"><path d="M 0 100 C 40 -32 60 -32 100 100 Z" style="fill: rgb(255, 255, 255);"></path></svg>
</div>
<div class="content">
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Mollitia voluptatem autem quod harum, necessitatibus nemo molestiae quos! Similique tempore blanditiis possimus unde tempora vitae autem voluptatum temporibus? Rerum, expedita odit?</p>
@Renik07
Renik07 / btn.css
Last active September 16, 2021 20:30
CodePen Home Button with border-radius and gradient
.btn {
display: flex;
justify-content: center;
align-items: center;
width: 300px;
height: 50px;
text-transform: uppercase;
text-decoration: none;
padding: 10px;
color: #000;