-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a910ea1
commit efaf21a
Showing
13 changed files
with
159 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { IColumn } from '../components/column/IColumn'; | ||
|
||
export const ADD_COLUMN = 'ADD_COLUMN'; | ||
export const REMOVE_COLUMN = 'REMOVE_COLUMN'; | ||
|
||
export const addColumn = (grid: IColumn) => ({ | ||
type: ADD_COLUMN, | ||
payload: grid | ||
}); | ||
|
||
export const removeColumn = (grid: IColumn) => ({ | ||
type: REMOVE_COLUMN, | ||
payload: grid | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import * as React from 'react'; | ||
import styled from 'styled-components'; | ||
import { IColumn } from './IColumn'; | ||
import { createColumn } from './utils'; | ||
|
||
export const Column = ({ width, height, color, opacity }: IColumn) => ( | ||
<Element data={createColumn(width, height, 20, color)} opacity={opacity} /> | ||
); | ||
|
||
interface Props { | ||
data: string; | ||
opacity: number; | ||
} | ||
|
||
const Element = styled.div<Props>` | ||
position: fixed; | ||
top: 0; | ||
left: 0; | ||
width: 100vw; | ||
height: 100vh; | ||
background-image: url(${({ data }) => data}); | ||
background-repeat: repeat; | ||
opacity: ${({ opacity }) => opacity}; | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { Color } from '../../utils/Color'; | ||
|
||
export interface IColumn { | ||
className?: string; | ||
id: string; | ||
color: Color; | ||
width: number; | ||
height: number; | ||
opacity: number; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import * as uuid from 'uuid/v1'; | ||
import { Color } from '../../utils/Color'; | ||
import { IColumn } from './IColumn'; | ||
|
||
export const factory = (id: string = uuid(), props = {}): IColumn => ({ | ||
id, | ||
width: 100, | ||
height: 100, | ||
color: Color.RED, | ||
opacity: 0.1, | ||
...props | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
export const createColumn = ( | ||
width: number, | ||
height: number, | ||
gap: number, | ||
color: string | ||
): string => { | ||
const canvas: HTMLCanvasElement = document.createElement('canvas'); | ||
const ctx = canvas.getContext('2d') as CanvasRenderingContext2D; | ||
|
||
canvas.width = width + gap; | ||
canvas.height = height; | ||
|
||
ctx.fillStyle = color; | ||
ctx.fillRect(0, 0, width, height); | ||
|
||
return canvas.toDataURL(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export enum Tool { | ||
COLUMN = 'column', | ||
GUIDE = 'guide', | ||
RULER = 'ruler', | ||
ONION = 'onion', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import * as R from 'ramda'; | ||
import { AnyAction } from 'redux'; | ||
import { ADD_COLUMN, REMOVE_COLUMN } from '../actions/columns'; | ||
import { IColumn } from '../components/column/IColumn'; | ||
|
||
const initialStore: IColumn[] = []; | ||
|
||
export const columns = ( | ||
store = initialStore, | ||
{ type, payload }: AnyAction | ||
): IColumn[] => { | ||
switch (type) { | ||
case ADD_COLUMN: | ||
return R.append(payload, store); | ||
case REMOVE_COLUMN: | ||
return R.reject(R.equals(payload), store); | ||
} | ||
|
||
return store; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters