Skip to content

add support to use backgroundColor and fontColor #26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ npm install react-countdown-clock
| prop | type | default | description |
|------------------|----------------|---------|-----------------------------------------------------------|
| seconds | integer | 60 | Seconds to countdown |
| color | string | #000 | Colour of counter |
| color | string | #000 | Colour of progressing counter |
| backgroundColor | string | #000 | Colour of counter background, default to color |
| fontColor | string | #000 | Colour of counter text, default to color |
| alpha | float | 1.0 | Alpha transparency of counter |
| size | integer | 300 | Width & height of canvas element |
| weight | integer | | Weight of circle, in pixels |
Expand Down
7 changes: 1 addition & 6 deletions build/react-countdown-clock.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/react-countdown-clock.js.map

Large diffs are not rendered by default.

12 changes: 9 additions & 3 deletions coffee/react-countdown-clock.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ ReactCountdownClock = CreateReactClass
_drawBackground: ->
@_background.beginPath()
@_background.globalAlpha = @props.alpha / 3
@_background.fillStyle = @props.color
@_background.fillStyle = @props.backgroundColor or @props.color
@_background.arc @_radius, @_radius, @_radius, 0, Math.PI * 2, false
@_background.arc @_radius, @_radius, @_innerRadius, Math.PI * 2, 0, true
@_background.closePath()
Expand Down Expand Up @@ -162,11 +162,15 @@ ReactCountdownClock = CreateReactClass
formattedTime = @_formattedTime()
text = if (@props.paused && @props.pausedText?) then @props.pausedText else formattedTime

# Timer Text
@_timer.fillStyle = @props.fontColor or @props.color
@_timer.font = "bold #{@_fontSize(formattedTime)} #{@props.font}"
@_timer.fillText text, @_radius, @_radius
@_timer.fill()

# Timer
@_timer.globalAlpha = @props.alpha
@_timer.fillStyle = @props.color
@_timer.font = "bold #{@_fontSize(formattedTime)} #{@props.font}"
@_timer.fillText text, @_radius, @_radius
@_timer.beginPath()
@_timer.arc @_radius, @_radius, @_radius, Math.PI * 1.5, Math.PI * percent, false
@_timer.arc @_radius, @_radius, @_innerRadius, Math.PI * percent, Math.PI * 1.5, true
Expand All @@ -193,6 +197,8 @@ ReactCountdownClock.propTypes =
showMilliseconds: PropTypes.bool
paused: PropTypes.bool
pausedText: PropTypes.string
backgroundColor: React.PropTypes.string
fontColor: React.PropTypes.string

ReactCountdownClock.defaultProps =
seconds: 60
Expand Down
4 changes: 4 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
return {
seconds: randomAmountOfSeconds(),
color: randomColor(),
fontColor: '#aaa',
backgroundColor: '#fff',
paused: false,
fontSize: 'auto'
}
Expand All @@ -64,6 +66,8 @@
React.createElement(ReactCountdownClock, {
seconds: this.state.seconds,
color: this.state.color,
fontColor: this.state.fontColor,
backgroundColor: this.state.backgroundColor,
paused: this.state.paused,
pausedText: "▐▐ ",
alpha: 0.9,
Expand Down