Skip to content

Commit

Permalink
Merge pull request #19 from JulieSagan/checkbox
Browse files Browse the repository at this point in the history
Created checkbox
  • Loading branch information
jsru-1 authored Jan 7, 2025
2 parents 08a47fa + 63e6d0a commit 3259cde
Show file tree
Hide file tree
Showing 2 changed files with 128 additions and 8 deletions.
72 changes: 72 additions & 0 deletions 07-lection5/01-checkbox/checkbox.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
.checkbox {
display: inline-block;
position: relative;
vertical-align: middle; /* параметр позволяет выравнить иконку по вертикали */
}

.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;
}
64 changes: 56 additions & 8 deletions 07-lection5/01-checkbox/index.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,59 @@
<!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">
<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>
</label>
</div>


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

</html>

0 comments on commit 3259cde

Please sign in to comment.