@ivy-interactive/ivy-design-system 1.1.16
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 +83 -0
- package/dist/csharp/IvyFrameworkChromaticTokens.cs +246 -0
- package/dist/csharp/IvyFrameworkDarkThemeTokens.cs +210 -0
- package/dist/csharp/IvyFrameworkLightThemeTokens.cs +210 -0
- package/dist/csharp/IvyFrameworkNeutralTokens.cs +166 -0
- package/dist/csharp/IvyFrameworkSourceTokens.cs +266 -0
- package/dist/csharp/IvyWebDarkThemeTokens.cs +206 -0
- package/dist/csharp/IvyWebLightThemeTokens.cs +206 -0
- package/dist/csharp/IvyWebSourceTokens.cs +210 -0
- package/dist/css/fonts.css +65 -0
- package/dist/css/ivy-framework-chromatic-flat.css +38 -0
- package/dist/css/ivy-framework-chromatic.css +38 -0
- package/dist/css/ivy-framework-dark-flat.css +29 -0
- package/dist/css/ivy-framework-dark.css +29 -0
- package/dist/css/ivy-framework-light.css +29 -0
- package/dist/css/ivy-framework-neutral-flat.css +18 -0
- package/dist/css/ivy-framework-neutral.css +18 -0
- package/dist/css/ivy-framework-source-flat.css +43 -0
- package/dist/css/ivy-framework-source.css +43 -0
- package/dist/css/ivy-web-dark-flat.css +28 -0
- package/dist/css/ivy-web-dark.css +28 -0
- package/dist/css/ivy-web-light.css +28 -0
- package/dist/css/ivy-web-source-flat.css +29 -0
- package/dist/css/ivy-web-source.css +29 -0
- package/dist/fonts/Geist/Geist-Bold.woff2 +0 -0
- package/dist/fonts/Geist/Geist-Medium.woff2 +0 -0
- package/dist/fonts/Geist/Geist-Regular.woff2 +0 -0
- package/dist/fonts/Geist/Geist-SemiBold.woff2 +0 -0
- package/dist/fonts/GeistMono/GeistMono-Bold.woff2 +0 -0
- package/dist/fonts/GeistMono/GeistMono-Medium.woff2 +0 -0
- package/dist/fonts/GeistMono/GeistMono-Regular.woff2 +0 -0
- package/dist/fonts/GeistMono/GeistMono-SemiBold.woff2 +0 -0
- package/dist/js/index.d.ts +55 -0
- package/dist/js/index.js +47 -0
- package/dist/tailwind/ivy-framework.js +47 -0
- package/dist/tokens/index.json +910 -0
- package/package.json +76 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Ivy Interactive
|
|
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,83 @@
|
|
|
1
|
+
# Ivy Design System
|
|
2
|
+
|
|
3
|
+
Color tokens for Ivy-Framework with light and dark theme support.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
**npm**
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install ivy-design-system
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
**.NET**
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
dotnet add package Ivy.DesignSystem
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
### CSS
|
|
22
|
+
|
|
23
|
+
```css
|
|
24
|
+
@import "ivy-design-system/css/ivy-framework";
|
|
25
|
+
@import "ivy-design-system/css/light";
|
|
26
|
+
|
|
27
|
+
.button {
|
|
28
|
+
background: var(--color-primary);
|
|
29
|
+
color: var(--color-primary-foreground);
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Tailwind
|
|
34
|
+
|
|
35
|
+
```javascript
|
|
36
|
+
import ivyTokens from "ivy-design-system/tailwind/ivy-framework";
|
|
37
|
+
|
|
38
|
+
export default {
|
|
39
|
+
...ivyTokens,
|
|
40
|
+
content: ["./src/**/*.{js,jsx,ts,tsx}"],
|
|
41
|
+
};
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### TypeScript
|
|
45
|
+
|
|
46
|
+
```typescript
|
|
47
|
+
import { tokens } from "ivy-design-system";
|
|
48
|
+
|
|
49
|
+
const primary = tokens["color-primary"];
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### C#
|
|
53
|
+
|
|
54
|
+
```csharp
|
|
55
|
+
using Ivy.Themes;
|
|
56
|
+
|
|
57
|
+
var primary = IvyFrameworkTokens.Color.Primary;
|
|
58
|
+
var background = LightThemeTokens.Color.Background;
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Tokens
|
|
62
|
+
|
|
63
|
+
- **Semantic**: primary, secondary, destructive, success, warning, info
|
|
64
|
+
- **UI**: background, foreground, border, input, ring, muted, accent, card, popover
|
|
65
|
+
- All tokens include foreground variants
|
|
66
|
+
- Light and dark theme support
|
|
67
|
+
|
|
68
|
+
Tokens are defined in `figma-tokens/$tokens.json` and exported to CSS, Tailwind, TypeScript, and C#.
|
|
69
|
+
|
|
70
|
+
## Development
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
npm install
|
|
74
|
+
npm run build
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Links
|
|
78
|
+
|
|
79
|
+
- [GitHub](https://github.com/Ivy-Interactive/Ivy-Design-System)
|
|
80
|
+
- [npm](https://www.npmjs.com/package/ivy-design-system)
|
|
81
|
+
- [NuGet](https://www.nuget.org/packages/Ivy.DesignSystem)
|
|
82
|
+
|
|
83
|
+
MIT © Ivy Interactive
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
//------------------------------------------------------------------------------
|
|
2
|
+
// <auto-generated>
|
|
3
|
+
// This code was generated by Ivy Design System build script.
|
|
4
|
+
// Changes to this file may cause incorrect behavior and will be lost if
|
|
5
|
+
// the code is regenerated.
|
|
6
|
+
// </auto-generated>
|
|
7
|
+
//------------------------------------------------------------------------------
|
|
8
|
+
|
|
9
|
+
#nullable enable
|
|
10
|
+
|
|
11
|
+
using System.Linq;
|
|
12
|
+
|
|
13
|
+
namespace Ivy.Themes
|
|
14
|
+
{
|
|
15
|
+
/// <summary>
|
|
16
|
+
/// Design System tokens generated from Ivy Design System
|
|
17
|
+
/// Provides compile-time access to all design tokens
|
|
18
|
+
/// </summary>
|
|
19
|
+
/// <remarks>
|
|
20
|
+
/// Generated on: 2025-12-27T21:08:13.587Z
|
|
21
|
+
/// Total tokens: 34
|
|
22
|
+
/// </remarks>
|
|
23
|
+
public static class IvyFrameworkChromaticTokens
|
|
24
|
+
{
|
|
25
|
+
|
|
26
|
+
/// <summary>
|
|
27
|
+
/// Design tokens for color
|
|
28
|
+
/// </summary>
|
|
29
|
+
public static class Color
|
|
30
|
+
{
|
|
31
|
+
/// <summary>red</summary>
|
|
32
|
+
public static readonly string Red = "#dd5860";
|
|
33
|
+
|
|
34
|
+
/// <summary>red-foreground</summary>
|
|
35
|
+
public static readonly string RedForeground = "#000000";
|
|
36
|
+
|
|
37
|
+
/// <summary>orange</summary>
|
|
38
|
+
public static readonly string Orange = "#dc824d";
|
|
39
|
+
|
|
40
|
+
/// <summary>orange-foreground</summary>
|
|
41
|
+
public static readonly string OrangeForeground = "#000000";
|
|
42
|
+
|
|
43
|
+
/// <summary>amber</summary>
|
|
44
|
+
public static readonly string Amber = "#deb145";
|
|
45
|
+
|
|
46
|
+
/// <summary>amber-foreground</summary>
|
|
47
|
+
public static readonly string AmberForeground = "#000000";
|
|
48
|
+
|
|
49
|
+
/// <summary>yellow</summary>
|
|
50
|
+
public static readonly string Yellow = "#e5e04c";
|
|
51
|
+
|
|
52
|
+
/// <summary>yellow-foreground</summary>
|
|
53
|
+
public static readonly string YellowForeground = "#000000";
|
|
54
|
+
|
|
55
|
+
/// <summary>lime</summary>
|
|
56
|
+
public static readonly string Lime = "#afd953";
|
|
57
|
+
|
|
58
|
+
/// <summary>lime-foreground</summary>
|
|
59
|
+
public static readonly string LimeForeground = "#000000";
|
|
60
|
+
|
|
61
|
+
/// <summary>green</summary>
|
|
62
|
+
public static readonly string Green = "#86d26f";
|
|
63
|
+
|
|
64
|
+
/// <summary>green-foreground</summary>
|
|
65
|
+
public static readonly string GreenForeground = "#000000";
|
|
66
|
+
|
|
67
|
+
/// <summary>emerald</summary>
|
|
68
|
+
public static readonly string Emerald = "#76cd94";
|
|
69
|
+
|
|
70
|
+
/// <summary>emerald-foreground</summary>
|
|
71
|
+
public static readonly string EmeraldForeground = "#000000";
|
|
72
|
+
|
|
73
|
+
/// <summary>teal</summary>
|
|
74
|
+
public static readonly string Teal = "#5b9ba8";
|
|
75
|
+
|
|
76
|
+
/// <summary>teal-foreground</summary>
|
|
77
|
+
public static readonly string TealForeground = "#ffffff";
|
|
78
|
+
|
|
79
|
+
/// <summary>cyan</summary>
|
|
80
|
+
public static readonly string Cyan = "#4469c0";
|
|
81
|
+
|
|
82
|
+
/// <summary>cyan-foreground</summary>
|
|
83
|
+
public static readonly string CyanForeground = "#ffffff";
|
|
84
|
+
|
|
85
|
+
/// <summary>sky</summary>
|
|
86
|
+
public static readonly string Sky = "#373bda";
|
|
87
|
+
|
|
88
|
+
/// <summary>sky-foreground</summary>
|
|
89
|
+
public static readonly string SkyForeground = "#ffffff";
|
|
90
|
+
|
|
91
|
+
/// <summary>blue</summary>
|
|
92
|
+
public static readonly string Blue = "#381ff4";
|
|
93
|
+
|
|
94
|
+
/// <summary>blue-foreground</summary>
|
|
95
|
+
public static readonly string BlueForeground = "#ffffff";
|
|
96
|
+
|
|
97
|
+
/// <summary>indigo</summary>
|
|
98
|
+
public static readonly string Indigo = "#4b28e2";
|
|
99
|
+
|
|
100
|
+
/// <summary>indigo-foreground</summary>
|
|
101
|
+
public static readonly string IndigoForeground = "#ffffff";
|
|
102
|
+
|
|
103
|
+
/// <summary>violet</summary>
|
|
104
|
+
public static readonly string Violet = "#6637d1";
|
|
105
|
+
|
|
106
|
+
/// <summary>violet-foreground</summary>
|
|
107
|
+
public static readonly string VioletForeground = "#ffffff";
|
|
108
|
+
|
|
109
|
+
/// <summary>purple</summary>
|
|
110
|
+
public static readonly string Purple = "#844cc0";
|
|
111
|
+
|
|
112
|
+
/// <summary>purple-foreground</summary>
|
|
113
|
+
public static readonly string PurpleForeground = "#ffffff";
|
|
114
|
+
|
|
115
|
+
/// <summary>fuchsia</summary>
|
|
116
|
+
public static readonly string Fuchsia = "#a361af";
|
|
117
|
+
|
|
118
|
+
/// <summary>fuchsia-foreground</summary>
|
|
119
|
+
public static readonly string FuchsiaForeground = "#000000";
|
|
120
|
+
|
|
121
|
+
/// <summary>pink</summary>
|
|
122
|
+
public static readonly string Pink = "#c377a0";
|
|
123
|
+
|
|
124
|
+
/// <summary>pink-foreground</summary>
|
|
125
|
+
public static readonly string PinkForeground = "#000000";
|
|
126
|
+
|
|
127
|
+
/// <summary>rose</summary>
|
|
128
|
+
public static readonly string Rose = "#e48e91";
|
|
129
|
+
|
|
130
|
+
/// <summary>rose-foreground</summary>
|
|
131
|
+
public static readonly string RoseForeground = "#000000";
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/// <summary>
|
|
135
|
+
/// Generates CSS custom properties for all design tokens
|
|
136
|
+
/// </summary>
|
|
137
|
+
/// <param name="selector">CSS selector (default: ":root")</param>
|
|
138
|
+
/// <returns>CSS string with all custom properties</returns>
|
|
139
|
+
public static string GenerateCSS(string selector = ":root")
|
|
140
|
+
{
|
|
141
|
+
var css = new System.Text.StringBuilder();
|
|
142
|
+
css.AppendLine($"{selector} {{");
|
|
143
|
+
|
|
144
|
+
// Color tokens
|
|
145
|
+
foreach (var field in typeof(Color).GetFields(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static))
|
|
146
|
+
{
|
|
147
|
+
if (field.FieldType == typeof(string))
|
|
148
|
+
{
|
|
149
|
+
var name = string.Concat(field.Name.Select((x, i) => i > 0 && char.IsUpper(x) ? "-" + x.ToString() : x.ToString())).ToLower();
|
|
150
|
+
var value = field.GetValue(null);
|
|
151
|
+
css.AppendLine($" --{name}: {value};");
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
css.AppendLine("}");
|
|
156
|
+
return css.ToString();
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/// <summary>
|
|
160
|
+
/// Gets a token value by its CSS variable name
|
|
161
|
+
/// </summary>
|
|
162
|
+
/// <param name="tokenName">Token name in kebab-case (e.g., "color-brand-primary")</param>
|
|
163
|
+
/// <returns>Token value or null if not found</returns>
|
|
164
|
+
public static string? GetToken(string tokenName)
|
|
165
|
+
{
|
|
166
|
+
var propertyName = string.Concat(tokenName.Split('-').Select(s =>
|
|
167
|
+
char.ToUpper(s[0]) + s.Substring(1)));
|
|
168
|
+
|
|
169
|
+
var category = tokenName.Split('-')[0];
|
|
170
|
+
var categoryClassName = char.ToUpper(category[0]) + category.Substring(1);
|
|
171
|
+
|
|
172
|
+
var type = typeof(IvyFrameworkChromaticTokens).GetNestedType(categoryClassName);
|
|
173
|
+
if (type == null) return null;
|
|
174
|
+
|
|
175
|
+
var field = type.GetField(propertyName, System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static);
|
|
176
|
+
return field?.GetValue(null) as string;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/// <summary>
|
|
180
|
+
/// Gets all token names
|
|
181
|
+
/// </summary>
|
|
182
|
+
/// <returns>Array of all token names in kebab-case</returns>
|
|
183
|
+
public static string[] GetAllTokenNames()
|
|
184
|
+
{
|
|
185
|
+
return new string[]
|
|
186
|
+
{
|
|
187
|
+
"red",
|
|
188
|
+
"red-foreground",
|
|
189
|
+
"orange",
|
|
190
|
+
"orange-foreground",
|
|
191
|
+
"amber",
|
|
192
|
+
"amber-foreground",
|
|
193
|
+
"yellow",
|
|
194
|
+
"yellow-foreground",
|
|
195
|
+
"lime",
|
|
196
|
+
"lime-foreground",
|
|
197
|
+
"green",
|
|
198
|
+
"green-foreground",
|
|
199
|
+
"emerald",
|
|
200
|
+
"emerald-foreground",
|
|
201
|
+
"teal",
|
|
202
|
+
"teal-foreground",
|
|
203
|
+
"cyan",
|
|
204
|
+
"cyan-foreground",
|
|
205
|
+
"sky",
|
|
206
|
+
"sky-foreground",
|
|
207
|
+
"blue",
|
|
208
|
+
"blue-foreground",
|
|
209
|
+
"indigo",
|
|
210
|
+
"indigo-foreground",
|
|
211
|
+
"violet",
|
|
212
|
+
"violet-foreground",
|
|
213
|
+
"purple",
|
|
214
|
+
"purple-foreground",
|
|
215
|
+
"fuchsia",
|
|
216
|
+
"fuchsia-foreground",
|
|
217
|
+
"pink",
|
|
218
|
+
"pink-foreground",
|
|
219
|
+
"rose",
|
|
220
|
+
"rose-foreground"
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/// <summary>
|
|
225
|
+
/// Gets all token values as a dictionary
|
|
226
|
+
/// </summary>
|
|
227
|
+
/// <returns>Dictionary of token name -> value</returns>
|
|
228
|
+
public static System.Collections.Generic.Dictionary<string, string> GetAllTokens()
|
|
229
|
+
{
|
|
230
|
+
var tokens = new System.Collections.Generic.Dictionary<string, string>();
|
|
231
|
+
|
|
232
|
+
// Color tokens
|
|
233
|
+
foreach (var field in typeof(Color).GetFields(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static))
|
|
234
|
+
{
|
|
235
|
+
if (field.FieldType == typeof(string))
|
|
236
|
+
{
|
|
237
|
+
var name = string.Concat(field.Name.Select((x, i) => i > 0 && char.IsUpper(x) ? "-" + x.ToString() : x.ToString())).ToLower();
|
|
238
|
+
var value = field.GetValue(null) as string;
|
|
239
|
+
if (value != null) tokens[name] = value;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
return tokens;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
//------------------------------------------------------------------------------
|
|
2
|
+
// <auto-generated>
|
|
3
|
+
// This code was generated by Ivy Design System build script.
|
|
4
|
+
// Changes to this file may cause incorrect behavior and will be lost if
|
|
5
|
+
// the code is regenerated.
|
|
6
|
+
// </auto-generated>
|
|
7
|
+
//------------------------------------------------------------------------------
|
|
8
|
+
|
|
9
|
+
#nullable enable
|
|
10
|
+
|
|
11
|
+
using System.Linq;
|
|
12
|
+
|
|
13
|
+
namespace Ivy.Themes
|
|
14
|
+
{
|
|
15
|
+
/// <summary>
|
|
16
|
+
/// Design System tokens generated from Ivy Design System
|
|
17
|
+
/// Provides compile-time access to all design tokens
|
|
18
|
+
/// </summary>
|
|
19
|
+
/// <remarks>
|
|
20
|
+
/// Generated on: 2025-12-27T21:08:13.588Z
|
|
21
|
+
/// Total tokens: 25
|
|
22
|
+
/// </remarks>
|
|
23
|
+
public static class IvyFrameworkDarkThemeTokens
|
|
24
|
+
{
|
|
25
|
+
|
|
26
|
+
/// <summary>
|
|
27
|
+
/// Design tokens for color
|
|
28
|
+
/// </summary>
|
|
29
|
+
public static class Color
|
|
30
|
+
{
|
|
31
|
+
/// <summary>primary</summary>
|
|
32
|
+
public static readonly string Primary = "#00cc92";
|
|
33
|
+
|
|
34
|
+
/// <summary>primary-foreground</summary>
|
|
35
|
+
public static readonly string PrimaryForeground = "#000000";
|
|
36
|
+
|
|
37
|
+
/// <summary>secondary</summary>
|
|
38
|
+
public static readonly string Secondary = "#26262b";
|
|
39
|
+
|
|
40
|
+
/// <summary>secondary-foreground</summary>
|
|
41
|
+
public static readonly string SecondaryForeground = "#f8f8f8";
|
|
42
|
+
|
|
43
|
+
/// <summary>destructive</summary>
|
|
44
|
+
public static readonly string Destructive = "#dd5860";
|
|
45
|
+
|
|
46
|
+
/// <summary>destructive-foreground</summary>
|
|
47
|
+
public static readonly string DestructiveForeground = "#f8f8f8";
|
|
48
|
+
|
|
49
|
+
/// <summary>success</summary>
|
|
50
|
+
public static readonly string Success = "#86d26f";
|
|
51
|
+
|
|
52
|
+
/// <summary>success-foreground</summary>
|
|
53
|
+
public static readonly string SuccessForeground = "#000000";
|
|
54
|
+
|
|
55
|
+
/// <summary>warning</summary>
|
|
56
|
+
public static readonly string Warning = "#deb145";
|
|
57
|
+
|
|
58
|
+
/// <summary>warning-foreground</summary>
|
|
59
|
+
public static readonly string WarningForeground = "#000000";
|
|
60
|
+
|
|
61
|
+
/// <summary>info</summary>
|
|
62
|
+
public static readonly string Info = "#4469c0";
|
|
63
|
+
|
|
64
|
+
/// <summary>info-foreground</summary>
|
|
65
|
+
public static readonly string InfoForeground = "#ffffff";
|
|
66
|
+
|
|
67
|
+
/// <summary>background</summary>
|
|
68
|
+
public static readonly string Background = "#000000";
|
|
69
|
+
|
|
70
|
+
/// <summary>foreground</summary>
|
|
71
|
+
public static readonly string Foreground = "#f8f8f8";
|
|
72
|
+
|
|
73
|
+
/// <summary>border</summary>
|
|
74
|
+
public static readonly string Border = "#262626";
|
|
75
|
+
|
|
76
|
+
/// <summary>input</summary>
|
|
77
|
+
public static readonly string Input = "#262626";
|
|
78
|
+
|
|
79
|
+
/// <summary>ring</summary>
|
|
80
|
+
public static readonly string Ring = "#777777";
|
|
81
|
+
|
|
82
|
+
/// <summary>muted</summary>
|
|
83
|
+
public static readonly string Muted = "#1a1a1a";
|
|
84
|
+
|
|
85
|
+
/// <summary>muted-foreground</summary>
|
|
86
|
+
public static readonly string MutedForeground = "#8f8f8f";
|
|
87
|
+
|
|
88
|
+
/// <summary>accent</summary>
|
|
89
|
+
public static readonly string Accent = "#1a1a1a";
|
|
90
|
+
|
|
91
|
+
/// <summary>accent-foreground</summary>
|
|
92
|
+
public static readonly string AccentForeground = "#f8f8f8";
|
|
93
|
+
|
|
94
|
+
/// <summary>card</summary>
|
|
95
|
+
public static readonly string Card = "#171717";
|
|
96
|
+
|
|
97
|
+
/// <summary>card-foreground</summary>
|
|
98
|
+
public static readonly string CardForeground = "#f8f8f8";
|
|
99
|
+
|
|
100
|
+
/// <summary>popover</summary>
|
|
101
|
+
public static readonly string Popover = "#000000";
|
|
102
|
+
|
|
103
|
+
/// <summary>popover-foreground</summary>
|
|
104
|
+
public static readonly string PopoverForeground = "#f8f8f8";
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/// <summary>
|
|
108
|
+
/// Generates CSS custom properties for all design tokens
|
|
109
|
+
/// </summary>
|
|
110
|
+
/// <param name="selector">CSS selector (default: ":root")</param>
|
|
111
|
+
/// <returns>CSS string with all custom properties</returns>
|
|
112
|
+
public static string GenerateCSS(string selector = ":root")
|
|
113
|
+
{
|
|
114
|
+
var css = new System.Text.StringBuilder();
|
|
115
|
+
css.AppendLine($"{selector} {{");
|
|
116
|
+
|
|
117
|
+
// Color tokens
|
|
118
|
+
foreach (var field in typeof(Color).GetFields(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static))
|
|
119
|
+
{
|
|
120
|
+
if (field.FieldType == typeof(string))
|
|
121
|
+
{
|
|
122
|
+
var name = string.Concat(field.Name.Select((x, i) => i > 0 && char.IsUpper(x) ? "-" + x.ToString() : x.ToString())).ToLower();
|
|
123
|
+
var value = field.GetValue(null);
|
|
124
|
+
css.AppendLine($" --{name}: {value};");
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
css.AppendLine("}");
|
|
129
|
+
return css.ToString();
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/// <summary>
|
|
133
|
+
/// Gets a token value by its CSS variable name
|
|
134
|
+
/// </summary>
|
|
135
|
+
/// <param name="tokenName">Token name in kebab-case (e.g., "color-brand-primary")</param>
|
|
136
|
+
/// <returns>Token value or null if not found</returns>
|
|
137
|
+
public static string? GetToken(string tokenName)
|
|
138
|
+
{
|
|
139
|
+
var propertyName = string.Concat(tokenName.Split('-').Select(s =>
|
|
140
|
+
char.ToUpper(s[0]) + s.Substring(1)));
|
|
141
|
+
|
|
142
|
+
var category = tokenName.Split('-')[0];
|
|
143
|
+
var categoryClassName = char.ToUpper(category[0]) + category.Substring(1);
|
|
144
|
+
|
|
145
|
+
var type = typeof(IvyFrameworkDarkThemeTokens).GetNestedType(categoryClassName);
|
|
146
|
+
if (type == null) return null;
|
|
147
|
+
|
|
148
|
+
var field = type.GetField(propertyName, System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static);
|
|
149
|
+
return field?.GetValue(null) as string;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/// <summary>
|
|
153
|
+
/// Gets all token names
|
|
154
|
+
/// </summary>
|
|
155
|
+
/// <returns>Array of all token names in kebab-case</returns>
|
|
156
|
+
public static string[] GetAllTokenNames()
|
|
157
|
+
{
|
|
158
|
+
return new string[]
|
|
159
|
+
{
|
|
160
|
+
"primary",
|
|
161
|
+
"primary-foreground",
|
|
162
|
+
"secondary",
|
|
163
|
+
"secondary-foreground",
|
|
164
|
+
"destructive",
|
|
165
|
+
"destructive-foreground",
|
|
166
|
+
"success",
|
|
167
|
+
"success-foreground",
|
|
168
|
+
"warning",
|
|
169
|
+
"warning-foreground",
|
|
170
|
+
"info",
|
|
171
|
+
"info-foreground",
|
|
172
|
+
"background",
|
|
173
|
+
"foreground",
|
|
174
|
+
"border",
|
|
175
|
+
"input",
|
|
176
|
+
"ring",
|
|
177
|
+
"muted",
|
|
178
|
+
"muted-foreground",
|
|
179
|
+
"accent",
|
|
180
|
+
"accent-foreground",
|
|
181
|
+
"card",
|
|
182
|
+
"card-foreground",
|
|
183
|
+
"popover",
|
|
184
|
+
"popover-foreground"
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/// <summary>
|
|
189
|
+
/// Gets all token values as a dictionary
|
|
190
|
+
/// </summary>
|
|
191
|
+
/// <returns>Dictionary of token name -> value</returns>
|
|
192
|
+
public static System.Collections.Generic.Dictionary<string, string> GetAllTokens()
|
|
193
|
+
{
|
|
194
|
+
var tokens = new System.Collections.Generic.Dictionary<string, string>();
|
|
195
|
+
|
|
196
|
+
// Color tokens
|
|
197
|
+
foreach (var field in typeof(Color).GetFields(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static))
|
|
198
|
+
{
|
|
199
|
+
if (field.FieldType == typeof(string))
|
|
200
|
+
{
|
|
201
|
+
var name = string.Concat(field.Name.Select((x, i) => i > 0 && char.IsUpper(x) ? "-" + x.ToString() : x.ToString())).ToLower();
|
|
202
|
+
var value = field.GetValue(null) as string;
|
|
203
|
+
if (value != null) tokens[name] = value;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
return tokens;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|