-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.jac
More file actions
153 lines (141 loc) · 4.96 KB
/
main.jac
File metadata and controls
153 lines (141 loc) · 4.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
"""Main entry point for jac-shadcn."""
import from lib.export_service { build_jacpack, build_jacpack_from_config, load_registry, resolve_single_component, resolve_css_vars, generate_global_css, FONT_DATA }
import from http { HTTPMethod }
cl import from ".lib.design-system-provider" { DesignSystemProvider }
cl import from react { useEffect }
cl import ".global.css";
cl {
"""App shell — wraps all pages with DesignSystemProvider and initializes dark mode."""
def:pub app(children: Any = None) -> JsxElement {
useEffect(lambda -> Any {
document.documentElement.classList.add("dark");
document.body.classList.add("dark");
return;
}, []);
return <DesignSystemProvider>
<div className="flex min-h-screen flex-col">
{children}
</div>
</DesignSystemProvider>;
}
}
walker:pub export_theme {
has style: str = "nova";
has baseColor: str = "neutral";
has theme: str = "neutral";
has font: str = "figtree";
has radius: str = "default";
has menuAccent: str = "subtle";
has menuColor: str = "default";
has cssVars: dict = {};
can start with Root entry {
shadcn_config: dict = {
"style": self.style,
"baseColor": self.baseColor,
"theme": self.theme,
"font": self.font,
"radius": self.radius,
"menuAccent": self.menuAccent,
"menuColor": self.menuColor
};
jacpack = build_jacpack(shadcn_config, self.cssVars);
report jacpack;
}
}
"""GET /jacpack — returns themed jacpack JSON from query params.
Used for: jac create --use 'https://jac-shadcn.jaseci.org/jacpack?style=nova&theme=rose&font=inter' myapp
Note: jac-scale wraps in TransportResponse — extract .data.result for raw jacpack."""
@restspec(method=HTTPMethod.GET, path="/jacpack")
def:pub get_jacpack(
style: str = "nova",
baseColor: str = "neutral",
theme: str = "neutral",
font: str = "figtree",
radius: str = "default",
menuAccent: str = "subtle",
menuColor: str = "default"
) -> dict {
shadcn_config: dict = {
"style": style,
"baseColor": baseColor,
"theme": theme,
"font": font,
"radius": radius,
"menuAccent": menuAccent,
"menuColor": menuColor
};
return build_jacpack_from_config(shadcn_config);
}
"""GET /registry — returns the component manifest (list of all components + metadata)."""
@restspec(method=HTTPMethod.GET, path="/registry")
def:pub get_registry() -> dict {
return load_registry();
}
"""GET /theme — returns just the themed global.css and jac.toml config snippet.
Used for adding jac-shadcn to an existing project without scaffolding a full project.
Example: GET /theme?style=nova&baseColor=stone&theme=blue&font=outfit"""
@restspec(method=HTTPMethod.GET, path="/theme")
def:pub get_theme(
style: str = "nova",
baseColor: str = "neutral",
theme: str = "neutral",
font: str = "figtree",
radius: str = "default",
menuAccent: str = "subtle",
menuColor: str = "default"
) -> dict {
shadcn_config: dict = {
"style": style,
"baseColor": baseColor,
"theme": theme,
"font": font,
"radius": radius,
"menuAccent": menuAccent,
"menuColor": menuColor
};
css_vars = resolve_css_vars(shadcn_config);
global_css = generate_global_css(font, css_vars);
font_info = FONT_DATA.get(font, FONT_DATA["figtree"]);
# Include all component names so --init can install them
registry = load_registry();
default_components: list = sorted(list(registry.get("components", {}).keys()));
return {
"global_css": global_css,
"jac_shadcn_config": {
"style": style,
"baseColor": baseColor,
"theme": theme,
"font": font,
"radius": radius,
"menuAccent": menuAccent,
"menuColor": menuColor,
"registry": "https://jac-shadcn.jaseci.org"
},
"npm_deps": {
"clsx": "^2.1.1",
"tailwind-merge": "^3.5.0",
"tw-animate-css": "^1.4.0",
"class-variance-authority": "^0.7.1",
"radix-ui": "^1.4.3",
"@base-ui/react": "^1.2.0",
"shadcn": "^3.8.5",
font_info["npm"]: "*"
},
"npm_dev_deps": {
"@jac-client/dev-deps": "1.0.0",
"@tailwindcss/vite": "latest",
"tailwindcss": "latest"
},
"vite_config": {
"plugins": ["tailwindcss()"],
"lib_imports": ["import tailwindcss from '@tailwindcss/vite'"]
},
"default_components": default_components
};
}
"""GET /component/{name} — returns a single resolved component.
Used by: jac add --shadcn button"""
@restspec(method=HTTPMethod.GET, path="/component/{name}")
def:pub get_component(name: str, style: str = "nova") -> dict {
return resolve_single_component(name, style);
}