Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: ParishConnect/box
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v2.2.0
Choose a base ref
...
head repository: ParishConnect/box
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v2.2.1
Choose a head ref
  • 2 commits
  • 4 files changed
  • 1 contributor

Commits on Jul 2, 2019

  1. Copy the full SHA
    69ac93e View commit details
  2. v2.2.1

    hennessyevan committed Jul 2, 2019
    Copy the full SHA
    fe0344e View commit details
Showing with 36 additions and 1 deletion.
  1. +1 −1 package.json
  2. +3 −0 src/box.tsx
  3. +26 −0 src/expandAliases.ts
  4. +6 −0 tools/story.tsx
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@parishconnect/box",
"version": "2.2.0",
"version": "2.2.1",
"description": "Blazing Fast React UI Primitive",
"contributors": [],
"repository": "hennessyevan/box",
3 changes: 3 additions & 0 deletions src/box.tsx
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@ import facepaint from "facepaint";
import cc from "classcat";
import * as CSS from "csstype";
import React, { ReactNode } from "react";
import expandAliases from "./expandAliases";

export interface BoxProps extends CSS.PropertiesFallback<number | string | number[] | string[] | null> {
is?: any;
@@ -17,6 +18,8 @@ export interface BoxProps extends CSS.PropertiesFallback<number | string | numbe
const Box = ({ is = "div", className, css, props, style, children, ...rest }: BoxProps) => {
const mq = facepaint(["@media(min-width: 420px)", "@media(min-width: 920px)", "@media(min-width: 1120px)"]);

rest = expandAliases(rest);

return (
<ClassNames>
{({ css: ecss }) =>
26 changes: 26 additions & 0 deletions src/expandAliases.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { BoxProps } from "./box";

export default function expandAliases(props: BoxProps): BoxProps {
if (props.marginX) {
props.marginLeft = props.marginX;
props.marginRight = props.marginX;
delete props.marginX;
}
if (props.marginY) {
props.marginTop = props.marginY;
props.marginBottom = props.marginY;
delete props.marginY;
}
if (props.paddingX) {
props.paddingLeft = props.paddingX;
props.paddingRight = props.paddingX;
delete props.paddingX;
}
if (props.paddingY) {
props.paddingTop = props.paddingY;
props.paddingBottom = props.paddingY;
delete props.paddingY;
}

return props;
}
6 changes: 6 additions & 0 deletions tools/story.tsx
Original file line number Diff line number Diff line change
@@ -157,6 +157,12 @@ storiesOf("Box", module)
<Box innerRef={logRef}>innerRef</Box>
</Box>
))
.add("aliases", () => (
<Box>
<Box width={200} height={200} background="red" marginY={64} paddingX={18} marginX={18} />
<Box width={200} height={200} background="blue" />
</Box>
))
.add("props pass through", () => (
<Box>
<Box is="input" type="file" />