@recursica/mantine-adapter 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +121 -0
- package/package.json +55 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Border LLC
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# Recursica
|
|
2
|
+
|
|
3
|
+
This is the Recursica design system. More details can be found at [Recursica](https://recursica.com/).
|
|
4
|
+
|
|
5
|
+
## What is Recursica
|
|
6
|
+
|
|
7
|
+
### Variable parser
|
|
8
|
+
|
|
9
|
+
Recursica parses the variables from the JSON files exported by the design system.
|
|
10
|
+
All your files can be at the root of the project, or if you prefer, you can put them in a folder. You just need to specify the path to the files in the `recursica.json` file.
|
|
11
|
+
|
|
12
|
+
### Icon parser
|
|
13
|
+
|
|
14
|
+
Recursica parses `recursica-icons.json` file to get the icons names and their respective paths.
|
|
15
|
+
The output will be at `src/components/Icons/`
|
|
16
|
+
|
|
17
|
+
- `svg` folder with the svg icon files
|
|
18
|
+
- `icon_exports.ts` parses the svg files and exports them as React components
|
|
19
|
+
- `icon_resource_map.ts` maps the icon names to the React components
|
|
20
|
+
- `Icon.tsx` is the main component that renders the icon
|
|
21
|
+
|
|
22
|
+
The `svg` folder, `icon_exports.ts` and `icon_resource_map.ts` are auto-generated. You don't need to do anything with them.
|
|
23
|
+
For the `Icon.tsx` file, you can customize the `Icon` component to your needs, here's the default implementation:
|
|
24
|
+
|
|
25
|
+
```tsx
|
|
26
|
+
import type { RecursicaColors } from "../../recursica/RecursicaColorsType";
|
|
27
|
+
import { IconResourceMap } from "./icon_resource_map";
|
|
28
|
+
import { recursica } from "../../recursica/Recursica";
|
|
29
|
+
const DEFAULT_SIZE = 24;
|
|
30
|
+
|
|
31
|
+
export type IconImport = React.SVGProps<SVGSVGElement> & {
|
|
32
|
+
title?: string | undefined;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export type IconName = keyof typeof IconResourceMap;
|
|
36
|
+
export const IconNames = Object.keys(IconResourceMap);
|
|
37
|
+
|
|
38
|
+
export interface IconProps {
|
|
39
|
+
name: IconName;
|
|
40
|
+
/** Icon size @default 24 */
|
|
41
|
+
size?: 16 | 20 | 24 | 32 | 40 | 48 | "100%";
|
|
42
|
+
/** The title to apply to the icon. If not set, it inherits from the parent */
|
|
43
|
+
title?: string;
|
|
44
|
+
/** The color to apply to the icon. If not set, it inherits from the parent */
|
|
45
|
+
color?: RecursicaColors;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export const Icon = (props: IconProps) => {
|
|
49
|
+
const SvgComponent = IconResourceMap[props.name];
|
|
50
|
+
const colorStyles = {
|
|
51
|
+
fill: props.color ? recursica[props.color] : "currentColor",
|
|
52
|
+
color: props.color ? recursica[props.color] : "currentColor",
|
|
53
|
+
};
|
|
54
|
+
return (
|
|
55
|
+
<SvgComponent
|
|
56
|
+
width={props.size ?? DEFAULT_SIZE}
|
|
57
|
+
height={props.size ?? DEFAULT_SIZE}
|
|
58
|
+
title={props.title}
|
|
59
|
+
style={props.color ? colorStyles : undefined}
|
|
60
|
+
viewBox="0 0 24 24"
|
|
61
|
+
preserveAspectRatio="xMidYMid meet"
|
|
62
|
+
/>
|
|
63
|
+
);
|
|
64
|
+
};
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Theme generator
|
|
68
|
+
|
|
69
|
+
Recursica generates a vanilla extract theme based on the variables. Then creates a mantine theme from the vanilla extract theme.
|
|
70
|
+
Here's a list of the generated files:
|
|
71
|
+
|
|
72
|
+
- `RecursicaCymbiotikaTokens.ts` contains the basic tokens for the theme
|
|
73
|
+
- `RecursicaCymbiotikaContractTheme.css` contains the contract theme for the vanilla extract theme, these variables will switch automatically based on the selected theme
|
|
74
|
+
- `RecursicaColorsType.ts` exposes all the colors available coming from the design system
|
|
75
|
+
- `Recursica.ts` is the main file that exports the theme available variables.
|
|
76
|
+
- `RecursicaCymbiotikaMantineTheme.ts` is the mantine theme generated from the vanilla extract theme
|
|
77
|
+
- `RecursicaCymbiotikaThemes.css.ts` contains all the themes available, also exposes a `Themes` object that can be used to switch between themes
|
|
78
|
+
|
|
79
|
+
## How to use
|
|
80
|
+
|
|
81
|
+
Create a recursica.json file in the root of the project.
|
|
82
|
+
|
|
83
|
+
```
|
|
84
|
+
{
|
|
85
|
+
"$schema": "./recursica/schemas/config-schema.json",
|
|
86
|
+
"project": "Cymbiotika"
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
[!NOTE]
|
|
91
|
+
The `project` field must match the name of the project in the JSON files.
|
|
92
|
+
|
|
93
|
+
Modify your package.json to include the recursica command.
|
|
94
|
+
|
|
95
|
+
```
|
|
96
|
+
"scripts": {
|
|
97
|
+
"recursica": "tsx recursica/main.ts"
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Run the recursica command.
|
|
102
|
+
|
|
103
|
+
```
|
|
104
|
+
npm run recursica
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## How to change the adapter
|
|
108
|
+
|
|
109
|
+
The adapter is the script that converts the JSON files into a theme.
|
|
110
|
+
The current adapter is the Mantine adapter.
|
|
111
|
+
To change the adapter, you need to go to the [adapter folder](recursica/adapter) and modify the adapter to your needs.
|
|
112
|
+
In case you wanna create a new adapter you must export a function named `generateThemeFile` that will receive the following parameters:
|
|
113
|
+
|
|
114
|
+
```
|
|
115
|
+
interface GenerateThemeFileParams {
|
|
116
|
+
srcPath: string;
|
|
117
|
+
baseTokens: ThemeTokens;
|
|
118
|
+
themes: Themes;
|
|
119
|
+
project: string;
|
|
120
|
+
}
|
|
121
|
+
```
|
package/package.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@recursica/mantine-adapter",
|
|
3
|
+
"description": "Recursica Design Token Adapter - Convert design tokens to code",
|
|
4
|
+
"version": "0.9.1",
|
|
5
|
+
"private": false,
|
|
6
|
+
"homepage": "https://github.com/borderux/recursica#readme",
|
|
7
|
+
"author": "hi@borderux.com",
|
|
8
|
+
"bugs": {
|
|
9
|
+
"url": "https://github.com/borderux/recursica/issues"
|
|
10
|
+
},
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git+https://github.com/borderux/recursica.git"
|
|
14
|
+
},
|
|
15
|
+
"type": "module",
|
|
16
|
+
"main": "dist/index.js",
|
|
17
|
+
"types": "dist/index.d.ts",
|
|
18
|
+
"bin": {
|
|
19
|
+
"recursica": "dist/main.cjs"
|
|
20
|
+
},
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "rollup -c",
|
|
23
|
+
"dev": "rollup -c -w",
|
|
24
|
+
"clean": "rm -rf dist"
|
|
25
|
+
},
|
|
26
|
+
"keywords": [
|
|
27
|
+
"design-tokens",
|
|
28
|
+
"figma",
|
|
29
|
+
"recursica",
|
|
30
|
+
"theme",
|
|
31
|
+
"adapter"
|
|
32
|
+
],
|
|
33
|
+
"files": [
|
|
34
|
+
"dist/**/*",
|
|
35
|
+
"README.md"
|
|
36
|
+
],
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"@recursica/common": "*",
|
|
39
|
+
"typescript": "^5.0.0"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@recursica/schemas": "*",
|
|
43
|
+
"@rollup/plugin-commonjs": "^28.0.3",
|
|
44
|
+
"@rollup/plugin-json": "^6.1.0",
|
|
45
|
+
"@rollup/plugin-node-resolve": "^16.0.1",
|
|
46
|
+
"@rollup/plugin-terser": "^0.4.4",
|
|
47
|
+
"@rollup/plugin-typescript": "^12.1.2",
|
|
48
|
+
"@types/node": "^20.0.0",
|
|
49
|
+
"rollup": "^4.42.0"
|
|
50
|
+
},
|
|
51
|
+
"engines": {
|
|
52
|
+
"node": ">=16.0.0"
|
|
53
|
+
},
|
|
54
|
+
"license": "MIT"
|
|
55
|
+
}
|