ranranrunforit commited on
Commit
e05e1db
·
verified ·
1 Parent(s): 9b99d45

Upload 33 files

Browse files
ui_kits/chan-compass/app.jsx CHANGED
@@ -6,15 +6,23 @@ const { useState: useS, useEffect: useE } = React;
6
  function _pascalG(name) {
7
  return String(name).split(/[-_]/).map(s=>s.charAt(0).toUpperCase()+s.slice(1)).join("");
8
  }
 
 
 
 
 
 
 
 
9
  function _glyphSvg(name, size, color) {
10
  const L = window.lucide;
11
  if (!L || !L.icons) return "";
12
  const node = L.icons[_pascalG(name)] || L.icons[name];
13
- if (!node) return "";
14
- const children = Array.isArray(node) ? node : (node.tags || node[2] || []);
15
- const inner = (children || []).map(([tag, attrs]) => {
16
- const a = Object.entries(attrs||{}).map(([k,v])=>`${k}="${v}"`).join(" ");
17
- return `<${tag} ${a}/>`;
18
  }).join("");
19
  return `<svg xmlns="http://www.w3.org/2000/svg" width="${size}" height="${size}" `
20
  + `viewBox="0 0 24 24" fill="none" stroke="${color||'currentColor'}" `
 
6
  function _pascalG(name) {
7
  return String(name).split(/[-_]/).map(s=>s.charAt(0).toUpperCase()+s.slice(1)).join("");
8
  }
9
+ function _glyphChildren(node) {
10
+ if (!node) return [];
11
+ if (Array.isArray(node)) {
12
+ if (node.length === 3 && Array.isArray(node[2])) return node[2];
13
+ return node;
14
+ }
15
+ return node.tags || node.children || [];
16
+ }
17
  function _glyphSvg(name, size, color) {
18
  const L = window.lucide;
19
  if (!L || !L.icons) return "";
20
  const node = L.icons[_pascalG(name)] || L.icons[name];
21
+ const children = _glyphChildren(node);
22
+ const inner = (children || []).map((ch) => {
23
+ const tag = ch[0], attrs = ch[1] || {};
24
+ const a = Object.entries(attrs).map(([k,v])=>`${k}="${v}"`).join(" ");
25
+ return `<${tag} ${a}></${tag}>`;
26
  }).join("");
27
  return `<svg xmlns="http://www.w3.org/2000/svg" width="${size}" height="${size}" `
28
  + `viewBox="0 0 24 24" fill="none" stroke="${color||'currentColor'}" `
ui_kits/chan-compass/index.html CHANGED
@@ -20,9 +20,5 @@
20
  <script src="/md.js"></script>
21
  <script type="text/babel" src="/views.jsx"></script>
22
  <script type="text/babel" src="/app.jsx"></script>
23
- <script>
24
- // Re-render lucide icons after Babel mounts everything.
25
- window.addEventListener('load', () => setTimeout(() => window.lucide && window.lucide.createIcons(), 400));
26
- </script>
27
  </body>
28
  </html>
 
20
  <script src="/md.js"></script>
21
  <script type="text/babel" src="/views.jsx"></script>
22
  <script type="text/babel" src="/app.jsx"></script>
 
 
 
 
23
  </body>
24
  </html>
ui_kits/chan-compass/views.jsx CHANGED
@@ -9,16 +9,24 @@ const API = window.CCApi;
9
  function _pascal(name) {
10
  return String(name).split(/[-_]/).map(s=>s.charAt(0).toUpperCase()+s.slice(1)).join("");
11
  }
 
 
 
 
 
 
 
 
 
12
  function _lucideSvg(name, size, color) {
13
  const L = window.lucide;
14
  if (!L || !L.icons) return "";
15
  const node = L.icons[_pascal(name)] || L.icons[name];
16
- if (!node) return "";
17
- // lucide icon data is an array of [tag, attrs] children
18
- const children = Array.isArray(node) ? node : (node.tags || node[2] || []);
19
- const inner = (children || []).map(([tag, attrs]) => {
20
- const a = Object.entries(attrs||{}).map(([k,v])=>`${k}="${v}"`).join(" ");
21
- return `<${tag} ${a}/>`;
22
  }).join("");
23
  return `<svg xmlns="http://www.w3.org/2000/svg" width="${size}" height="${size}" `
24
  + `viewBox="0 0 24 24" fill="none" stroke="${color||'currentColor'}" `
 
9
  function _pascal(name) {
10
  return String(name).split(/[-_]/).map(s=>s.charAt(0).toUpperCase()+s.slice(1)).join("");
11
  }
12
+ function _lucideChildren(node) {
13
+ if (!node) return [];
14
+ if (Array.isArray(node)) {
15
+ // could be [ [tag,attrs], ... ] OR ["svg", attrs, [ [tag,attrs],... ]]
16
+ if (node.length === 3 && Array.isArray(node[2])) return node[2];
17
+ return node;
18
+ }
19
+ return node.tags || node.children || [];
20
+ }
21
  function _lucideSvg(name, size, color) {
22
  const L = window.lucide;
23
  if (!L || !L.icons) return "";
24
  const node = L.icons[_pascal(name)] || L.icons[name];
25
+ const children = _lucideChildren(node);
26
+ const inner = (children || []).map((ch) => {
27
+ const tag = ch[0], attrs = ch[1] || {};
28
+ const a = Object.entries(attrs).map(([k,v])=>`${k}="${v}"`).join(" ");
29
+ return `<${tag} ${a}></${tag}>`;
 
30
  }).join("");
31
  return `<svg xmlns="http://www.w3.org/2000/svg" width="${size}" height="${size}" `
32
  + `viewBox="0 0 24 24" fill="none" stroke="${color||'currentColor'}" `