Skip to content

Commit

Permalink
chore(dx): improve DX
Browse files Browse the repository at this point in the history
  • Loading branch information
Raphaël Benitte committed Aug 1, 2017
1 parent 06882cf commit c6ba5ea
Show file tree
Hide file tree
Showing 25 changed files with 411 additions and 169 deletions.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions .npmignore
Expand Up @@ -9,7 +9,7 @@
.travis.yml

# Logs
npm-debug.log*
*.log*

# Non transpiled source code
/src
Expand All @@ -20,7 +20,7 @@ npm-debug.log*
/coverage

# GitHub
ISSUE_TEMPLATE.md
/.github

# OSX
.DS_Store
Expand Down
9 changes: 5 additions & 4 deletions .travis.yml
Expand Up @@ -4,7 +4,8 @@ node_js:
- '7'
- '8'
script:
- npm run lint
- npm run test
#after_success:
# - npm run coveralls
- yarn run lint
- yarn run fmt:check
- yarn run test:cover
after_success:
- yarn run coverage
65 changes: 56 additions & 9 deletions package.json
@@ -1,6 +1,6 @@
{
"name": "@mozaik/ext-time",
"version": "2.0.0-alpha.10",
"version": "2.0.0-alpha.11",
"description": "Mozaik time widgets",
"repository": {
"type": "git",
Expand Down Expand Up @@ -41,7 +41,7 @@
},
"devDependencies": {
"@mozaik/babel-preset": "^1.0.0-alpha.6",
"@mozaik/ui": "^2.0.0-alpha.7",
"@mozaik/ui": "^2.0.0-alpha.11",
"babel-cli": "^6.24.1",
"babel-eslint": "^7.2.3",
"babel-jest": "^20.0.3",
Expand All @@ -50,26 +50,73 @@
"enzyme": "^2.9.1",
"eslint": "^4.2.0",
"eslint-plugin-react": "^7.1.0",
"husky": "^0.14.3",
"jest": "^20.0.4",
"lint-staged": "^4.0.2",
"nyc": "8.1.0",
"prettier": "^1.5.3",
"react": "^15.6.1",
"react-dom": "^15.6.1",
"react-test-renderer": "^15.6.1"
"react-test-renderer": "^15.6.1",
"validate-commit-msg": "^2.14.0"
},
"peerDependencies": {
"@mozaik/ui": "^2.0.0-alpha.1",
"@mozaik/ui": "^2.0.0-alpha.11",
"react": "^15.6.1"
},
"scripts": {
"lint": "eslint ./src/** ./test/**",
"test": "jest",
"coveralls": "nyc report --reporter=text-lcov | coveralls",
"cover-report": "nyc report --reporter=lcov && open coverage/lcov-report/index.html",
"lint:fix": "eslint --fix ./src/** ./test/**",
"test": "jest --verbose",
"coverage": "cat ./coverage/lcov.info | coveralls",
"test:cover": "jest --verbose --coverage",
"build:commonjs": "cross-env BABEL_ENV=commonjs babel src --out-dir lib",
"build:es": "cross-env BABEL_ENV=es babel src --out-dir es",
"build": "npm run build:commonjs && npm run build:es",
"format": "prettier --tab-width=4 --bracket-spacing --no-semi --trailing-comma es5 --single-quote --write 'src/**/*.js' 'test/**/*.js'",
"prepublish": "npm run format && npm run lint && npm run build"
"fmt": "prettier --print-width=100 --tab-width=4 --bracket-spacing --no-semi --trailing-comma es5 --single-quote --color --write \"{src,test}/**/*.js\"",
"fmt:check": "prettier --print-width=100 --tab-width=4 --bracket-spacing --no-semi --trailing-comma es5 --single-quote --list-different \"{src,test}/**/*.js\"",
"prepublishOnly": "npm run lint && npm test && npm run build",
"version": "echo ${npm_package_version}",
"precommit": "lint-staged",
"commitmsg": "validate-commit-msg"
},
"lint-staged": {
"*.js": [
"lint:fix",
"fmt",
"git add",
"jest --bail --findRelatedTests"
]
},
"config": {
"validate-commit-msg": {
"types": [
"feat",
"fix",
"docs",
"style",
"refactor",
"perf",
"test",
"build",
"ci",
"chore",
"revert"
],
"scope": {
"required": true,
"allowed": [
"*"
],
"validate": false,
"multiple": false
},
"warnOnFail": false,
"maxSubjectLength": 80,
"subjectPattern": ".+",
"subjectPatternErrorMsg": "subject does not match subject pattern!",
"helpMessage": "",
"autoFix": false
}
}
}
14 changes: 3 additions & 11 deletions src/components/Clock.js
Expand Up @@ -49,9 +49,7 @@ export const HoursHand = Hand.extend`
background-color: ${props => props.colors.hoursHand};
`

export const MinutesHand = Hand.extend`
background-color: ${props => props.colors.minutesHand};
`
export const MinutesHand = Hand.extend`background-color: ${props => props.colors.minutesHand};`

export const SecondsHand = Hand.extend`
height: 1px;
Expand Down Expand Up @@ -92,14 +90,8 @@ const getCurrentTimeParts = timezoneName => {
}
}

const secondsScale = d3.scale
.linear()
.domain([0, 59 + 999 / 1000])
.range([-90, 270])
const minutesScale = d3.scale
.linear()
.domain([0, 59 + 59 / 60])
.range([-90, 270])
const secondsScale = d3.scale.linear().domain([0, 59 + 999 / 1000]).range([-90, 270])
const minutesScale = d3.scale.linear().domain([0, 59 + 59 / 60]).range([-90, 270])
const hoursScale = d3.scale.linear().domain([0, 11 + 59 / 60]).range([-90, 270])

const sunFormats = ['HH:mm', 'H:mm', 'H:m']
Expand Down
25 changes: 5 additions & 20 deletions src/components/digital_clock/DigitalChar.js
Expand Up @@ -67,28 +67,13 @@ export default class DigitalChar extends PureComponent {
<PartCenterLeft {...shapeProps} isActive={shape.centerLeft} />
<PartCenterRight {...shapeProps} isActive={shape.centerRight} />
<PartCenterTop {...shapeProps} isActive={shape.centerTop} />
<PartCenterBottom
{...shapeProps}
isActive={shape.centerBottom}
/>
<PartCenterBottom {...shapeProps} isActive={shape.centerBottom} />

{/* Oblique parts */}
<PartObliqueTopLeft
{...shapeProps}
isActive={shape.obliqueTopLeft}
/>
<PartObliqueTopRight
{...shapeProps}
isActive={shape.obliqueTopRight}
/>
<PartObliqueBottomRight
{...shapeProps}
isActive={shape.obliqueBottomRight}
/>
<PartObliqueBottomLeft
{...shapeProps}
isActive={shape.obliqueBottomLeft}
/>
<PartObliqueTopLeft {...shapeProps} isActive={shape.obliqueTopLeft} />
<PartObliqueTopRight {...shapeProps} isActive={shape.obliqueTopRight} />
<PartObliqueBottomRight {...shapeProps} isActive={shape.obliqueBottomRight} />
<PartObliqueBottomLeft {...shapeProps} isActive={shape.obliqueBottomLeft} />
</g>
)
}
Expand Down
6 changes: 1 addition & 5 deletions src/components/digital_clock/DigitalClock.js
Expand Up @@ -85,11 +85,7 @@ export default class DigitalClock extends Component {
{({ measureRef }) =>
<div ref={measureRef} style={innerContainerStyle}>
{shouldRenderDate &&
<DigitalClockDate
date={date}
width={width}
color={color}
/>}
<DigitalClockDate date={date} width={width} color={color} />}
{shouldRender &&
<DigitalClockTime
date={date}
Expand Down
15 changes: 3 additions & 12 deletions src/components/digital_clock/DigitalClockDate.js
Expand Up @@ -41,10 +41,7 @@ export default class DigitalClockDate extends Component {
height: dateHeight,
}}
>
<svg
width={dateCharWidth * 4 + dateSpacing * 3}
height={dateHeight}
>
<svg width={dateCharWidth * 4 + dateSpacing * 3} height={dateHeight}>
<DigitalWord
word={date.format('YYYY')}
charWidth={dateCharWidth}
Expand All @@ -54,10 +51,7 @@ export default class DigitalClockDate extends Component {
color={color}
/>
</svg>
<svg
width={dateCharWidth * 2 + dateSpacing}
height={dateHeight}
>
<svg width={dateCharWidth * 2 + dateSpacing} height={dateHeight}>
<DigitalWord
word={date.format('MM')}
charWidth={dateCharWidth}
Expand All @@ -67,10 +61,7 @@ export default class DigitalClockDate extends Component {
color={color}
/>
</svg>
<svg
width={dateCharWidth * 6 + dateSpacing * 5}
height={dateHeight}
>
<svg width={dateCharWidth * 6 + dateSpacing * 5} height={dateHeight}>
<DigitalWord
word={date.format('DD')}
charWidth={dateCharWidth}
Expand Down
11 changes: 1 addition & 10 deletions src/components/digital_clock/DigitalWord.js
Expand Up @@ -20,16 +20,7 @@ export default class DigitalWord extends PureComponent {
}

render() {
const {
word,
charWidth,
charHeight,
stroke,
color,
spacing,
x,
y,
} = this.props
const { word, charWidth, charHeight, stroke, color, spacing, x, y } = this.props

return (
<g transform={`translate(${x}, ${y})`}>
Expand Down
4 changes: 2 additions & 2 deletions src/components/digital_clock/parts/PartBottomLeft.js
Expand Up @@ -4,8 +4,8 @@ import HorizontalPart from './HorizontalPart'

const PartBottomLeft = props =>
<HorizontalPart
transform={`translate(${props.stroke / 2 +
props.spacing / 2}, ${props.height - props.stroke})`}
transform={`translate(${props.stroke / 2 + props.spacing / 2}, ${props.height -
props.stroke})`}
{...props}
/>

Expand Down
4 changes: 2 additions & 2 deletions src/components/digital_clock/parts/PartBottomRight.js
Expand Up @@ -4,8 +4,8 @@ import HorizontalPart from './HorizontalPart'

const PartBottomRight = props =>
<HorizontalPart
transform={`translate(${props.width / 2 +
props.spacing / 2}, ${props.height - props.stroke})`}
transform={`translate(${props.width / 2 + props.spacing / 2}, ${props.height -
props.stroke})`}
{...props}
/>

Expand Down
4 changes: 2 additions & 2 deletions src/components/digital_clock/parts/PartCenterBottom.js
Expand Up @@ -4,8 +4,8 @@ import VerticalPart from './VerticalPart'

const PartCenterBottom = props =>
<VerticalPart
transform={`translate(${props.width / 2 -
props.stroke / 2}, ${props.height / 2 + props.spacing / 2})`}
transform={`translate(${props.width / 2 - props.stroke / 2}, ${props.height / 2 +
props.spacing / 2})`}
{...props}
/>

Expand Down
4 changes: 2 additions & 2 deletions src/components/digital_clock/parts/PartCenterLeft.js
Expand Up @@ -4,8 +4,8 @@ import HorizontalPart from './HorizontalPart'

const PartCenterLeft = props =>
<HorizontalPart
transform={`translate(${props.stroke / 2 +
props.spacing / 2}, ${props.height / 2 - props.stroke / 2})`}
transform={`translate(${props.stroke / 2 + props.spacing / 2}, ${props.height / 2 -
props.stroke / 2})`}
{...props}
/>

Expand Down
4 changes: 2 additions & 2 deletions src/components/digital_clock/parts/PartCenterRight.js
Expand Up @@ -4,8 +4,8 @@ import HorizontalPart from './HorizontalPart'

const PartCenterRight = props =>
<HorizontalPart
transform={`translate(${props.width / 2 +
props.spacing / 2}, ${props.height / 2 - props.stroke / 2})`}
transform={`translate(${props.width / 2 + props.spacing / 2}, ${props.height / 2 -
props.stroke / 2})`}
{...props}
/>

Expand Down
4 changes: 2 additions & 2 deletions src/components/digital_clock/parts/PartCenterTop.js
Expand Up @@ -4,8 +4,8 @@ import VerticalPart from './VerticalPart'

const PartCenterTop = props =>
<VerticalPart
transform={`translate(${props.width / 2 -
props.stroke / 2}, ${props.stroke / 2 + props.spacing / 2})`}
transform={`translate(${props.width / 2 - props.stroke / 2}, ${props.stroke / 2 +
props.spacing / 2})`}
{...props}
/>

Expand Down
5 changes: 1 addition & 4 deletions src/components/digital_clock/parts/PartLeftBottom.js
Expand Up @@ -3,10 +3,7 @@ import { partPropTypes } from './Part'
import VerticalPart from './VerticalPart'

const PartLeftBottom = props =>
<VerticalPart
transform={`translate(0, ${props.height / 2 + props.spacing / 2})`}
{...props}
/>
<VerticalPart transform={`translate(0, ${props.height / 2 + props.spacing / 2})`} {...props} />

PartLeftBottom.propTypes = partPropTypes

Expand Down
5 changes: 1 addition & 4 deletions src/components/digital_clock/parts/PartLeftTop.js
Expand Up @@ -3,10 +3,7 @@ import { partPropTypes } from './Part'
import VerticalPart from './VerticalPart'

const PartLeftTop = props =>
<VerticalPart
transform={`translate(0, ${props.stroke / 2 + props.spacing / 2})`}
{...props}
/>
<VerticalPart transform={`translate(0, ${props.stroke / 2 + props.spacing / 2})`} {...props} />

PartLeftTop.propTypes = partPropTypes

Expand Down
4 changes: 2 additions & 2 deletions src/components/digital_clock/parts/PartObliqueTopLeft.js
Expand Up @@ -5,8 +5,8 @@ import ObliquePart from './ObliquePart'
const PartObliqueTopLeft = props =>
<ObliquePart
{...props}
transform={`translate(${props.stroke +
props.spacing / 2}, ${props.stroke + props.spacing / 2})`}
transform={`translate(${props.stroke + props.spacing / 2}, ${props.stroke +
props.spacing / 2})`}
/>

PartObliqueTopLeft.propTypes = partPropTypes
Expand Down
4 changes: 1 addition & 3 deletions src/components/digital_clock/parts/PartObliqueTopRight.js
Expand Up @@ -5,9 +5,7 @@ import ObliquePart from './ObliquePart'
const PartObliqueTopRight = props =>
<ObliquePart
{...props}
transform={`translate(${props.width -
props.stroke -
props.spacing / 2}, ${props.stroke +
transform={`translate(${props.width - props.stroke - props.spacing / 2}, ${props.stroke +
props.spacing / 2}) scale(-1, 1)`}
/>

Expand Down
3 changes: 1 addition & 2 deletions src/components/digital_clock/parts/PartRightBottom.js
Expand Up @@ -4,8 +4,7 @@ import VerticalPart from './VerticalPart'

const PartRightBottom = props =>
<VerticalPart
transform={`translate(${props.width - props.stroke}, ${props.height /
2 +
transform={`translate(${props.width - props.stroke}, ${props.height / 2 +
props.spacing / 2})`}
{...props}
/>
Expand Down
3 changes: 1 addition & 2 deletions src/components/digital_clock/parts/PartRightTop.js
Expand Up @@ -4,8 +4,7 @@ import VerticalPart from './VerticalPart'

const PartRightTop = props =>
<VerticalPart
transform={`translate(${props.width - props.stroke}, ${props.stroke /
2 +
transform={`translate(${props.width - props.stroke}, ${props.stroke / 2 +
props.spacing / 2})`}
{...props}
/>
Expand Down

0 comments on commit c6ba5ea

Please sign in to comment.