Skip to content

Instantly share code, notes, and snippets.

@Et7f3
Last active May 3, 2020 17:40
Show Gist options
  • Save Et7f3/66972fccccb641792d20c413b3132278 to your computer and use it in GitHub Desktop.
Save Et7f3/66972fccccb641792d20c413b3132278 to your computer and use it in GitHub Desktop.
Language toogle for ReasonML/OCaml
<!DOCTYPE html>
<html lang="en">
<head>
<title>Example of toogle for OCaml/ReasonML docs.</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
#lang-switch {
position: relative;
display: inline-block;
width: 60px;
height: 34px;
}
#toogle-lang {
opacity: 0;
width: 0;
height: 0;
display: none;
}
.slider {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #db4d3f;
-webkit-transition: .4s;
transition: .4s;
}
.slider:before {
position: absolute;
content: "re";
height: 26px;
width: 26px;
left: 4px;
bottom: 4px;
background-color: white;
-webkit-transition: .4s;
transition: .4s;
}
#toogle-lang:checked+label .slider:before {
content: "ml";
}
#toogle-lang:checked+label .slider {
background-color: #ED9200;
border-radius: 34px;
content: "ml";
}
#toogle-lang:focus+label .slider {
box-shadow: 0 0 1px #ED9200;
}
#toogle-lang:checked+label .slider:before {
-webkit-transform: translateX(26px);
-ms-transform: translateX(26px);
transform: translateX(26px);
border-radius: 50%;
}
#toogle-lang:checked+label+div .reason {
display: none
}
#toogle-lang:not(:checked)+label+div .ocaml {
display: none
}
</style>
</head>
<body>
<!-- Use this tag if you want Reason syntax as default -->
<input type="checkbox" id="toogle-lang" />
<!-- Use this tag if you want OCaml syntax as default -->
<!--<input type="checkbox" id="toogle-lang" checked />-->
<label id="lang-switch" for="toogle-lang">
<span class="slider"></span>
</label>
<div class="content">
<code class="reason">print_endline("Hello world!");</code>
<code class="ocaml">let () = print_endline("Hello world!")</code>
</div>
</body>
</html>
@Et7f3
Copy link
Author

Et7f3 commented May 3, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment