Skip to content

Instantly share code, notes, and snippets.

View nkmcheng's full-sized avatar
GM

Niña nkmcheng

GM
View GitHub Profile
@nkmcheng
nkmcheng / numberFormat.js
Created June 29, 2022 15:15
number formatting using numeral js with locales and abbreviations
import numeral from 'numeral';
if (numeral.locales['id'] === undefined) {
numeral.register('locale', 'id', {
delimiters: {
thousands: '.',
decimal: ','
},
abbreviations: {
thousand: 'rb',
@nkmcheng
nkmcheng / dateFormat.js
Created June 29, 2022 15:13
Formatting date with moment.js
import moment from 'moment';
const DateTimeFormat = date => {
return moment(date).format('MMM DD, YYYY hh:mm A');
};
export default DateTimeFormat;
@nkmcheng
nkmcheng / shortenAddress.js
Created June 29, 2022 15:12
Substring wallet address
const shortenAddress = address => {
if (!address) {
return '';
}
return address.substring(0, 6) + '...' + address.substring(address.length - 8);
};
export default shortenAddress;
@nkmcheng
nkmcheng / index.txt
Created June 29, 2022 15:11
Table component using tailwind css
// How to use table component
const column = [
{ heading: 'Name', value: 'name' },
{ heading: 'Number', value: 'phoneNo', render: text => `+63${text}` },
{ heading: 'Date', value: 'createdAt', render: text => dateFormat(text) },
];
<Table data={data} column={column} />
@nkmcheng
nkmcheng / createSnackbarSlice.txt
Last active June 29, 2022 15:03
createSnackbarSlice
import { StoreSlice } from '../../shared/types';
export interface ISnackbarProperty {
visible: boolean;
message: string;
}
export interface ISnarkbarSlice {
snackbar: ISnackbarProperty;
showSnackbar: (message: string) => void;
@nkmcheng
nkmcheng / meta-prevent-zoom
Created June 7, 2019 01:23
Prevent zooming all together by adding this meta tag to your head tag
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1,user-scalable=0"/>