Skip to content

Commit

Permalink
chore(lib): downgrade peer deps and update readme (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
mwiercinska authored Aug 14, 2024
1 parent b5034bd commit 2b4e142
Show file tree
Hide file tree
Showing 5 changed files with 128 additions and 85 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lib.yml → .github/workflows/verify.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Run Tests
name: Verify package

on:
pull_request:
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@ TODO
## How to find the ledgerId ?

You can use Coinradar: https://coinradar.ledger.com/

## @ledgerhq/crypto-icons

See @ledgerhq/crypto-icons library README here: [lib/README.md](lib/README.md)
19 changes: 13 additions & 6 deletions lib/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@

A package which provides a `<CryptoIcon />` component that can be consumed by Ledger applications in a React environment and used with a `ledgerId` to render icons.

<!-- TODO: add Storybook link -->

## Installation

```bash
pnpm i @ledgerhq/crypto-icons
# or
yarn add @ledgerhq/crypto-icons
npm set //npm.pkg.github.com/:_authToken=<GITHUB_TOKEN>
npm config set @ledgerhq/crypto-icons:registry https://npm.pkg.github.com/
# or setup the .npmrc file with this config in the root of your project
# https://docs.npmjs.com/cli/v10/configuring-npm/npmrc
```

```bash
npm install @ledgerhq/crypto-icons
```

### Usage example
Expand All @@ -30,7 +33,11 @@ const Page = () => {

## Icon sources

The component's primary source of icons is Ledger's CDN which contains the [assets](../assets/index.json) from this repository. It attempts to fetch a [mapping from Ledger's CDN](https://crypto-icons.ledger.com/index.json) and if the ledgerId that is passed in as a prop to the component is found, the URL for that key is used as the image source. Otherwise, a request to the [Ledger mapping service](https://ledgerhq.atlassian.net/wiki/spaces/BE/pages/3973022073/Mapping+Service) is made to retrieve a [CoinGecko mapping](https://mapping-service.api.ledger.com/v1/coingecko/mapped-assets) as a fallback. If a match for an icon is found using the ledgerId then it is used as the image source. If neither mapping has a match, a `<FallbackIcon />` component is returned with the first letter of the currency ticker as its content e.g. B for BTC.
The component's primary source of icons is Ledger's CDN which contains the [assets](../assets/index.json) from this repository. It attempts to fetch a [mapping from Ledger's CDN](https://crypto-icons.ledger.com/index.json) and if the ledgerId that is passed in as a prop to the component is found, the URL for that key is used as the image source. You can see an up-to-date list of all available Ledger icons in this [Storybook](https://crypto-icons-storybook.pages.dev).

Otherwise, a request to the [Ledger mapping service](https://ledgerhq.atlassian.net/wiki/spaces/BE/pages/3973022073/Mapping+Service) is made to retrieve a [CoinGecko mapping](https://mapping-service.api.ledger.com/v1/coingecko/mapped-assets) as a fallback. If a match for an icon is found using the ledgerId then it is used as the image source.

If neither mapping has a match, a `<FallbackIcon />` component is returned with the first letter of the currency ticker as its content e.g. B for BTC.

```mermaid
flowchart TD
Expand Down
17 changes: 9 additions & 8 deletions lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@
"@types/jest": "^29.5.12",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"@types/styled-components": "^5.1.34",
"@typescript-eslint/eslint-plugin": "^7.17.0",
"@typescript-eslint/parser": "^7.17.0",
"axios": "^1.7.2",
"axios": "^1.6.0",
"eslint": "^8.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.29.1",
Expand All @@ -49,21 +50,21 @@
"msw": "1.3.3",
"prettier": "^3.3.3",
"prettier-plugin-organize-imports": "^4.0.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react": "^18",
"react-dom": "^18",
"rollup": "^4.19.0",
"rollup-plugin-peer-deps-external": "^2.2.4",
"rollup-plugin-typescript2": "^0.36.0",
"storybook": "^8.2.6",
"styled-components": "^6.1.12",
"styled-components": "^5.3.3",
"ts-jest": "^29.2.3",
"typescript": "^5.5.4"
},
"peerDependencies": {
"axios": "^1.7.2",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"styled-components": "^6.1.12"
"axios": ">=1.6.0",
"react": ">=18",
"react-dom": ">=18",
"styled-components": ">=5.3.3"
},
"packageManager": "pnpm@9.6.0"
}
Loading

0 comments on commit 2b4e142

Please sign in to comment.