Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Created checkbox #19

Merged
merged 4 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 78 additions & 0 deletions 07-lection5/01-checkbox/checkbox.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
.checkbox {
display: inline-block;
position: relative;
vertical-align: middle; /* параметр позволяет выравнить иконку по вертикали */
}

.checkbox__wrapper {
display: flex;
flex-direction: column;
gap: 16px;
}

.checkbox__input {
position: absolute;
left: -100vh;
}

.checkbox__state{
display: flex;
gap: 12px;
align-items: center;
}

.checkbox__square {
display: flex;
align-items: center;
justify-content: center;
width: 28px;
height: 28px;
border-radius: 4px;
border: 1px solid var(--grey-2, #DDE2E5);
}

.checkbox__icon{
display: none;
fill: none;
stroke-width: 3px;
}

.checkbox__label {
color: var(--gray-4, #495057);
font-family: Inter, sans-serif;
font-size: 16px;
font-style: normal;
font-weight: 400;
line-height: 1.5;
}

.checkbox__input:checked ~ .checkbox__state .checkbox__square {
background-color: var(--blue, #374FC7);
border-color: var(--blue, #374FC7);
}

.checkbox__input:checked ~ .checkbox__state .checkbox__icon {
display: block;
color: var(--white, #ffffff);
}

.checkbox__input:focus ~ .checkbox__state .checkbox__label {
text-decoration: underline;
}

.checkbox__input:disabled ~ .checkbox__state .checkbox__square {
background-color: var(--grey-2, #DDE2E5);
border-color: var(--grey-2, #DDE2E5);
}

.checkbox__input:disabled ~ .checkbox__state .checkbox__icon {
display: none;
}

.checkbox__input:disabled ~ .checkbox__state .checkbox__label {
color: var(--grey-2, #DDE2E5);
}

.checkbox__input:disabled ~ .checkbox__state {
cursor: not-allowed;
}
68 changes: 60 additions & 8 deletions 07-lection5/01-checkbox/index.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,63 @@
<!DOCTYPE html>
<!-- Страница чекбокса -->
<html lang="ru">
<head>
<link rel="stylesheet" href="../../assets/css/main.css">
<link rel="stylesheet" href="./checkbox.css">
</head>
<body>

</body>
</html>

<head>
<link rel="stylesheet" href="../../assets/css/main.css">
<link rel="stylesheet" href="./checkbox.css">

<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>Checkbox</title>

<script src="https://unpkg.com/feather-icons"></script>
</head>

<body>
<div class="container">
<label class="checkbox">
<div class="checkbox__wrapper">
GSemikozov marked this conversation as resolved.
Show resolved Hide resolved
<input class="checkbox__input" type="checkbox">
<div class="checkbox__state">
<div class="checkbox__square">
<i data-feather="check" class="checkbox__icon"></i>
</div>
<div class="checkbox__label">Default</div>
</div>
</label>

<label class="checkbox">
<input class="checkbox__input" type="checkbox" checked>
<div class="checkbox__state">
<div class="checkbox__square">
<i data-feather="check" class="checkbox__icon"></i>
</div>
<div class="checkbox__label">Checked</div>
</div>
</label>

<label class="checkbox">
<input class="checkbox__input" type="checkbox" disabled>
<div class="checkbox__state">
<div class="checkbox__square">
<i data-feather="check" class="checkbox__icon"></i>
</div>
<div class="checkbox__label">Disabled</div>
</div>
</div>


</label>
</div>


<script>
feather.replace({
width: '1.2rem',
height: '1.2rem'
});
</script>
</body>

</html>
Loading