-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into aaronmgdr/typed-localeStorage
# Conflicts: # packages/react-celo/src/use-celo-methods.ts
- Loading branch information
Showing
18 changed files
with
446 additions
and
105 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 @@ | ||
registry "https://registry.npmjs.org/" |
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,63 @@ | ||
# Development | ||
|
||
## Workflow | ||
|
||
To run all the packages locally at once, simply clone this repository and run: | ||
|
||
```sh | ||
yarn; | ||
yarn build; #only needs to be run the first time | ||
yarn dev; | ||
``` | ||
|
||
A hot reloading server should come up on localhost:3000, it's the exact same as what's at react-celo-canary.vercel.app. | ||
|
||
Alternatively, you can individually run `react-celo` and the `example` app in parallel. | ||
|
||
For that, you still need to have run `yarn` in the root. | ||
|
||
Then, you can run `react-celo` in one tab: | ||
|
||
```sh | ||
cd packages/react-celo | ||
yarn dev | ||
``` | ||
|
||
and run the `example` app in another: | ||
|
||
```sh | ||
cd packages/example | ||
yarn dev | ||
``` | ||
|
||
## Bumping the packages | ||
|
||
All packages under `/packages` are meant to published with the same version. | ||
|
||
To bump the version of all the packages at once, use the `bump-versions` script. | ||
You'll need to specify which semver increase you want to use. | ||
|
||
For example, to bump to a prerelease: | ||
|
||
```sh | ||
yarn bump-versions prerelease --preId alpha | ||
``` | ||
|
||
or for bumping a `major` version (same for `minor` or `patch`): | ||
|
||
```sh | ||
yarn bump-versions major | ||
``` | ||
|
||
## Publishing the packages | ||
|
||
Once the packages are ready to be published, ensure you've checked master and it is updated. Then, you can run the npm following npm script: | ||
|
||
```sh | ||
yarn publish-packages | ||
``` | ||
|
||
Hint: | ||
|
||
- You can use the `--dry-run` flag to check everything would run properly | ||
- If you need to run the script multiple times without changing the code, using the `--skip-build` flag can be useful to reduce the time. |
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
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,4 +1,7 @@ | ||
{ | ||
"extends": "./tsconfig.spec.json", | ||
"exclude": ["**/*.test.ts"] | ||
"exclude": ["**/*.test.ts"], | ||
"compilerOptions": { | ||
"jsx": "preserve" | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,102 @@ | ||
import { | ||
Color, | ||
contrast, | ||
hexToRGB, | ||
luminance, | ||
RGBToHex, | ||
} from '../../src/utils/colors'; | ||
|
||
describe('RGBToHex', () => { | ||
it('converts rgb to hex', () => { | ||
expect(RGBToHex('rgb(0, 0, 0)')).toEqual('#000000'); | ||
expect(RGBToHex('rgb(255, 0, 0)')).toEqual('#ff0000'); | ||
}); | ||
it('converts rgba to hex, with an error, and strip the alpha', () => { | ||
const spy = jest.spyOn(console, 'error'); | ||
expect(RGBToHex('rgba(255, 255, 255, 0.5)')).toEqual('#ffffff80'); | ||
expect(spy).toBeCalled(); | ||
}); | ||
}); | ||
|
||
describe('hexToRGB', () => { | ||
it('converts hex to rgb', () => { | ||
expect(hexToRGB('#000000')).toEqual('rgb(0, 0, 0)'); | ||
expect(hexToRGB('#ff0000')).toEqual('rgb(255, 0, 0)'); | ||
}); | ||
it('converts hex to rgba', () => { | ||
expect(hexToRGB('#000000ff')).toEqual('rgba(0, 0, 0, 1)'); | ||
expect(hexToRGB('#ff0000', 0.5)).toEqual('rgba(255, 0, 0, 0.5)'); | ||
}); | ||
}); | ||
|
||
describe('luminance', () => { | ||
it('calculates the luminance of one color', () => { | ||
expect(luminance(new Color('#fff'))).toBe(1); | ||
expect(luminance(new Color('#000'))).toBe(0); | ||
const randomColor = '#' + Math.floor(Math.random() * 0xffffff).toString(16); | ||
expect(luminance(new Color(randomColor))).toBeGreaterThanOrEqual(0); | ||
expect(luminance(new Color(randomColor))).toBeLessThanOrEqual(1); | ||
}); | ||
}); | ||
|
||
describe('contrast', () => { | ||
it('calculates the constrats between two colors', () => { | ||
expect(contrast(new Color('#fff'), new Color('#000'))).toBe(21); | ||
expect(contrast(new Color('#000'), new Color('#000'))).toBe(1); | ||
expect(contrast(new Color('#fff'), new Color('#fff'))).toBe(1); | ||
expect(contrast(new Color('#fff'), new Color('#444'))).toBe(9.74); | ||
}); | ||
}); | ||
|
||
describe('Color', () => { | ||
it('accepts hex', () => { | ||
const color1 = new Color('#000000'); | ||
expect(color1.r).toEqual(0x00); | ||
expect(color1.g).toEqual(0x00); | ||
expect(color1.b).toEqual(0x00); | ||
expect(color1.a).toEqual(null); | ||
const color2 = new Color('#f00'); | ||
expect(color2.r).toEqual(0xff); | ||
expect(color1.g).toEqual(0x00); | ||
expect(color1.b).toEqual(0x00); | ||
expect(color1.a).toEqual(null); | ||
const color3 = new Color('#ffffff80'); | ||
expect(color3.r).toEqual(0xff); | ||
expect(color3.r).toEqual(0xff); | ||
expect(color3.r).toEqual(0xff); | ||
expect(color3.a).toEqual(0.5); | ||
}); | ||
it('accepts rgb(a)', () => { | ||
const color1 = new Color('rgb(0, 0, 0)'); | ||
expect(color1.r).toEqual(0x00); | ||
expect(color1.g).toEqual(0x00); | ||
expect(color1.b).toEqual(0x00); | ||
expect(color1.a).toEqual(null); | ||
const color2 = new Color('rgb(255, 0, 0)'); | ||
expect(color2.r).toEqual(0xff); | ||
expect(color1.g).toEqual(0x00); | ||
expect(color1.b).toEqual(0x00); | ||
expect(color1.a).toEqual(null); | ||
const color3 = new Color('rgb(255, 255, 255, 0.2)'); | ||
expect(color3.r).toEqual(0xff); | ||
expect(color3.r).toEqual(0xff); | ||
expect(color3.r).toEqual(0xff); | ||
expect(color3.a).toEqual(0.2); | ||
}); | ||
it('accepts hsl(a)', () => { | ||
const color1 = new Color('hsl(0, 0, 0)'); | ||
expect(color1.r).toEqual(0x00); | ||
expect(color1.g).toEqual(0x00); | ||
expect(color1.b).toEqual(0x00); | ||
expect(color1.a).toEqual(null); | ||
const color2 = new Color('hsl(359, 94, 62)'); | ||
expect(color2.r).toEqual(0xf9); | ||
expect(color2.g).toEqual(0x43); | ||
expect(color2.b).toEqual(0x46); | ||
const color3 = new Color('hsl(359, 94, 62, 0.3)'); | ||
expect(color3.r).toEqual(0xf9); | ||
expect(color3.g).toEqual(0x43); | ||
expect(color3.b).toEqual(0x46); | ||
expect(color3.a).toEqual(0.3); | ||
}); | ||
}); |
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
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.