Skip to content

Commit faac925

Browse files
author
Cem Yılmaz
committed
Make value accessible in ast root
1 parent fe907be commit faac925

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

src/parse.test.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ it('should parse a functional class', () => {
77
"root": "bg",
88
"kind": "functional",
99
"property": "backgroundColor",
10-
"value": {
10+
"value": "#ef4444",
11+
"valueDef": {
1112
"value": "#ef4444",
1213
"kind": "color",
1314
"class": [
@@ -30,7 +31,8 @@ it("should parse a named/static class", () => {
3031
"root": "flex",
3132
"kind": "named",
3233
"property": "display",
33-
"value": {
34+
"value": "flex",
35+
"valueDef": {
3436
"class": [
3537
"display"
3638
],
@@ -52,7 +54,8 @@ it("should parse a functional class with arbitrary modifier", () => {
5254
"root": "bg",
5355
"kind": "functional",
5456
"property": "backgroundColor",
55-
"value": {
57+
"value": "#f9fafb",
58+
"valueDef": {
5659
"value": "#f9fafb",
5760
"kind": "color",
5861
"class": [
@@ -77,7 +80,8 @@ it("should parse a functional class with modifier", () => {
7780
"root": "bg",
7881
"kind": "functional",
7982
"property": "backgroundColor",
80-
"value": {
83+
"value": "#f9fafb",
84+
"valueDef": {
8185
"value": "#f9fafb",
8286
"kind": "color",
8387
"class": [
@@ -102,7 +106,8 @@ it("should parse a functional class with variants", () => {
102106
"root": "text",
103107
"kind": "functional",
104108
"property": "textColor",
105-
"value": {
109+
"value": "#ef4444",
110+
"valueDef": {
106111
"value": "#ef4444",
107112
"kind": "color",
108113
"class": [

src/parse.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ export type AST = {
1919
root: string
2020
kind: "named" | "functional"
2121
property: string
22-
value: Value
22+
value: string
23+
valueDef: Value
2324
variants: Variant[]
2425
modifier: Modifier | null,
2526
important: boolean
@@ -60,7 +61,8 @@ export const parse = (input: string, config?: CustomThemeConfig): AST => {
6061
root: base,
6162
kind: "named",
6263
property: namedPlugin!.ns,
63-
value: {
64+
value: namedPlugin.value,
65+
valueDef: {
6466
class: namedPlugin.class,
6567
raw: base,
6668
kind: "named",
@@ -94,7 +96,8 @@ export const parse = (input: string, config?: CustomThemeConfig): AST => {
9496
root: root,
9597
kind: "functional",
9698
property: associatedPluginByType!.ns,
97-
value: {
99+
value: arbitraryValue,
100+
valueDef:{
98101
value: arbitraryValue,
99102
class: associatedPluginByType!.class,
100103
raw: value,
@@ -140,11 +143,14 @@ export const parse = (input: string, config?: CustomThemeConfig): AST => {
140143
throw new PluginNotFoundException(base)
141144
}
142145

146+
const val = getValue(value, matchedPlugin, theme[matchedPlugin.scaleKey])
147+
143148
return {
144149
root: root,
145150
kind: "functional",
146151
property: matchedPlugin.ns,
147-
value: getValue(value, matchedPlugin, theme[matchedPlugin.scaleKey]),
152+
value: val.value,
153+
valueDef: val,
148154
variants: parsedCandidateVariants,
149155
modifier: modifier,
150156
important: state.important,

0 commit comments

Comments
 (0)