Skip to content

Instantly share code, notes, and snippets.

View BosNaufal's full-sized avatar

Naufal Rabbani BosNaufal

View GitHub Profile
@BosNaufal
BosNaufal / dynamic-styling.js
Created December 29, 2019 04:25
Konfigurasi Sederhana CSS in JS Vue JS - Dynamic Styling
import styled from 'vue-styled-components';
const WrapperProps = ["bg", "fontSize"]
const Wrapper = styled('div', WrapperProps)`
background: ${(props) => props.bg};
color: white;
font-size: ${(props) => props.fontSize}rem;
`
@BosNaufal
BosNaufal / conditional-styling.js
Created December 29, 2019 04:24
Konfigurasi Sederhana CSS in JS Vue JS - Coditional Styling
import styled from 'vue-styled-components';
const MyButtonProps = {
success: Boolean
}
const MyButton = styled('button', MyButtonProps)`
background: ${
({ success }) => success
? "green"
@BosNaufal
BosNaufal / basic-composing.js
Created December 29, 2019 04:22
Konfigurasi Sederhana CSS in JS Vue JS - Basic Composing
import styled, { css } from 'vue-styled-components';
const baseDarkModeStyle = css`
background: black;
color: white;
`
const DarkButton = styled('button')`
${baseDarkModeStyle}
font-size: 2rem;
@BosNaufal
BosNaufal / composeable-function.js
Created December 29, 2019 04:21
Konfigurasi Sederhana CSS in JS Vue JS - Composable Function
import styled from 'vue-styled-components';
const adaptCurrentMode = (isDarkMode = false, customColor) => {
return isDarkMode
? (`
background: black;
color: ${customColor || 'white'};
`)
: ""
}
@BosNaufal
BosNaufal / basic-theming.js
Created December 29, 2019 04:20
Konfigurasi Sederhana CSS in JS Vue JS - Basic Theming
import styled, { ThemeProvider } from 'vue-styled-components';
const Button = styled('button')`
background: ${({ theme }) => theme.bg};
color: ${({ theme }) => theme.text};
font-size: 2rem;
border-color: ${({ theme }) => theme.borderColor};
`
const Card = styled('div')`
@BosNaufal
BosNaufal / basic-theming.js
Last active December 29, 2019 04:15
Konfigurasi Sederhana CSS in JS Vue JS
import styled, { ThemeProvider } from 'vue-styled-components';
const Button = styled('button')`
background: ${({ theme }) => theme.bg};
color: ${({ theme }) => theme.text};
font-size: 2rem;
border-color: ${({ theme }) => theme.borderColor};
`
const Card = styled('div')`
@BosNaufal
BosNaufal / time_dimension.sql
Last active June 28, 2022 03:46
Generate Time Dimension in SQL
/* Adapted from Tom Cunningham's 'Data Warehousing with MySql' (www.meansandends.com/mysql-data-warehouse) */
/* BASED ON: https://gist.github.com/johngrimes/408559 */
-- YOUR VARIABLES HERE;
SET @DATE_START = '2010-01-01';
SET @DATE_END = '2020-01-01';
###### small-numbers table
DROP TABLE IF EXISTS numbers_small;
CREATE TABLE numbers_small (number INT);
import { call } from 'vuex-saga'
import api from '../api'
function *fetchFlow() {
let [product, other] = yield [call(api.fetchProduct), call(api.otherApis)]
}
import api from '../api'
function *fetchFlow() {
let product = yield call(api.fetchProduct)
let seller = yield call(api.fetchSeller, { product })
let statistic = yield call(api.statistic, { product, seller })
let lastFetch = yield call(api.needStatisticProductAndSeller, { statistic, product, seller })
return lastFetch
}
import api from '../api'
api.fetchProduct()
.then((product) => {
return api.fetchSeller(product.id)
.then((seller) => {
return api.statistic(product, seller)
.then((statistic) => {
return api.needStatisticProductAndSeller(statstic, product, seller)
})