Skip to content

Commit

Permalink
Created toggler
Browse files Browse the repository at this point in the history
  • Loading branch information
JulieSagan committed Dec 28, 2024
1 parent 2aa382a commit 398dad4
Show file tree
Hide file tree
Showing 2 changed files with 111 additions and 8 deletions.
57 changes: 49 additions & 8 deletions 07-lection5/03-toggler/index.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,52 @@
<!DOCTYPE html>
<!-- Страница с кнопкой переключения -->
<html lang="ru">
<head>
<link rel="stylesheet" href="../../assets/css/main.css">
<link rel="stylesheet" href="./toggler.css">
</head>
<body>

</body>
</html>

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

<title>Toggler</title>

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

<body>
<div class="container">
<label class="toggler">
<input class="toggler__input" type="checkbox">
<div class="toggler__state">
<div class="toggler__control">
<i class="toggler__icon" data-feather="circle"></i>
</div>
<div class="toggler__label">Off</div>
</div>
</label>

<label class="toggler">
<input class="toggler__input" type="checkbox" checked>
<div class="toggler__state">
<div class="toggler__control">
<i class="toggler__icon" data-feather="circle"></i>
</div>
<div class="toggler__label">On</div>
</div>
</label>

<label class="toggler">
<input class="toggler__input" type="checkbox" disabled>
<div class="toggler__state">
<div class="toggler__control">
<i class="toggler__icon" data-feather="circle"></i>
</div>
<div class="toggler__label">Disabled</div>
</div>
</label>
</div>

<script>
feather.replace();
</script>
</body>

</html>
62 changes: 62 additions & 0 deletions 07-lection5/03-toggler/toggler.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
.toggler {
display: flex;
flex-direction: column;
position: relative;
}

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

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

.toggler__control {
display: flex;
align-items: center;
width: 52px;
height: 28px;
border: 1px solid var(--grey-2, #DDE2E5);
border-radius: 16px;
}

.toggler__icon {
color: var(--grey-2, #DDE2E5);
}

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

.toggler__input:checked ~ .toggler__state .toggler__control {
border-color: var(--blue, #374FC7);
background-color: var(--blue, #374FC7);
justify-content: flex-end;
}

.toggler__input:checked ~ .toggler__state .toggler__icon {
color: var(--white, #ffffff);
justify-content: right;
}

.toggler__input:focus ~ .toggler__state .toggler__label {
text-decoration: underline;
}

.toggler__input:disabled ~ .toggler__state .toggler__control {
border-color: var(--grey-2, #DDE2E5);
background-color: var(--grey-2, #DDE2E5);
}

.toggler__input:disabled ~ .toggler__state .toggler__icon {
color: var(--grey-3, #ACB5BD);
}

0 comments on commit 398dad4

Please sign in to comment.