Skip to content

Commit a7dcd03

Browse files
authored
v7: rebuild with typescript for typescript (#45)
1 parent 34c9934 commit a7dcd03

File tree

102 files changed

+12467
-3141
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+12467
-3141
lines changed

.github/workflows/build.yml

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,34 @@
11
name: Build
22

3-
on: [push, pull_request]
3+
on:
4+
pull_request:
5+
branches: [main]
6+
push:
7+
branches: [main]
48

59
jobs:
6-
build:
10+
test:
711
runs-on: ubuntu-latest
812

9-
strategy:
10-
matrix:
11-
node-version:
12-
- 14.x
13-
- 16.x
14-
1513
steps:
16-
- uses: actions/checkout@v1
17-
- name: Use Node.js ${{ matrix.node-version }}
18-
uses: actions/setup-node@v1
14+
- uses: actions/checkout@v4
15+
16+
- name: Use Node.js
17+
uses: actions/setup-node@v4
18+
with:
19+
node-version-file: "package.json"
20+
cache: "npm"
21+
22+
- name: Handle Next.js Cache
23+
uses: actions/cache@v4
1924
with:
20-
node-version: ${{ matrix.node-version }}
21-
- name: Install
22-
run: |
23-
yarn install \
24-
--non-interactive \
25-
--frozen-lockfile
25+
path: .next/cache
26+
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }}
27+
restore-keys: |
28+
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-
29+
30+
- name: Install dependencies
31+
run: npm ci
32+
2633
- name: Test
27-
run: yarn test
28-
env:
29-
CI: true
34+
run: npm run test

.gitignore

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,6 @@
33

44
# node
55
node_modules
6-
# npm unused lock file (we use yarn.lock)
7-
package-lock.json
86

9-
# ocaml/reason build artifacts
10-
.bsb.lock
11-
**/lib/bs
12-
**/lib/ocaml
13-
**/.merlin
14-
*.bs.js
15-
16-
# webpack build
7+
# build
178
dist

.husky/pre-push

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
npm test

README.md

Lines changed: 12 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,17 @@
88
[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/MoOx/react-from-svg/build.yml?branch=main)](https://github.com/MoOx/react-from-svg/actions)
99
[![License](https://img.shields.io/github/license/MoOx/react-from-svg)](https://github.com/MoOx/react-from-svg)
1010
[![GitHub followers](https://img.shields.io/github/followers/MoOx?style=social&label=Follow%20me)](https://github.com/MoOx)
11-
[![Twitter Follow](https://img.shields.io/twitter/follow/MoOx?style=social&label=Follow%20me)](https://twitter.com/MoOx)
12-
[![Sponsor my work](https://github.com/moox/.github/raw/main/FUNDING-button.svg)](https://github.com/MoOx/react-from-svg?sponsor=1)
11+
[![LinkedIn Follow](https://img.shields.io/badge/Follow%20Me-on%20LinkedIn-gray?style=social&logo=invision&logoColor=%230077B5)](https://www.linkedin.com/in/maxthirouin/)
12+
[![BlueSky Follow](https://img.shields.io/badge/Follow%20Me-on%20BlueSky-gray?style=social&logo=bluesky)](https://bsky.app/profile/moox.io)
13+
[![X Follow](https://img.shields.io/twitter/follow/MoOx?style=social&label=Follow%20me)](https://x.com/MoOx)
1314

14-
> Transform SVG files into React components, Native and/or Web, JavaScript and
15-
> rescriptML. Without shitload of dependencies.
15+
> Transform SVG files into React components, Native and/or Web, JavaScript and/or TypeScript.
16+
> Without minimal dependencies.
1617
1718
## Install
1819

1920
```console
2021
npm install react-from-svg
21-
22-
# or
23-
24-
yarn add react-from-svg
2522
```
2623

2724
## Usage
@@ -35,59 +32,40 @@ Usage
3532
Options
3633
--with-native, -rn Output code for react-native-svg
3734
--with-native-for-typescript, -rnts Output code for react-native-svg with TypeScript
38-
3935
--with-web, -rnw Output code for DOM. If --with-native is also used, will be output as .web.js files
40-
--with-native-for-rescript, -rrn Output code for @rescript-react-native/svg
41-
--with-web-for-rescript, -rrnw Output code for @rescript/react
36+
--with-web-for-typescript, -rnwts Output code for DOM with TypeScript. If --with-native is also used, will be output as .web.tsx files
4237
--remove-fill, -rf Remove all 'fill' properties from SVGs, convenient for icons
4338
--remove-stroke, -rs Remove all 'stroke' properties from SVGs, convenient for icons
44-
--commonjs, -cjs Export as commonjs instead of es6 import/export
4539

4640
Example
4741
$ react-from-svg assets/svgs src/Svgs --with-native --remove-fill
4842
```
4943

50-
Generated components will have the following props that you can inject to the
51-
SVG components:
44+
Generated components will allow you to inject all the props you could use on an `<svg>`/`<Svg>`, such as:
5245

5346
- `width`
5447
- `height`
5548
- `fill` (if you use `--remove-fill`)
5649
- `stroke` (if you use `--remove-stroke`)
50+
- `style`
5751

58-
⚠️ To see what you can expect from the transformations,
59-
[check our snapshots](./__tests__/__snapshots__) 👀
52+
⚠️ To see what you can expect from the transformations, [check our snapshots](./tests/) 👀
6053

6154
## Requirements
6255

63-
### `--with-web`
56+
### `--with-web(-*)`
6457

6558
Need you to have:
6659

6760
- [React](https://reactjs.org)
6861

69-
### `--with-web-for-rescript`
62+
Note: if you use [React Native for Web](https://github.com/necolas/react-native-web), see requirements below.
7063

71-
Need you to have:
72-
73-
- [React](https://reactjs.org)
74-
- [`rescript-react`](https://rescriptml.github.io/rescript-react/)
75-
76-
### `--with-native`
64+
### `--with-native(-*)`
7765

7866
Need you to have:
7967

8068
- [React](https://reactjs.org)
8169
- [React Native](https://reactnative.dev) (or an alternative platform like
8270
[React Native Web](https://github.com/necolas/react-native-web))
8371
- [`react-native-svg`](https://github.com/react-native-community/react-native-svg)
84-
85-
### `--with-native-for-rescript`
86-
87-
In addition to `--with-native` requirements, you need to have:
88-
89-
- [`@rescript/react`](https://rescript-lang.org/docs/react/latest/introduction)
90-
- [`rescript-react-native`](https://rescript-react-native.github.io)
91-
- [`@rescript-react-native/svg`](https://github.com/rescript-react-native/svg)
92-
93-
Ensure as that this dependencies are in the `bs-dependencies` of your `bsconfig.json`.

__tests__/TransformNative.res

Lines changed: 0 additions & 48 deletions
This file was deleted.

__tests__/TransformNativeForReScript.res

Lines changed: 0 additions & 55 deletions
This file was deleted.

__tests__/TransformNativeForTypescript.res

Lines changed: 0 additions & 48 deletions
This file was deleted.

__tests__/TransformWeb.res

Lines changed: 0 additions & 48 deletions
This file was deleted.

0 commit comments

Comments
 (0)