forked from scratchfoundation/scratch-blocks
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request scratchfoundation#26 from rschamp/feature/layout
Pass for overall layout
- Loading branch information
Showing
28 changed files
with
385 additions
and
221 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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
.blocks { | ||
.blocks :global(.injectionDiv){ | ||
position: absolute; | ||
top: 40px; | ||
right: 500px; | ||
top: 0; | ||
right: 0; | ||
bottom: 0; | ||
left: 0; | ||
} |
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,25 +1,21 @@ | ||
const React = require('react'); | ||
|
||
const Box = require('../box/box.jsx'); | ||
const styles = require('./blocks.css'); | ||
|
||
class BlocksComponent extends React.Component { | ||
render () { | ||
const { | ||
componentRef, | ||
...props | ||
} = this.props; | ||
return ( | ||
<div | ||
className={styles.blocks} | ||
ref={componentRef} | ||
{...props} | ||
/> | ||
); | ||
} | ||
} | ||
|
||
const BlocksComponent = props => { | ||
const { | ||
componentRef, | ||
...componentProps | ||
} = props; | ||
return ( | ||
<Box | ||
className={styles.blocks} | ||
componentRef={componentRef} | ||
{...componentProps} | ||
/> | ||
); | ||
}; | ||
BlocksComponent.propTypes = { | ||
componentRef: React.PropTypes.func | ||
}; | ||
|
||
module.exports = BlocksComponent; |
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,4 @@ | ||
.box { | ||
display: flex; | ||
position: relative; | ||
} |
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,119 @@ | ||
const classNames = require('classnames'); | ||
const React = require('react'); | ||
const stylePropType = require('react-style-proptype'); | ||
const styles = require('./box.css'); | ||
|
||
const getRandomColor = (function () { | ||
// In "DEBUG" mode this is used to output a random background color for each | ||
// box. The function gives the same "random" set for each seed, allowing re- | ||
// renders of the same content to give the same random display. | ||
const random = (function (seed) { | ||
let mW = seed; | ||
let mZ = 987654321; | ||
const mask = 0xffffffff; | ||
return function () { | ||
mZ = ((36969 * (mZ & 65535)) + (mZ >> 16)) & mask; | ||
mW = ((18000 * (mW & 65535)) + (mW >> 16)) & mask; | ||
let result = ((mZ << 16) + mW) & mask; | ||
result /= 4294967296; | ||
return result + 1; | ||
}; | ||
}(601)); | ||
return function () { | ||
const r = Math.max(parseInt(random() * 100, 10) % 256, 1); | ||
const g = Math.max(parseInt(random() * 100, 10) % 256, 1); | ||
const b = Math.max(parseInt(random() * 100, 10) % 256, 1); | ||
return `rgb(${r},${g},${b})`; | ||
}; | ||
}()); | ||
|
||
const Box = props => { | ||
const { | ||
alignContent, | ||
alignItems, | ||
alignSelf, | ||
basis, | ||
children, | ||
className, | ||
componentRef, | ||
direction, | ||
element, | ||
grow, | ||
height, | ||
justifyContent, | ||
width, | ||
wrap, | ||
shrink, | ||
style, | ||
...componentProps | ||
} = props; | ||
return React.createElement(element, { | ||
className: classNames(styles.box, className), | ||
ref: componentRef, | ||
style: Object.assign( | ||
{ | ||
alignContent: alignContent, | ||
alignItems: alignItems, | ||
alignSelf: alignSelf, | ||
flexBasis: basis, | ||
flexDirection: direction, | ||
flexGrow: grow, | ||
flexShrink: shrink, | ||
flexWrap: wrap, | ||
justifyContent: justifyContent, | ||
width: width, | ||
height: height | ||
}, | ||
process.env.DEBUG ? { | ||
backgroundColor: getRandomColor(), | ||
outline: `1px solid black` | ||
} : {}, | ||
style | ||
), | ||
...componentProps | ||
}, children); | ||
}; | ||
Box.propTypes = { | ||
alignContent: React.PropTypes.oneOf([ | ||
'flex-start', 'flex-end', 'center', 'space-between', 'space-around', 'stretch' | ||
]), | ||
alignItems: React.PropTypes.oneOf([ | ||
'flex-start', 'flex-end', 'center', 'baseline', 'stretch' | ||
]), | ||
alignSelf: React.PropTypes.oneOf([ | ||
'auto', 'flex-start', 'flex-end', 'center', 'baseline', 'stretch' | ||
]), | ||
basis: React.PropTypes.oneOfType([ | ||
React.PropTypes.number, | ||
React.PropTypes.oneOf(['auto']) | ||
]), | ||
children: React.PropTypes.node, | ||
className: React.PropTypes.string, | ||
componentRef: React.PropTypes.func, | ||
direction: React.PropTypes.oneOf([ | ||
'row', 'row-reverse', 'column', 'column-reverse' | ||
]), | ||
element: React.PropTypes.string, | ||
grow: React.PropTypes.number, | ||
height: React.PropTypes.oneOfType([ | ||
React.PropTypes.number, | ||
React.PropTypes.string | ||
]), | ||
justifyContent: React.PropTypes.oneOf([ | ||
'flex-start', 'flex-end', 'center', 'space-between', 'space-around' | ||
]), | ||
shrink: React.PropTypes.number, | ||
style: stylePropType, | ||
width: React.PropTypes.oneOfType([ | ||
React.PropTypes.number, | ||
React.PropTypes.string | ||
]), | ||
wrap: React.PropTypes.oneOf([ | ||
'nowrap', 'wrap', 'wrap-reverse' | ||
]) | ||
}; | ||
Box.defaultProps = { | ||
element: 'div', | ||
style: {} | ||
}; | ||
module.exports = Box; |
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,11 +1,7 @@ | ||
.green-flag { | ||
position: absolute; | ||
top: 8px; | ||
right: calc(480px - 16px); | ||
width: 16px; | ||
height: 16px; | ||
} | ||
|
||
.active { | ||
.green-flag.is-active { | ||
filter: saturate(200%) brightness(150%); | ||
} |
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 was deleted.
Oops, something went wrong.
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
Oops, something went wrong.