Skip to content
Merged
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
48 changes: 48 additions & 0 deletions docs-md/api/readableColor.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->

# readableColor

Returns a readable light/dark color based on the provided HEX value. User can provide custom light/dark values.

### Parameters

* `hex` **[string][1]** HEX color to change brightness
* `options` **[Object][2]?** user provided object to override default colors

* `options.light` **[string][1]?** light color
* `options.dark` **[string][1]?** dark color

### Examples

```javascript
readableColor('#222001');
// => '#ffffff'

readableColor('#baebd8');
// => '#24292f'

readableColor('#261104', { light: '#fcf' });
// => '#fcf'

readableColor('#fbdbd7', { dark: '#000' });
// => '#A8646'

readableColor('#013735', { light: '#fcf', dark: '#000' });
// => '#fcf'

readableColor('#defbf7', { light: '#fcf', dark: '#000' });
// => '#000'
```

Returns **[string][1]** light/dark hex value.

**Meta**

* **version**: 4.3.0

[1]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String

[2]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object


* Source: [readable-color.ts](https://github.com/iamdevlinph/common-utils-pkg/blob/main/src/readable-color/readable-color.ts#L33-L45)
4 changes: 4 additions & 0 deletions docs-md/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ id: changelog

# Changelog

##### 4.3.0

- **NEW:** `Colors -> readableColor` - get light/dark mode color for text readability

##### 4.2.0

- Removed `arrayToString` -> `Array.prototype.join`
Expand Down
7 changes: 3 additions & 4 deletions docs/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ Closes: #

- [ ] This PR will add a **new method**
- [ ] **New method directory** `src/<method_name>/`
- [ ] **Created method file** under `src/<method_name>/<method_name>.js`
- [ ] **Created method file** under `src/<method_name>/<method_name>.ts`
- [ ] **Added jsdoc comments** in the method file
- [ ] **Created a test** under `src/<method_name>/<method_name>.spec.js`
- [ ] **Export the method file in main entry file** `src/index.js`
- [ ] **Add entry in the typings**
- [ ] **Created a test** under `src/<method_name>/<method_name>.test.ts`
- [ ] **Export the method file in main entry file** `src/index.ts`
- [ ] **Generate docs**

---
Expand Down
37 changes: 13 additions & 24 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "common-utils-pkg",
"version": "4.2.0",
"version": "4.3.0",
"description": "A package of commonly used JavaScript utilities.",
"keywords": [
"utilities",
Expand Down Expand Up @@ -48,19 +48,19 @@
"docusaurus:write-heading-ids": "docusaurus write-heading-ids"
},
"dependencies": {
"@docusaurus/plugin-google-gtag": "^3.9.2",
"@docusaurus/plugin-google-gtag": "3.9.2",
"lz-string": "1.5.0"
},
"devDependencies": {
"@docusaurus/core": "3.10.0",
"@docusaurus/module-type-aliases": "3.10.0",
"@docusaurus/preset-classic": "3.10.0",
"@docusaurus/tsconfig": "3.10.0",
"@docusaurus/types": "3.10.0",
"@eslint/eslintrc": "^3.3.5",
"@eslint/js": "^10.0.1",
"@docusaurus/core": "3.10.1",
"@docusaurus/module-type-aliases": "3.10.1",
"@docusaurus/preset-classic": "3.10.1",
"@docusaurus/tsconfig": "3.10.1",
"@docusaurus/types": "3.10.1",
"@eslint/eslintrc": "3.3.5",
"@eslint/js": "10.0.1",
"@mdx-js/react": "3.1.1",
"@types/jest": "^30.0.0",
"@types/jest": "30.0.0",
"@types/node": "25.6.0",
"@typescript-eslint/eslint-plugin": "8.58.2",
"@typescript-eslint/parser": "8.58.2",
Expand All @@ -72,16 +72,16 @@
"eslint-plugin-simple-import-sort": "13.0.0",
"http-server": "14.1.1",
"husky": "9.1.7",
"jest": "^30.3.0",
"jest": "30.3.0",
"lint-staged": "16.4.0",
"mock-local-storage": "1.1.24",
"prettier": "3.8.3",
"prism-react-renderer": "2.4.1",
"react": "19.2.5",
"react-dom": "19.2.5",
"shell-quote": "1.8.3",
"ts-jest": "^29.1.2",
"tsup": "^8.3.5",
"ts-jest": "29.1.2",
"tsup": "8.3.5",
"typescript": "6.0.2"
},
"browserslist": {
Expand All @@ -95,16 +95,5 @@
"last 3 firefox version",
"last 5 safari version"
]
},
"pnpm": {
"overrides": {
"webpackbar": "^7.0.0"
}
},
"overrides": {
"webpackbar": "^7.0.0"
},
"resolutions": {
"webpackbar": "^7.0.0"
}
}
Loading
Loading