-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Noah Hummel
committed
Mar 2, 2022
0 parents
commit 5e7fe2f
Showing
25 changed files
with
20,236 additions
and
0 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,5 @@ | ||
{ | ||
"extends": [ | ||
"es/browser" | ||
] | ||
} |
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,17 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: npm | ||
directory: "/" | ||
schedule: | ||
interval: daily | ||
open-pull-requests-limit: 10 | ||
assignees: | ||
- strangedev | ||
labels: | ||
- Dependencies | ||
versioning-strategy: increase | ||
allow: | ||
- dependency-type: direct | ||
commit-message: | ||
prefix: fix | ||
prefix-development: chore |
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,26 @@ | ||
name: QA | ||
|
||
on: pull_request | ||
|
||
jobs: | ||
qa: | ||
name: QA | ||
runs-on: ${{ matrix.os }} | ||
|
||
strategy: | ||
matrix: | ||
node-version: [ '16.x' ] | ||
os: [ ubuntu-latest, macos-latest ] | ||
|
||
steps: | ||
- uses: actions/checkout@v1 | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- name: Install dependencies | ||
run: | | ||
npm install | ||
- name: Run roboter | ||
run: | | ||
npx roboter |
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,32 @@ | ||
name: Release | ||
|
||
on: | ||
push: | ||
branches: | ||
- 'main' | ||
|
||
jobs: | ||
release: | ||
name: Release | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v1 | ||
- name: Use Node.js | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: 16.x | ||
- name: Install dependencies | ||
run: | | ||
npm install | ||
- name: Run roboter | ||
run: | | ||
npx roboter | ||
- name: Compile TypeScript | ||
run: | | ||
npx roboter build | ||
- name: Release | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GH_TOKEN_ADMIN }} | ||
NPM_TOKEN: ${{ secrets.NPM_TOKEN_ADMIN }} | ||
run: npx semantic-release |
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,3 @@ | ||
.idea | ||
node_modules | ||
build |
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,3 @@ | ||
{ | ||
"extends": "semantic-release-configuration" | ||
} |
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,27 @@ | ||
## [1.0.3](https://github.com/strangedev/react-i18next-fluent/compare/1.0.2...1.0.3) (2022-02-25) | ||
|
||
|
||
### Bug Fixes | ||
|
||
* move unneeded deps to dev deps ([#2](https://github.com/strangedev/react-i18next-fluent/issues/2)) ([53e24b7](https://github.com/strangedev/react-i18next-fluent/commit/53e24b7003df988743a5349c5c5b981a9a52c78d)) | ||
|
||
## [1.0.2](https://github.com/strangedev/react-i18next-fluent/compare/1.0.1...1.0.2) (2022-02-25) | ||
|
||
|
||
### Bug Fixes | ||
|
||
* build ([1bc7cb0](https://github.com/strangedev/react-i18next-fluent/commit/1bc7cb076ec6f8b119106ca0ee02614fe90d47d8)) | ||
|
||
## [1.0.1](https://github.com/strangedev/react-i18next-fluent/compare/1.0.0...1.0.1) (2022-02-25) | ||
|
||
|
||
### Bug Fixes | ||
|
||
* fix package.json ([bf617f1](https://github.com/strangedev/react-i18next-fluent/commit/bf617f138763c90b2cf2d027789d39bf455f4bc0)) | ||
|
||
# 1.0.0 (2022-02-25) | ||
|
||
|
||
### Features | ||
|
||
* initial implementation and some tests ([84bdc91](https://github.com/strangedev/react-i18next-fluent/commit/84bdc9158cee37204ae632a74a2abf1255189f17)) |
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,8 @@ | ||
Copyright 2022 Noah Hummel | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
|
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,15 @@ | ||
# css-in-js | ||
|
||
Helpers for generating CSS from JS. | ||
|
||
## TODO... | ||
|
||
## Contributing | ||
|
||
Feel free to open an issue or a pull request. | ||
|
||
### Running quality assurance | ||
|
||
```shell | ||
npx roboter | ||
``` |
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,35 @@ | ||
import { Stringable, Stringlike } from './Stringable'; | ||
|
||
type CssClause = [ string, Stringlike ]; | ||
|
||
class CssBuilder implements Stringable { | ||
private readonly clauses: CssClause[]; | ||
|
||
protected constructor (clauses: CssClause[]) { | ||
this.clauses = clauses; | ||
} | ||
|
||
public static new (): CssBuilder { | ||
return new CssBuilder([]); | ||
} | ||
|
||
public add (...clause: CssClause): CssBuilder { | ||
return new CssBuilder([ | ||
...this.clauses, | ||
clause | ||
]); | ||
} | ||
|
||
public toString (): string { | ||
return this.clauses. | ||
map(([ key, value ]): string => `${key}: ${value};`). | ||
join('\n'); | ||
} | ||
} | ||
|
||
export { | ||
CssBuilder | ||
}; | ||
export type { | ||
CssClause | ||
}; |
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,10 @@ | ||
interface Stringable { | ||
toString: () => string; | ||
} | ||
|
||
type Stringlike = string | Stringable; | ||
|
||
export type { | ||
Stringable, | ||
Stringlike | ||
}; |
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,196 @@ | ||
import color from 'color'; | ||
import { Quantity } from './base/Quantity'; | ||
import { Stringable } from '../Stringable'; | ||
|
||
type Rgba = 'rgba'; | ||
type Rgb = 'rgb'; | ||
type Hex = 'hex'; | ||
|
||
type RgbValue = [ number, number, number ]; | ||
type RgbaValue = [ number, number, number, number ]; | ||
type HexValue = `#${string}`; | ||
|
||
type ColorValue = RgbValue | RgbaValue | HexValue; | ||
type ColorSign = Rgb | Rgba | Hex; | ||
|
||
const clamp = function (value: number, min: number, max: number): number { | ||
return Math.min(max, Math.max(min, value)); | ||
}; | ||
|
||
abstract class Color<TValue extends ColorValue = ColorValue, TSign extends ColorSign = ColorSign> extends Quantity<TValue, TSign, Color<TValue, TSign>> implements Stringable { | ||
public abstract toString (): string; | ||
|
||
public abstract valueRgba (): RgbaValue; | ||
|
||
public negate (): ColorRgba { | ||
const rgba = this.valueRgba(); | ||
const newRgb = color(rgba.slice(0, -1)).negate().rgb().array() as RgbValue; | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-use-before-define | ||
return ColorRgba.new( | ||
...newRgb, | ||
rgba[3] | ||
); | ||
} | ||
|
||
public lighten (amount: number): ColorRgba { | ||
const rgba = this.valueRgba(); | ||
const newRgb = color(rgba.slice(0, -1)).lighten(amount).rgb().array() as RgbValue; | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-use-before-define | ||
return ColorRgba.new( | ||
...newRgb, | ||
rgba[3] | ||
); | ||
} | ||
|
||
public darken (amount: number): ColorRgba { | ||
const rgba = this.valueRgba(); | ||
const newRgb = color(rgba.slice(0, -1)).darken(amount).rgb().array() as RgbValue; | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-use-before-define | ||
return ColorRgba.new( | ||
...newRgb, | ||
rgba[3] | ||
); | ||
} | ||
|
||
public saturate (amount: number): ColorRgba { | ||
const rgba = this.valueRgba(); | ||
const newRgb = color(rgba.slice(0, -1)).saturate(amount).rgb().array() as RgbValue; | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-use-before-define | ||
return ColorRgba.new( | ||
...newRgb, | ||
rgba[3] | ||
); | ||
} | ||
|
||
public desaturate (amount: number): ColorRgba { | ||
const rgba = this.valueRgba(); | ||
const newRgb = color(rgba.slice(0, -1)).desaturate(amount).rgb().array() as RgbValue; | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-use-before-define | ||
return ColorRgba.new( | ||
...newRgb, | ||
rgba[3] | ||
); | ||
} | ||
|
||
public grayscale (): ColorRgba { | ||
const rgba = this.valueRgba(); | ||
const newRgb = color(rgba.slice(0, -1)).grayscale().rgb().array() as RgbValue; | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-use-before-define | ||
return ColorRgba.new( | ||
...newRgb, | ||
rgba[3] | ||
); | ||
} | ||
|
||
public isDark (): boolean { | ||
const rgba = this.valueRgba(); | ||
|
||
return color(rgba.slice(0, -1)).isDark(); | ||
} | ||
|
||
public isLight (): boolean { | ||
const rgba = this.valueRgba(); | ||
|
||
return color(rgba.slice(0, -1)).isLight(); | ||
} | ||
|
||
public fade (amount: number): ColorRgba { | ||
const rgba = this.valueRgba(); | ||
const alpha = rgba[3]; | ||
const range = alpha; | ||
const fadedAlpha = clamp(alpha - (range * amount), 0, 1); | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-use-before-define | ||
return ColorRgba.new( | ||
...rgba.slice(0, -1) as RgbValue, | ||
fadedAlpha | ||
); | ||
} | ||
|
||
public opaquer (amount: number): ColorRgba { | ||
const rgba = this.valueRgba(); | ||
const alpha = rgba[3]; | ||
const range = 1 - alpha; | ||
const opaquerAlpha = clamp(alpha + (range * amount), 0, 1); | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-use-before-define | ||
return ColorRgba.new( | ||
...rgba.slice(0, -1) as RgbValue, | ||
opaquerAlpha | ||
); | ||
} | ||
} | ||
|
||
class ColorRgb extends Color<RgbValue, Rgb> { | ||
public static new (...value: RgbValue): ColorRgb { | ||
return new ColorRgb({ value, sign: 'rgb' }); | ||
} | ||
|
||
public toString (): string { | ||
return `rgb(${this.value.join(',')})`; | ||
} | ||
|
||
public valueRgba (): RgbaValue { | ||
return [ ...this.value, 1 ]; | ||
} | ||
|
||
public clone (): ColorRgb { | ||
return ColorRgb.new(...this.value); | ||
} | ||
} | ||
|
||
class ColorRgba extends Color<RgbaValue, Rgba> { | ||
public static new (...value: RgbaValue): ColorRgba { | ||
return new ColorRgba({ value, sign: 'rgba' }); | ||
} | ||
|
||
public toString (): string { | ||
return `rgba(${this.value.join(',')})`; | ||
} | ||
|
||
public valueRgba (): RgbaValue { | ||
return [ ...this.value ]; | ||
} | ||
|
||
public clone (): ColorRgba { | ||
return ColorRgba.new(...this.value); | ||
} | ||
} | ||
|
||
class ColorHex extends Color<HexValue, Hex> { | ||
public static new (value: HexValue): ColorHex { | ||
return new ColorHex({ value, sign: 'hex' }); | ||
} | ||
|
||
public toString (): string { | ||
return this.value; | ||
} | ||
|
||
public valueRgba (): RgbaValue { | ||
const rgb = color(this.value).rgb().array() as RgbValue; | ||
|
||
return [ ...rgb, 1 ]; | ||
} | ||
|
||
public clone (): ColorHex { | ||
return ColorHex.new(this.value); | ||
} | ||
} | ||
|
||
export { | ||
Color, | ||
ColorHex, | ||
ColorRgb, | ||
ColorRgba | ||
}; | ||
export type { | ||
HexValue, | ||
RgbValue, | ||
RgbaValue | ||
}; |
Oops, something went wrong.