Skip to content

Commit 95f47cc

Browse files
authored
Merge pull request #85 from ryanhefner/feat/add-format
[feat] Add New Format
2 parents 7baf4b7 + 95c635c commit 95f47cc

31 files changed

+5752
-13193
lines changed

.babelrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"presets": ["./tools/babel-preset.js"]
2+
"presets": ["./tools/babel-preset.cjs"]
33
}

.circleci/config.yml

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,15 @@
1-
# Javascript Node CircleCI 2.0 configuration file
2-
#
3-
# Check https://circleci.com/docs/2.0/language-javascript/ for more details
4-
#
5-
version: 2
6-
jobs:
7-
build:
8-
docker:
9-
# specify the version you desire here
10-
- image: circleci/node:10.18.0
11-
12-
# Specify service dependencies here if necessary
13-
# CircleCI maintains a library of pre-built images
14-
# documented at https://circleci.com/docs/2.0/circleci-images/
15-
# - image: circleci/mongo:3.4.4
1+
# This config is equivalent to both the '.circleci/extended/orb-free.yml' and the base '.circleci/config.yml'
2+
version: 2.1
163

17-
working_directory: ~/repo
4+
# Orbs are reusable packages of CircleCI configuration that you may share across projects, enabling you to create encapsulated, parameterized commands, jobs, and executors that can be used across multiple projects.
5+
# See: https://circleci.com/docs/2.0/orb-intro/
6+
orbs:
7+
node: circleci/node@4.7
188

9+
jobs:
10+
build-test-package:
11+
docker:
12+
- image: cimg/node:18.0.0
1913
steps:
2014
- checkout
2115

@@ -26,20 +20,28 @@ jobs:
2620
# fallback to using the latest cache if no exact match is found
2721
- v1-dependencies-
2822

29-
- run: npm i
23+
- run: yarn
3024

3125
- save_cache:
3226
paths:
3327
- node_modules
3428
key: v1-dependencies-{{ checksum "package.json" }}
3529

36-
- run: ./node_modules/.bin/greenkeeper-lockfile-update
37-
- run: npm run build
30+
- run: yarn build
3831

3932
# run tests!
40-
- run: npm run test
33+
- run: yarn test:ci
4134

4235
# send code coverage info to coveralls
4336
- run: cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js
4437

45-
- run: ./node_modules/.bin/greenkeeper-lockfile-upload
38+
# send code coverage info to codecov
39+
- run: bash <(curl -s https://codecov.io/bash)
40+
41+
# Invoke jobs via workflows
42+
# See: https://circleci.com/docs/2.0/configuration-reference/#workflows
43+
workflows:
44+
test-package: # This is the name of the workflow, feel free to change it to better match your workflow.
45+
# Inside the workflow, you define the jobs you want to run.
46+
jobs:
47+
- build-test-package

.eslintrc.json

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{
2+
"env": {
3+
"browser": true,
4+
"es2021": true,
5+
"node": true
6+
},
7+
"extends": [
8+
"plugin:react/recommended",
9+
"plugin:react-hooks/recommended",
10+
"plugin:prettier/recommended"
11+
],
12+
"ignorePatterns": ["!**/*"],
13+
"overrides": [
14+
{
15+
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
16+
"rules": {
17+
"semi": ["error", "never"],
18+
"no-prototype-builtins": "off",
19+
"react/react-in-jsx-scope": "off",
20+
"react-hooks/rules-of-hooks": "error",
21+
"react-hooks/exhaustive-deps": "warn",
22+
"react/prop-types": "off",
23+
"prettier/prettier": [
24+
"error",
25+
{
26+
"endOfLine": "auto"
27+
}
28+
]
29+
}
30+
},
31+
{
32+
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
33+
"rules": {}
34+
}
35+
],
36+
"parserOptions": {
37+
"babelOptions": {
38+
"plugins": [
39+
"@babel/plugin-syntax-import-assertions"
40+
]
41+
},
42+
"ecmaVersion": "latest",
43+
"sourceType": "module"
44+
}
45+
}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ es
44
node_modules
55
umd
66
/*.js
7+
/*.cjs
78
npm-debug.log
89
yarn-error.log
910
*.sublime-project
1011
*.sublime-workspace
1112
!rollup.config.js
13+
!jest.config.cjs

.npmignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
.circleci
2+
.github
13
coverage
24
tools
35
src/.babelrc
6+
src/__snapshots__
47
**/*.test.js
58
rollup.config.js
69
*.sublime-project

.prettierrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"singleQuote": true,
3+
"semi": false
4+
}

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2018 Ryan Hefner <hi@ryanhefner.com> (https://www.ryanhefner.com)
3+
Copyright (c) 2018 - 2023: [Ryan Hefner](https://www.ryanhefner.com)
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
![npm](https://img.shields.io/npm/dt/react-timecode?style=flat-square)
66
![Coveralls github](https://img.shields.io/coveralls/github/ryanhefner/react-timecode?style=flat-square)
77
![CircleCI](https://img.shields.io/circleci/build/github/ryanhefner/react-timecode?style=flat-square)
8-
![Snyk Vulnerabilities for GitHub Repo](https://img.shields.io/snyk/vulnerabilities/github/ryanhefner/react-timecode?style=flat-square)
8+
![Known Vulnerabilities](https://snyk.io/test/github/ryanhefner/react-timecode/badge.svg)
9+
![Twitter Follow](https://img.shields.io/twitter/follow/ryanhefner)
910

1011

1112
Simple React component for displaying a timecode, with various formatting options.
@@ -32,7 +33,8 @@ simple example.
3233

3334
### Properties
3435

35-
* `component:String|Function` - Element to render the timecode within. (Default: `span`)
36+
* `as:String|Function` - Element to render the timecode within. (Default: `span`)
37+
* `[DEPRECATED]` `component:String|Function` - Element to render the timecode within. (Default: `span`)
3638
* `format:String` - Specifies the format to display the timecode. (Default: `H:?m:ss`)
3739
* `HH:mm:ss.SSS` - (Example: 00:01:23.876)
3840
* `H:mm:ss.SSS` - (Example: 0:01:23.876)
@@ -44,6 +46,8 @@ simple example.
4446
* `H:mm` - (Example: 0:01)
4547
* `s.SSS` - (Example: 0.000)
4648
* `s.SS` - (Example: 0.00)
49+
* `mm:ss` - (Example: 90:00)
50+
* `H:?mm:ss` - (Example: 00:00)
4751
* `H:?m:ss` - (Example: 1:23 - _Default_)
4852
* `postfix:String` - Append a string after the formatted timecode.
4953
* `prefix:String` - Include a string before the formatted timecode.
@@ -70,6 +74,17 @@ import Timecode from 'react-timecode';
7074

7175
```
7276

77+
### Utilities
78+
79+
In addition to the `Timecode` component, the underlying utility methods that the
80+
component uses for rendering the timecodes have also been exposed, in case you
81+
have some need to render some strings without the context of the component.
82+
83+
* `parseTime(time:Number): { hours: Number, minutes: Number, seconds: Number, milliseconds: Number }`
84+
* `pad(number: Number, length: Number = 2): String`
85+
* `formatMilliseconds(milliseconds: Number, length: Number = 3): String`
86+
* `formatTimecode({ format: String, time: Number }): String`
87+
7388
## Pairs well with...
7489

7590
* [react-timer-wrapper](https://github.com/ryanhefner/react-timer-wrapper)

jest.config.cjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
testEnvironment: 'jsdom',
3+
}

0 commit comments

Comments
 (0)