Commit 6cc198bf authored by Sangjune Bae's avatar Sangjune Bae
Browse files

first commit

parent 81c6da4b
export default function getFreshSideObject() {
return {
top: 0,
right: 0,
bottom: 0,
left: 0
};
}
\ No newline at end of file
// @flow
import type { SideObject } from '../types';
export default function getFreshSideObject(): SideObject {
return {
top: 0,
right: 0,
bottom: 0,
left: 0,
};
}
import { Placement } from "../enums";
export default function getMainAxisFromPlacement(placement: Placement): "x" | "y";
export default function getMainAxisFromPlacement(placement) {
return ['top', 'bottom'].indexOf(placement) >= 0 ? 'x' : 'y';
}
\ No newline at end of file
// @flow
import type { Placement } from '../enums';
export default function getMainAxisFromPlacement(
placement: Placement
): 'x' | 'y' {
return ['top', 'bottom'].indexOf(placement) >= 0 ? 'x' : 'y';
}
import { Placement } from "../enums";
export default function getOppositePlacement(placement: Placement): Placement;
var hash = {
left: 'right',
right: 'left',
bottom: 'top',
top: 'bottom'
};
export default function getOppositePlacement(placement) {
return placement.replace(/left|right|bottom|top/g, function (matched) {
return hash[matched];
});
}
\ No newline at end of file
// @flow
import type { Placement } from '../enums';
const hash = { left: 'right', right: 'left', bottom: 'top', top: 'bottom' };
export default function getOppositePlacement(placement: Placement): Placement {
return (placement.replace(
/left|right|bottom|top/g,
matched => hash[matched]
): any);
}
import { Placement } from "../enums";
export default function getOppositeVariationPlacement(placement: Placement): Placement;
var hash = {
start: 'end',
end: 'start'
};
export default function getOppositeVariationPlacement(placement) {
return placement.replace(/start|end/g, function (matched) {
return hash[matched];
});
}
\ No newline at end of file
// @flow
import type { Placement } from '../enums';
const hash = { start: 'end', end: 'start' };
export default function getOppositeVariationPlacement(
placement: Placement
): Placement {
return (placement.replace(/start|end/g, matched => hash[matched]): any);
}
import { Variation, Placement } from "../enums";
export default function getVariation(placement: Placement): Variation | null | undefined;
export default function getVariation(placement) {
return placement.split('-')[1];
}
\ No newline at end of file
// @flow
import { type Variation, type Placement } from '../enums';
export default function getVariation(placement: Placement): ?Variation {
return (placement.split('-')[1]: any);
}
import { Modifier } from "../types";
export default function mergeByName(modifiers: Array<Partial<Modifier<any, any>>>): Array<Partial<Modifier<any, any>>>;
export default function mergeByName(modifiers) {
var merged = modifiers.reduce(function (merged, current) {
var existing = merged[current.name];
merged[current.name] = existing ? Object.assign(Object.assign(Object.assign({}, existing), current), {}, {
options: Object.assign(Object.assign({}, existing.options), current.options),
data: Object.assign(Object.assign({}, existing.data), current.data)
}) : current;
return merged;
}, {}); // IE11 does not support Object.values
return Object.keys(merged).map(function (key) {
return merged[key];
});
}
\ No newline at end of file
// @flow
import type { Modifier } from '../types';
export default function mergeByName(
modifiers: Array<$Shape<Modifier<any, any>>>
): Array<$Shape<Modifier<any, any>>> {
const merged = modifiers.reduce((merged, current) => {
const existing = merged[current.name];
merged[current.name] = existing
? {
...existing,
...current,
options: { ...existing.options, ...current.options },
data: { ...existing.data, ...current.data },
}
: current;
return merged;
}, {});
// IE11 does not support Object.values
return Object.keys(merged).map(key => merged[key]);
}
import { SideObject } from "../types";
export default function mergePaddingObject(paddingObject: Partial<SideObject>): SideObject;
import getFreshSideObject from "./getFreshSideObject.js";
export default function mergePaddingObject(paddingObject) {
return Object.assign(Object.assign({}, getFreshSideObject()), paddingObject);
}
\ No newline at end of file
// @flow
import type { SideObject } from '../types';
import getFreshSideObject from './getFreshSideObject';
export default function mergePaddingObject(
paddingObject: $Shape<SideObject>
): SideObject {
return {
...getFreshSideObject(),
...paddingObject,
};
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment