-
Notifications
You must be signed in to change notification settings - Fork 1
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 #493 from kitsuyui/refactor-bulma-stopwatch-and-timer
Refactor: style-bulma timer and stopwatch components
- Loading branch information
Showing
7 changed files
with
269 additions
and
79 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,110 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Stopwatch render Stopwatch 1`] = ` | ||
<DocumentFragment> | ||
<div | ||
class="card" | ||
> | ||
<div | ||
class="card-content" | ||
> | ||
<p | ||
class="title is-family-monospace has-text-centered" | ||
> | ||
00:00:00.000 | ||
</p> | ||
</div> | ||
<footer | ||
class="card-footer" | ||
> | ||
<button | ||
class="card-footer-item is-clickable is-button" | ||
disabled="" | ||
type="button" | ||
> | ||
Reset | ||
</button> | ||
<button | ||
class="card-footer-item is-clickable is-button" | ||
type="button" | ||
> | ||
Start | ||
</button> | ||
</footer> | ||
</div> | ||
</DocumentFragment> | ||
`; | ||
|
||
exports[`Timer render Timer 1`] = ` | ||
<DocumentFragment> | ||
<div | ||
class="card" | ||
> | ||
<div | ||
class="card-content" | ||
> | ||
<p | ||
class="title is-family-monospace has-text-centered" | ||
> | ||
00:00:00.000 | ||
</p> | ||
</div> | ||
<footer | ||
class="card-footer" | ||
> | ||
<span | ||
class="card-footer-item" | ||
> | ||
<button | ||
class="is-button" | ||
type="button" | ||
> | ||
+1h | ||
</button> | ||
</span> | ||
<span | ||
class="card-footer-item" | ||
> | ||
<button | ||
class="is-button" | ||
type="button" | ||
> | ||
+1m | ||
</button> | ||
</span> | ||
<span | ||
class="card-footer-item" | ||
> | ||
<button | ||
class="is-button" | ||
type="button" | ||
> | ||
+1s | ||
</button> | ||
</span> | ||
<span | ||
class="card-footer-item" | ||
> | ||
<button | ||
class="is-button" | ||
disabled="" | ||
type="button" | ||
> | ||
Reset | ||
</button> | ||
</span> | ||
<span | ||
class="card-footer-item" | ||
> | ||
<button | ||
class="is-button" | ||
disabled="" | ||
type="button" | ||
> | ||
Start | ||
</button> | ||
</span> | ||
</footer> | ||
</div> | ||
</DocumentFragment> | ||
`; |
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,8 +1,26 @@ | ||
import { render } from '@testing-library/react' | ||
import React from 'react' | ||
|
||
import { Clock } from '.' | ||
import { Clock } from './clock' | ||
import { Stopwatch } from './stopwatch' | ||
import { Timer } from './timer' | ||
|
||
test('render Clock', () => { | ||
render(<Clock />) | ||
describe('Clock', () => { | ||
test('render Clock', () => { | ||
render(<Clock />) | ||
}) | ||
}) | ||
|
||
describe('Stopwatch', () => { | ||
test('render Stopwatch', () => { | ||
const { asFragment } = render(<Stopwatch />) | ||
expect(asFragment()).toMatchSnapshot() | ||
}) | ||
}) | ||
|
||
describe('Timer', () => { | ||
test('render Timer', () => { | ||
const { asFragment } = render(<Timer />) | ||
expect(asFragment()).toMatchSnapshot() | ||
}) | ||
}) |
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 @@ | ||
export const timeLabelString = (total: number): string => { | ||
const hours = Math.floor(total / 3600) | ||
const remaining = total - hours * 3600 | ||
const minutes = Math.floor(remaining / 60) | ||
const seconds = (remaining % 60) | 0 | ||
const milliseconds = ((remaining % 1) * 1000) | 0 | ||
const hoursString = String(hours).padStart(2, '0') | ||
const minutesString = String(minutes).padStart(2, '0') | ||
const secondsString = String(seconds).padStart(2, '0') | ||
const millisecondsString = String(milliseconds).padStart(3, '0') | ||
return `${hoursString}:${minutesString}:${secondsString}.${millisecondsString}` | ||
} |
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 { timeLabelString } from "."; | ||
|
||
describe("timeLabelString", () => { | ||
it("should format time", () => { | ||
expect(timeLabelString(0)).toBe("00:00:00.000"); | ||
expect(timeLabelString(1)).toBe("00:00:01.000"); | ||
expect(timeLabelString(60)).toBe("00:01:00.000"); | ||
expect(timeLabelString(61)).toBe("00:01:01.000"); | ||
expect(timeLabelString(3600)).toBe("01:00:00.000"); | ||
expect(timeLabelString(3601)).toBe("01:00:01.000"); | ||
expect(timeLabelString(3661)).toBe("01:01:01.000"); | ||
expect(timeLabelString(3661.123)).toBe("01:01:01.123"); | ||
}); | ||
}); |
Oops, something went wrong.