Skip to content

Instantly share code, notes, and snippets.

View thomasJang's full-sized avatar
🎯
Focusing

JANG KI-YOUNG thomasJang

🎯
Focusing
View GitHub Profile
@thomasJang
thomasJang / handleRowResizerMove.ts
Created January 8, 2019 11:04
mouseEventSubscribe
handleRowResizerMove = (e: React.MouseEvent<HTMLDivElement>) => {
const { activePanel } = this.props.appStore.uiStore.queryPanelStore;
const containerTop = this.containerRef.current.getBoundingClientRect().top;
mouseEventSubscribe(
(mpos: IMousePosition) => {
const resizerTop = mpos.clientY - containerTop;
activePanel.setFlexGlow((resizerTop * 2) / this.containerHeight);
},
() => {
// onSubscribeEnd
@thomasJang
thomasJang / sortPanel.js
Created January 7, 2019 13:08
sortPanel.js
function sortPanel(fromIndex: number, toIndex: number) {
const movePanel = self.panelsRefs[fromIndex];
self.panelsRefs.splice(fromIndex, 1);
self.panelsRefs.splice(toIndex, 0, movePanel);
open(movePanel);
}
@thomasJang
thomasJang / handleDragEnd.js
Created January 7, 2019 13:05
handleDragEnd.js
handleDragEnd = (tabIndex: number, e: React.DragEvent) => {
const { sortPanel } = this.props.appStore.uiStore.queryPanelStore;
if (
this.dragTabIndex !== undefined &&
this.dragOverTabIndex !== undefined &&
this.dragTabIndex !== this.dragOverTabIndex
) {
sortPanel(this.dragTabIndex, this.dragOverTabIndex);
}
@thomasJang
thomasJang / ant-modal-custom.less
Created December 24, 2018 09:49
ant-modal-custom.less
.ant-modal {
top: 24px;
.effect() {
animation-duration: 0.3s;
animation-fill-mode: both;
}
&.slidedown-enter,
&.slidedown-appear {
opacity: 0;
@thomasJang
thomasJang / mouseEventSubscribe.ts
Created December 5, 2018 01:44
mouseEventSubscribe.ts
export interface IMousePosition {
pageX: number;
pageY: number;
clientX: number;
clientY: number;
}
export type MouseEventSubscribeCallbackFn = (mpos: IMousePosition) => void;
const mouseEventSubscribe = (
callBack: MouseEventSubscribeCallbackFn,
@thomasJang
thomasJang / sample.jsx
Created November 23, 2018 04:57
sample.jsx
<ReactMultiEmail
placeholder="Input your email"
emails={emails}
onChange={(_emails: string[]) => {
this.setState({ emails: _emails });
}}
getLabel={(
email: string,
index: number,
removeEmail: (index: number) => void,
@thomasJang
thomasJang / SMixinFlex.ts
Created November 14, 2018 03:24
SMixinFlex.ts
export interface ISMixinFlex {
direction?: 'row' | 'column';
justifyContent?:
| 'normal'
| 'space-between'
| 'space-around'
| 'space-evenly'
| 'stretch'
| 'start'
| 'end'
@thomasJang
thomasJang / package.json
Created November 1, 2018 12:42
package.json
"scripts": {
"start": "npm-run-all -p build-watch:less-var build-watch:react",
"tslint-check": "tslint-config-prettier-check ./tslint.json",
"build-watch:react": "react-app-rewired start --scripts-version react-scripts-ts",
"build-watch:less-var": "ts-node -P ./tsconfig.dev.json ./script/generate-less-var.ts"
}
@thomasJang
thomasJang / generate-less-var.ts
Created November 1, 2018 12:41
generate-less-var.ts
const path = require('path');
const fs = require('fs-extra');
const chalk = require('chalk');
const srcPath = '../src/styles/theme.ts';
const srcResoloved = path.resolve(__dirname, srcPath);
const target = path.resolve(__dirname, '../src/styles/less/theme-vars.less');
const buildLessVar = () => {
delete require.cache[srcResoloved];
const theme = require(srcPath);
fs.writeFileSync(
@thomasJang
thomasJang / Footer.tsx
Last active September 29, 2018 15:03
Footer.tsx