Skip to content

Instantly share code, notes, and snippets.

View codedrops-io's full-sized avatar

CodeDrops codedrops-io

View GitHub Profile
@codedrops-io
codedrops-io / disable-zoom-on-mobile.html
Created June 19, 2020 08:07
Disable zoom on mobile with HTML.
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
@codedrops-io
codedrops-io / copy-to-clipboard.js
Created June 18, 2020 20:19
Simple copy to clipboard function.
const copyTextToClipboard = (textString) => {
const textarea = document.createElement('textarea')
textarea.value = textString
document.body.appendChild(textarea)
textarea.select()
document.execCommand('copy')
document.body.removeChild(textarea)
}
@codedrops-io
codedrops-io / media-query-mixins.scss
Created June 18, 2020 15:01
Media query mixins.
// Device sizes
$phone: 599px;
$tablet-portrait: 600px;
$tablet-landscape: 900px;
$desktop: 1200px;
$desktop-big: 1800px;
// Media queries
@mixin for-phone-only {
@media (max-width: $phone) {
@codedrops-io
codedrops-io / button-reset.css
Created June 18, 2020 14:59
Reset your buttons.
button {
overflow: visible;
margin: 0;
font-family: inherit;
font-size: 100%;
line-height: 1.15;
text-transform: none;
-webkit-appearance: button;
}
@codedrops-io
codedrops-io / grayscale-anti-aliasing.css
Created June 18, 2020 14:58
Grayscale anti-aliasing.
* {
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
@codedrops-io
codedrops-io / initialize-body.scss
Created June 18, 2020 14:56
Initialize the body of your document.
body {
margin: 0;
padding: 0;
box-sizing: border-box;
* {
box-sizing: inherit;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
@codedrops-io
codedrops-io / ellipsis.css
Created June 18, 2020 14:55
Add ellipsis to a text.
p {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
@codedrops-io
codedrops-io / shuffle-array.js
Created June 18, 2020 14:53
Shuffle array function.
function shuffleArray (array) {
let currentIndex = array.length
let temporaryValue
let randomIndex
// While there remain elements to shuffle.
while (currentIndex !== 0) {
// Pick a remaining element
randomIndex = Math.floor(Math.random() * currentIndex)
currentIndex -= 1
@codedrops-io
codedrops-io / debounce.js
Created June 18, 2020 14:52
Debounce function.
function debounce (func, wait = 100, immediate) {
let timeout
return function () {
const context = this
const args = arguments
const later = function () {
timeout = null
if (!immediate) func.apply(context, args)
@codedrops-io
codedrops-io / slow-loading-checker.js
Created June 18, 2020 14:51
Check if a feature of your project is loading slow.
setTimeout(() => {
if (!HAS_LOADED_CONDITION) {
// This should be sent to your error tracking system
console.error('⚠️ Slow connection!')
}
}, 10000)