This repository has been archived by the owner on Jan 7, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #42 from locaweb/switch-button
Switch button
- Loading branch information
Showing
10 changed files
with
156 additions
and
2 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
.switch-btn { | ||
position: relative; | ||
display: inline-block; | ||
user-select: none; | ||
} | ||
.switch-btn a { | ||
color: #555555; | ||
} | ||
.switch-btn .switch-label { | ||
display: inline-block; | ||
} | ||
.switch-btn .switch-label span { | ||
display: inline-block; | ||
vertical-align: middle; | ||
} | ||
.switch-btn .switch-label span:after { | ||
content: ""; | ||
-moz-user-select: -moz-none; | ||
-ms-user-select: none; | ||
-webkit-user-select: none; | ||
user-select: none; | ||
background: #888888 url(../images/ico-switch-on-off.png) -159px center no-repeat; | ||
height: 26px; | ||
width: 52px; | ||
position: relative; | ||
z-index: 0; | ||
margin-right: 10px; | ||
border-radius: 4px; | ||
display: inline-block; | ||
cursor: pointer; | ||
} | ||
.switch-btn .switch-label span:before { | ||
content: ""; | ||
-moz-transition: all 0.25s linear; | ||
-webkit-transition: all 0.25s linear; | ||
transition: all 0.25s linear; | ||
position: absolute; | ||
top: 2px; | ||
left: 2px; | ||
z-index: 1; | ||
display: block; | ||
width: 23px; | ||
height: 20px; | ||
border: 1px solid rgba(34, 34, 34, 0.15); | ||
background: white url(../images/ico-switch.png) center no-repeat; | ||
border-radius: 4px 0 0 4px; | ||
cursor: pointer; | ||
} | ||
.switch-btn .switch-label span:hover:before, .switch-btn .switch-label span:focus:before { | ||
background-color: #ebebeb; | ||
} | ||
.switch-btn .switch-label span:focus { | ||
outline: 5px auto -webkit-focus-ring-color; | ||
outline-offset: -2px; | ||
} | ||
.switch-btn input { | ||
display: block; | ||
cursor: pointer; | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
z-index: 2; | ||
width: 100%; | ||
height: 24px; | ||
opacity: 0; | ||
} | ||
.switch-btn input:checked + .switch-label span { | ||
display: inline-block; | ||
} | ||
.switch-btn input:checked + .switch-label span:after { | ||
box-shadow: none; | ||
background-position: 7px center; | ||
} | ||
.switch-btn input:checked + .switch-label span:before { | ||
-moz-transition: all 0.25s linear; | ||
-webkit-transition: all 0.25s linear; | ||
transition: all 0.25s linear; | ||
top: 2px; | ||
left: 25px; | ||
border-radius: 0 4px 4px 0; | ||
} | ||
|
||
@media screen and (min-width: 768px) { | ||
.switch-btn input + .switch-label:after { | ||
display: inline-block; | ||
vertical-align: middle; | ||
content: attr(data-off); | ||
} | ||
.switch-btn input + .switch-label span:before { | ||
-moz-transition: none 1s; | ||
-webkit-transition: none 1s; | ||
transition: none 1s; | ||
} | ||
.switch-btn input:checked + .switch-label:after { | ||
content: attr(data-on); | ||
} | ||
.switch-btn input:checked + .switch-label span:before { | ||
-moz-transition: none 1s; | ||
-webkit-transition: none 1s; | ||
transition: none 1s; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
--- | ||
title: Componentes - Switch Button | ||
|
||
menu_page: sidebar-componentes.erb | ||
--- | ||
|
||
<article class="text"> | ||
<header> | ||
<h1>Botão Switch</h1> | ||
<h3>permite a escolha de apenas uma entre duas opções (Ativado ou Desativado).</h3> | ||
</header> | ||
|
||
<p>Você pode definir que será escrito na label utilizando os atributos <code>data-on</code> quando estiver checado, e <code>data-off</code> quando não estiver checado.</p> | ||
<div class="example"> | ||
<%= partial "manual/componentes/partials/switch-button" %> | ||
</div> | ||
<pre class="lang-html prettyprint linenums"> | ||
<div class="switch-btn"> | ||
<input type="checkbox" id="switch1"> | ||
<label class="switch-label" for="switch1" name="label-switch" data-off="Desativado" data-on="Ativado"><span></span></label> | ||
</div> | ||
</pre> | ||
|
||
<h3>Botão switch com link</h3> | ||
<p>Pra deixá-lo com visual ativado é necessário que o checkbox esteja checado.</p> | ||
<div class="example"> <%= partial "manual/componentes/partials/switch-button-link" %></div> | ||
<pre class="lang-html prettyprint linenums"> | ||
<div class="switch-btn"> | ||
<a href="#"> | ||
<input type="checkbox" checked id="switch1"> | ||
<label class="switch-label" for="switch1" name="label-switch" data-off="Desativado" data-on="Ativado"><span></span></label> | ||
</a> | ||
</div> | ||
</pre> | ||
|
||
</article> |
6 changes: 6 additions & 0 deletions
6
source/manual/componentes/partials/_switch-button-link.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<div class="switch-btn"> | ||
<a href="#"> | ||
<input type="checkbox" checked id="switch2"> | ||
<label class="switch-label" for="switch2" name="label-switch2" data-off="Desativado" data-on="Ativado"><span></span></label> | ||
</a> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<div class="switch-btn"> | ||
<input type="checkbox" id="switch1"> | ||
<label class="switch-label" for="switch1" name="label-switch" data-off="Desativado" data-on="Ativado"><span></span></label> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters