This commit is contained in:
zakhy 2024-09-24 08:13:46 +07:00
commit bfa312651d
36 changed files with 570 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.idea

112
css/style.css Normal file
View File

@ -0,0 +1,112 @@
@import "../fonts/Manrope/font.css";
.inputs {
width: 500px;
display: flex;
flex-direction: column;
gap: 40px;
}
/*colors.css*/
:root {
--border-gray: #C9C8D3;
--c-primary: #0A5BFF;
--text-gray: #8A8894;
--text-dark: #00133B;
--input-bg: #fff
}
/*inputs.css*/
/* Основные стили для полей ввода */
.c-input {
background-color: var(--input-bg);
border: 2px solid var(--border-gray);
width: 100%;
height: 57px;
border-radius: 8px;
font-family: Manrope, sans-serif;
font-size: 18px;
color: var(--text-gray);
padding-left: 16px;
transition: border 0.3s ease, color 0.3s ease
}
.c-input:focus {
color: var(--text-dark);
border: 2px solid var(--c-primary);
outline: none;
}
.c-label {
color: var(--text-gray);
font-size: 14px;
font-family: Manrope, sans-serif;
padding: 0 16px 4px 16px;
transition: color 0.3s ease;
cursor: pointer;
}
.c-labeled-input {
user-select: none; /* Для современных браузеров */
-moz-user-select: none; /* Для Firefox */
-webkit-user-select: none; /* Для Safari */
-ms-user-select: none; /* Для Internet Explorer/Edge */
}
.c-labeled-input:focus-within .c-label {
color: var(--c-primary);
}
@keyframes focus-border-animation {
from {
border-color: var(--border-gray);
}
to {
border-color: var(--c-primary);
}
}
.c-input:focus {
animation: focus-border-animation 0.3s forwards;
}
/*password*/
/*num*/
input[type="number"] {
-webkit-appearance: textfield;
-moz-appearance: textfield;
appearance: textfield;
}
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
-webkit-appearance: none;
}
/*date*/
.calendar-icon {
position: absolute;
right: 10px;
top: 50%;
pointer-events: none; /* Иконка не будет мешать кликам по input */
font-size: 18px; /* Размер иконки */
color: #555; /* Цвет иконки */
}
.calendar-icon {
color: #8A8894; /* Цвет иконки - красный */
}
.input-with-icon:focus-within .calendar-icon {
color: var(--c-primary);
}
.input-with-icon {
position: relative;
display: inline-block;
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

84
fonts/Manrope/font.css Normal file
View File

@ -0,0 +1,84 @@
@font-face {
font-family: 'Manrope';
src: url('Manrope-Bold.eot');
src: local('Manrope Bold'), local('Manrope-Bold'),
url('Manrope-Bold.eot?#iefix') format('embedded-opentype'),
url('Manrope-Bold.woff2') format('woff2'),
url('Manrope-Bold.woff') format('woff'),
url('Manrope-Bold.ttf') format('truetype');
font-weight: bold;
font-style: normal;
}
@font-face {
font-family: 'Manrope';
src: url('Manrope-Semibold.eot');
src: local('Manrope Semibold'), local('Manrope-Semibold'),
url('Manrope-Semibold.eot?#iefix') format('embedded-opentype'),
url('Manrope-Semibold.woff2') format('woff2'),
url('Manrope-Semibold.woff') format('woff'),
url('Manrope-Semibold.ttf') format('truetype');
font-weight: 600;
font-style: normal;
}
@font-face {
font-family: 'Manrope';
src: url('Manrope-Regular.eot');
src: local('Manrope Regular'), local('Manrope-Regular'),
url('Manrope-Regular.eot?#iefix') format('embedded-opentype'),
url('Manrope-Regular.woff2') format('woff2'),
url('Manrope-Regular.woff') format('woff'),
url('Manrope-Regular.ttf') format('truetype');
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: 'Manrope';
src: url('Manrope-Light.eot');
src: local('Manrope Light'), local('Manrope-Light'),
url('Manrope-Light.eot?#iefix') format('embedded-opentype'),
url('Manrope-Light.woff2') format('woff2'),
url('Manrope-Light.woff') format('woff'),
url('Manrope-Light.ttf') format('truetype');
font-weight: 300;
font-style: normal;
}
@font-face {
font-family: 'Manrope';
src: url('Manrope-Thin.eot');
src: local('Manrope Thin'), local('Manrope-Thin'),
url('Manrope-Thin.eot?#iefix') format('embedded-opentype'),
url('Manrope-Thin.woff2') format('woff2'),
url('Manrope-Thin.woff') format('woff'),
url('Manrope-Thin.ttf') format('truetype');
font-weight: 100;
font-style: normal;
}
@font-face {
font-family: 'Manrope';
src: url('Manrope-Medium.eot');
src: local('Manrope Medium'), local('Manrope-Medium'),
url('Manrope-Medium.eot?#iefix') format('embedded-opentype'),
url('Manrope-Medium.woff2') format('woff2'),
url('Manrope-Medium.woff') format('woff'),
url('Manrope-Medium.ttf') format('truetype');
font-weight: 500;
font-style: normal;
}
@font-face {
font-family: 'Manrope';
src: url('Manrope-ExtraBold.eot');
src: local('Manrope ExtraBold'), local('Manrope-ExtraBold'),
url('Manrope-ExtraBold.eot?#iefix') format('embedded-opentype'),
url('Manrope-ExtraBold.woff2') format('woff2'),
url('Manrope-ExtraBold.woff') format('woff'),
url('Manrope-ExtraBold.ttf') format('truetype');
font-weight: 800;
font-style: normal;
}

7
icons/calendar.svg Normal file
View File

@ -0,0 +1,7 @@
<svg width="24" height="25" viewBox="0 0 24 25" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M19 4.5H5C3.89543 4.5 3 5.39543 3 6.5V20.5C3 21.6046 3.89543 22.5 5 22.5H19C20.1046 22.5 21 21.6046 21 20.5V6.5C21 5.39543 20.1046 4.5 19 4.5Z"
stroke="#8A8894" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M16 2.5V6.5" stroke="#8A8894" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M8 2.5V6.5" stroke="#8A8894" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M3 10.5H21" stroke="#8A8894" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
</svg>

After

Width:  |  Height:  |  Size: 677 B

93
index.html Normal file
View File

@ -0,0 +1,93 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/flatpickr/dist/flatpickr.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
<link rel="stylesheet" href="css/style.css">
<title>Библиотека UI компонентов</title>
</head>
<body>
<div style="display: grid; grid-template-columns: 1fr 1fr">
<div class="input-fields">
<h1>Поля ввода</h1>
<h2>Строка</h2>
<form class="inputs">
<div class="c-labeled-input">
<label for="username" class="c-label">Логин</label>
<input type="text" placeholder="Имя пользователя" class="c-input" id="username" autocomplete="username">
</div>
<div class="c-labeled-input">
<label for="password" class="c-label">Пароль</label>
<input type="password" placeholder="Пароль" class="c-input" id="password"
autocomplete="current-password">
<label for="password" class="c-label passwordVisibilityToggle">Показать пароль</label>
</div>
</form>
<h2>Число</h2>
<form class="inputs">
<div class="c-labeled-input">
<label for="num" class="c-label">Число</label>
<input type="number" placeholder="Введите число" class="c-input" id="num">
</div>
</form>
<h2>Дата</h2>
<form class="inputs">
<div class="c-labeled-input input-with-icon">
<label for="date-picker" class="c-label">Дата</label>
<input type="text" placeholder="Дата" class="c-input date-picker" id="date-picker" autocomplete="date">
<span class="calendar-icon">
<svg width="24" height="25" viewBox="0 0 24 25" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M19 4.5H5C3.89543 4.5 3 5.39543 3 6.5V20.5C3 21.6046 3.89543 22.5 5 22.5H19C20.1046 22.5 21 21.6046 21 20.5V6.5C21 5.39543 20.1046 4.5 19 4.5Z"
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M16 2.5V6.5" stroke="currentColor" stroke-width="2" stroke-linecap="round"
stroke-linejoin="round"/>
<path d="M8 2.5V6.5" stroke="currentColor" stroke-width="2" stroke-linecap="round"
stroke-linejoin="round"/>
<path d="M3 10.5H21" stroke="currentColor" stroke-width="2" stroke-linecap="round"
stroke-linejoin="round"/>
</svg>
</span>
</div>
</form>
</div>
<div class="buttons">
<h1>Кнопки & ссылки</h1>
<div style="width: 300px">
<button type="button">Войти</button>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/flatpickr"></script>
<script src="https://cdn.jsdelivr.net/npm/flatpickr/dist/l10n/ru.js"></script>
<script>
flatpickr(".date-picker", {
locale: "ru",
dateFormat: "Y-m-d",
monthSelectorType: "dropdown",
disableMobile: true,
onReady: function(selectedDates, dateStr, instance) {
styleDropdowns(instance);
}
});
function styleDropdowns(instance) {
const yearDropdown = instance.yearElements[0];
const monthDropdown = instance.monthElements[0];
yearDropdown.classList.add('styled-year-dropdown');
monthDropdown.classList.add('styled-month-dropdown');
}
</script>
<script src="js/script.js"></script>
<script src="js/showPassword.js"></script>
</body>
</html>

253
inputWithCalculator.html Normal file
View File

@ -0,0 +1,253 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="css/style.css">
<title>Input с калькулятором</title>
</head>
<body>
<style>
body {
font-family: Arial, sans-serif;
}
.c-input {
width: 200px;
height: 40px;
margin-right: 10px;
}
.modal {
display: none;
position: fixed;
z-index: 1;
left: 0;
top: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
}
.modal-content {
background-color: white;
margin: 15% auto;
padding: 20px;
border: 1px solid #888;
width: 300px;
}
.close {
color: #aaa;
float: right;
font-size: 28px;
font-weight: bold;
}
.close:hover,
.close:focus {
color: black;
text-decoration: none;
cursor: pointer;
}
.buttons {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 10px;
}
.calc-btn {
padding: 15px;
font-size: 18px;
cursor: pointer;
}
#calcInput {
width: 100%;
height: 40px;
margin-bottom: 10px;
text-align: right;
font-size: 18px;
}
</style>
<h1>Поле ввода с калькулятором</h1>
<div class="inputs">
<label for="numberInput">Введите число:</label>
<input type="number" id="numberInput" class="c-input" placeholder="0">
<button id="openCalculatorBtn">Открыть калькулятор</button>
</div>
<!-- Модальное окно калькулятора -->
<div id="calculatorModal" class="modal">
<div class="modal-content">
<span class="close">&times;</span>
<div id="calculator">
<input type="text" id="calcInput" disabled>
<div class="buttons">
<button class="calc-btn">1</button>
<button class="calc-btn">2</button>
<button class="calc-btn">3</button>
<button class="calc-btn">+</button>
<button class="calc-btn">4</button>
<button class="calc-btn">5</button>
<button class="calc-btn">6</button>
<button class="calc-btn">-</button>
<button class="calc-btn">7</button>
<button class="calc-btn">8</button>
<button class="calc-btn">9</button>
<button class="calc-btn">*</button>
<button class="calc-btn">0</button>
<button class="calc-btn">/</button>
<button id="clearBtn">C</button>
<button id="equalsBtn">=</button>
</div>
</div>
</div>
</div>
<script>
// Получение элементов
const numberInput = document.getElementById('numberInput');
const openCalculatorBtn = document.getElementById('openCalculatorBtn');
const calculatorModal = document.getElementById('calculatorModal');
const closeModal = document.querySelector('.close');
const calcInput = document.getElementById('calcInput');
const calcButtons = document.querySelectorAll('.calc-btn');
const equalsBtn = document.getElementById('equalsBtn');
const clearBtn = document.getElementById('clearBtn');
let calcExpression = '';
function createCalculatorElement() {
// Создаем модальное окно
const modal = document.createElement('div');
modal.id = 'calculatorModal';
modal.classList.add('modal');
// Создаем содержимое модального окна
const modalContent = document.createElement('div');
modalContent.classList.add('modal-content');
// Создаем кнопку для закрытия
const closeBtn = document.createElement('span');
closeBtn.classList.add('close');
closeBtn.innerHTML = '&times;';
// Добавляем кнопку закрытия в содержимое модального окна
modalContent.appendChild(closeBtn);
// Создаем сам калькулятор
const calculator = document.createElement('div');
calculator.id = 'calculator';
// Создаем поле вывода калькулятора
const calcInput = document.createElement('input');
calcInput.type = 'text';
calcInput.id = 'calcInput';
calcInput.disabled = true;
// Добавляем поле вывода в калькулятор
calculator.appendChild(calcInput);
// Создаем контейнер для кнопок калькулятора
const buttonsContainer = document.createElement('div');
buttonsContainer.classList.add('buttons');
// Массив всех кнопок калькулятора (значения)
const buttons = [
'1', '2', '3', '+',
'4', '5', '6', '-',
'7', '8', '9', '*',
'0', '/', 'C', '='
];
// Проходим по массиву и создаем кнопки
buttons.forEach(value => {
const button = document.createElement('button');
button.classList.add('calc-btn');
button.textContent = value;
// Специально задаем id для кнопок C и =
if (value === 'C') {
button.id = 'clearBtn';
}
if (value === '=') {
button.id = 'equalsBtn';
}
// Добавляем кнопку в контейнер кнопок
buttonsContainer.appendChild(button);
});
// Добавляем контейнер кнопок в калькулятор
calculator.appendChild(buttonsContainer);
// Добавляем калькулятор в содержимое модального окна
modalContent.appendChild(calculator);
// Добавляем содержимое модального окна в само модальное окно
modal.appendChild(modalContent);
// Добавляем модальное окно в тело страницы
document.body.appendChild(modal);
}
// Открытие калькулятора
openCalculatorBtn.addEventListener('click', () => {
calculatorModal.style.display = 'block';
});
// Закрытие калькулятора
closeModal.addEventListener('click', () => {
calculatorModal.style.display = 'none';
});
// Закрытие модального окна при клике вне его
window.addEventListener('click', (event) => {
if (event.target == calculatorModal) {
calculatorModal.style.display = 'none';
}
});
// Обработка нажатий кнопок калькулятора
calcButtons.forEach(button => {
button.addEventListener('click', () => {
const value = button.textContent;
if (['+', '-', '*', '/'].includes(value)) {
calcExpression += ` ${value} `;
} else {
calcExpression += value;
}
calcInput.value = calcExpression;
});
});
// Вычисление результата
equalsBtn.addEventListener('click', () => {
try {
const result = eval(calcExpression);
calcInput.value = result;
numberInput.value = result; // Заполнение результата в input
calcExpression = ''; // Очистка выражения после вычисления
} catch (e) {
calcInput.value = 'Ошибка';
calcExpression = '';
}
});
// Очистка выражения
clearBtn.addEventListener('click', () => {
calcExpression = '';
calcInput.value = '';
});
</script>
<script src="js/script.js"></script>
</body>
</html>

0
js/script.js Normal file
View File

20
js/showPassword.js Normal file
View File

@ -0,0 +1,20 @@
document.addEventListener('DOMContentLoaded', () => {
const targetEl = document.querySelector('.passwordVisibilityToggle')
targetEl.addEventListener('click', () => {
const parent = targetEl.parentNode
const childrenArr = Array.from(parent.children);
for (let item of childrenArr) {
if (item.localName === 'input') {
if (item.getAttribute('type') === 'password') {
targetEl.textContent = 'Скрыть пароль'
item.setAttribute('type', 'text');
} else {
item.setAttribute('type', 'password');
targetEl.textContent = 'Показать пароль'
}
return false;
}
}
})
})