Skip to content

Instantly share code, notes, and snippets.

View kuanhsuh's full-sized avatar
🏠
Working from home

Danny Huang kuanhsuh

🏠
Working from home
View GitHub Profile
@kuanhsuh
kuanhsuh / wordpress code snipps
Last active May 19, 2019 04:35
function.php load styles and script
// get feature image inside loop
<?php
if (has_post_thumbnail()) { // check if the post has a Post Thumbnail assigned to it.
the_post_thumbnail('full', array('class' => 'img-fluid d-block')); // show featured image
} else { ?>
<img src="https://via.placeholder.com/1200x750" alt="" class="img-fluid d-block">
<?php } ?>
// get images from files
// css
#loadingScreen {
height: 100vh;
-webkit-box-pack: center;
-ms-flex-pack: center;
justify-content: center;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
// parent
<BottomSheet
primaryBtn={
<Button
children="Primary Action"
licon="lock-f"
onClick={action("primaryBtn Action")}
/>
}
@kuanhsuh
kuanhsuh / storybookcomponent
Last active May 28, 2018 01:52
storybook component
import React, { PureComponent } from "react";
import PropTypes from "prop-types";
import styles from "./TextArea.css";
class TextArea extends PureComponent {
constructor(props) {
super(props);
}
render() {
@kuanhsuh
kuanhsuh / destructuring.js
Created May 11, 2018 01:45
destructuring.js
// Rest 剩下的, Spread 展開 , Destructuring 將陣列或物件中的資料取出成獨立變數
// Array Example
// let a, b
// [a, b, ...c] = [1, 2, 3, 4, 5]
// c
// Obj Example
// ({a, b, ...c} = {a: 1, b: 2, c: 3, d: 4, e: 5})
// es5 classes
// function Person(name, age) {
// this.name = name;
// this.age = age;
// }
// Person.prototype.sayHi = function () {
function logWord(word) {
return new Promise(function (resolve, reject) {
setTimeout(function() {
console.log(word)
resolve()
}, Math.floor(Math.random() * 100) + 1)
})
}
// function logAll() {
@kuanhsuh
kuanhsuh / letconst.js
Created April 9, 2018 13:19
let const var
// add Block Scope 限制在這個區塊
// ES6
// let x = 2;
// if (x === 2) {
// let x = 5;
// console.log(x);
// }
// console.log(x);
@kuanhsuh
kuanhsuh / arrowfn.js
Created April 2, 2018 04:53
arrow function
// Simple Example
// 1. Better Looking (sugar syntax)
// function sayHi() {
// console.log('Hello world')
// }
// const sayHi = user => {
// console.log('Hello world ' + user)
// }