graphen 2.0.7 → 2.0.8

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/src/example.tsx CHANGED
@@ -2,20 +2,35 @@
2
2
  import React, { useEffect, useMemo, useState } from "react";
3
3
  import { render } from "react-dom";
4
4
  import {
5
+ Accordion,
5
6
  Badge,
6
7
  Button,
7
8
  Card,
8
9
  CoverEmpty,
9
10
  Dialog,
10
11
  Dropdown,
12
+ Flex,
13
+ FlexItem,
11
14
  Icons,
12
15
  Input,
16
+ Joystick,
13
17
  Link,
18
+ Loader,
14
19
  Logo,
20
+ Navigation,
21
+ NavigationOption,
22
+ Panel,
23
+ PanelContent,
24
+ PanelFooter,
25
+ PanelTitle,
26
+ Scroller,
15
27
  SegmentedControl,
16
28
  Separator,
29
+ Skeleton,
17
30
  Stat,
18
31
  Switch,
32
+ Tooltip,
33
+ Validation,
19
34
  constants,
20
35
  } from "./index";
21
36
 
@@ -198,6 +213,19 @@ const NAV = [
198
213
  { id: "stat", label: "Stat" },
199
214
  { id: "cover-empty", label: "Cover empty" },
200
215
  { id: "switch", label: "Switch" },
216
+ { id: "panel", label: "Panel" },
217
+ { id: "accordion", label: "Accordion" },
218
+ { id: "flex", label: "Flex" },
219
+ { id: "loader", label: "Loader" },
220
+ { id: "skeleton", label: "Skeleton" },
221
+ { id: "tooltip", label: "Tooltip" },
222
+ { id: "validation", label: "Validation" },
223
+ { id: "alert", label: "Alert" },
224
+ { id: "list", label: "List" },
225
+ { id: "textarea", label: "Textarea" },
226
+ { id: "led", label: "LED" },
227
+ { id: "joystick", label: "Joystick" },
228
+ { id: "scroller", label: "Scroller" },
201
229
  ],
202
230
  },
203
231
  ];
@@ -224,6 +252,19 @@ const TOC = [
224
252
  ["stat", "Stat"],
225
253
  ["cover-empty", "Cover empty"],
226
254
  ["switch", "Switch"],
255
+ ["panel", "Panel"],
256
+ ["accordion", "Accordion"],
257
+ ["flex", "Flex"],
258
+ ["loader", "Loader"],
259
+ ["skeleton", "Skeleton"],
260
+ ["tooltip", "Tooltip"],
261
+ ["validation", "Validation"],
262
+ ["alert", "Alert"],
263
+ ["list", "List"],
264
+ ["textarea", "Textarea"],
265
+ ["led", "LED"],
266
+ ["joystick", "Joystick"],
267
+ ["scroller", "Scroller"],
227
268
  ] as const;
228
269
 
229
270
  type IconProps = {
@@ -277,6 +318,39 @@ function CopyButton({
277
318
  );
278
319
  }
279
320
 
321
+ function JoystickDemo() {
322
+ const [position, setPosition] = useState({ left: 0, top: 0 });
323
+ return (
324
+ <>
325
+ <Joystick
326
+ isEnabled
327
+ onPositionChange={(left, top) =>
328
+ setPosition({ left: Math.round(left), top: Math.round(top) })
329
+ }
330
+ />
331
+ <span className="docs-demo-value">
332
+ left: {position.left} / top: {position.top}
333
+ </span>
334
+ </>
335
+ );
336
+ }
337
+
338
+ function ScrollerDemo() {
339
+ const [scrollValue, setScrollValue] = useState(0);
340
+ return (
341
+ <>
342
+ <div className="docs-scroller-track">
343
+ <Scroller
344
+ min={0}
345
+ max={100}
346
+ onScrollChange={(value) => setScrollValue(Math.round(value))}
347
+ />
348
+ </div>
349
+ <span className="docs-demo-value">value: {scrollValue}</span>
350
+ </>
351
+ );
352
+ }
353
+
280
354
  type DemoProps = {
281
355
  code: React.ReactNode;
282
356
  stageClass?: string;
@@ -1085,60 +1159,36 @@ function App() {
1085
1159
  <h2 className="docs-section-title">Navigation</h2>
1086
1160
  <p className="docs-section-desc">
1087
1161
  Horizontal navigation for top-of-page links. The active option is
1088
- underlined with the brand color; hover an option that owns a
1089
- submenu to reveal it.
1162
+ underlined with the brand color; click an option that owns a
1163
+ submenu to open it.
1090
1164
  </p>
1091
1165
  <Demo
1092
1166
  stageClass="column"
1093
- code={`<ul className="gc-navigation gc-navigation--default">
1094
- <li className="gc-navigation__option gc-navigation__option--active">
1095
- <a className="gc-navigation__link" href="#">Overview</a>
1096
- </li>
1097
- <li className="gc-navigation__option">
1098
- <a className="gc-navigation__link" href="#">Components</a>
1099
- <div className="gc-submenu">
1100
- <div className="gc-submenu__content">
1101
- <a className="gc-submenu__item" href="#">Button</a>
1102
- <a className="gc-submenu__item" href="#">Card</a>
1103
- <a className="gc-submenu__item" href="#">Dialog</a>
1104
- </div>
1105
- </div>
1106
- </li>
1107
- <li className="gc-navigation__option">
1108
- <a className="gc-navigation__link" href="#">Resources</a>
1109
- </li>
1110
- </ul>`}
1167
+ code={`<Navigation>
1168
+ <NavigationOption label="Overview" href="#" isActive />
1169
+ <NavigationOption label="Components">
1170
+ <a className="gc-submenu__item" href="#">Button</a>
1171
+ <a className="gc-submenu__item" href="#">Card</a>
1172
+ <a className="gc-submenu__item" href="#">Dialog</a>
1173
+ </NavigationOption>
1174
+ <NavigationOption label="Resources" href="#" />
1175
+ </Navigation>`}
1111
1176
  >
1112
- <ul className="gc-navigation gc-navigation--default">
1113
- <li className="gc-navigation__option gc-navigation__option--active">
1114
- <a className="gc-navigation__link" href="#">
1115
- Overview
1177
+ <Navigation>
1178
+ <NavigationOption label="Overview" href="#" isActive />
1179
+ <NavigationOption label="Components">
1180
+ <a className="gc-submenu__item" href="#">
1181
+ Button
1116
1182
  </a>
1117
- </li>
1118
- <li className="gc-navigation__option">
1119
- <a className="gc-navigation__link" href="#">
1120
- Components
1183
+ <a className="gc-submenu__item" href="#">
1184
+ Card
1121
1185
  </a>
1122
- <div className="gc-submenu">
1123
- <div className="gc-submenu__content">
1124
- <a className="gc-submenu__item" href="#">
1125
- Button
1126
- </a>
1127
- <a className="gc-submenu__item" href="#">
1128
- Card
1129
- </a>
1130
- <a className="gc-submenu__item" href="#">
1131
- Dialog
1132
- </a>
1133
- </div>
1134
- </div>
1135
- </li>
1136
- <li className="gc-navigation__option">
1137
- <a className="gc-navigation__link" href="#">
1138
- Resources
1186
+ <a className="gc-submenu__item" href="#">
1187
+ Dialog
1139
1188
  </a>
1140
- </li>
1141
- </ul>
1189
+ </NavigationOption>
1190
+ <NavigationOption label="Resources" href="#" />
1191
+ </Navigation>
1142
1192
  </Demo>
1143
1193
  </section>
1144
1194
 
@@ -1237,6 +1287,306 @@ function App() {
1237
1287
  </Demo>
1238
1288
  </section>
1239
1289
 
1290
+ <section className="docs-section" id="panel">
1291
+ <div className="docs-section-eyebrow">Components / 16</div>
1292
+ <h2 className="docs-section-title">Panel</h2>
1293
+ <p className="docs-section-desc">
1294
+ A composable surface for grouping related content. Combine{" "}
1295
+ <code>PanelTitle</code>, <code>PanelContent</code> and{" "}
1296
+ <code>PanelFooter</code>; <code>isBordered</code> outlines the
1297
+ panel and <code>isSeparator</code> draws dividers between the
1298
+ parts.
1299
+ </p>
1300
+ <Demo
1301
+ stageClass="column"
1302
+ code={`<Panel isBordered>
1303
+ <PanelTitle>Billing</PanelTitle>
1304
+ <PanelContent>Invoices are issued on the first day of each month.</PanelContent>
1305
+ <PanelFooter>Last updated today</PanelFooter>
1306
+ </Panel>
1307
+ <Panel isSeparator>
1308
+ <PanelTitle>Notifications</PanelTitle>
1309
+ <PanelContent>Choose how you want to be notified about activity.</PanelContent>
1310
+ </Panel>`}
1311
+ >
1312
+ <Panel isBordered>
1313
+ <PanelTitle>Billing</PanelTitle>
1314
+ <PanelContent>
1315
+ Invoices are issued on the first day of each month.
1316
+ </PanelContent>
1317
+ <PanelFooter>Last updated today</PanelFooter>
1318
+ </Panel>
1319
+ <Panel isSeparator>
1320
+ <PanelTitle>Notifications</PanelTitle>
1321
+ <PanelContent>
1322
+ Choose how you want to be notified about activity.
1323
+ </PanelContent>
1324
+ </Panel>
1325
+ </Demo>
1326
+ </section>
1327
+
1328
+ <section className="docs-section" id="accordion">
1329
+ <div className="docs-section-eyebrow">Components / 17</div>
1330
+ <h2 className="docs-section-title">Accordion</h2>
1331
+ <p className="docs-section-desc">
1332
+ A collapsible panel for secondary content. It starts collapsed by
1333
+ default — click the title to expand it.
1334
+ </p>
1335
+ <Demo
1336
+ stageClass="column"
1337
+ code={`<Accordion title="Shipping details">
1338
+ Orders placed before noon ship the same day. Tracking is emailed
1339
+ once the parcel leaves the warehouse.
1340
+ </Accordion>`}
1341
+ >
1342
+ <Accordion title="Shipping details">
1343
+ Orders placed before noon ship the same day. Tracking is emailed
1344
+ once the parcel leaves the warehouse.
1345
+ </Accordion>
1346
+ </Demo>
1347
+ </section>
1348
+
1349
+ <section className="docs-section" id="flex">
1350
+ <div className="docs-section-eyebrow">Components / 18</div>
1351
+ <h2 className="docs-section-title">Flex</h2>
1352
+ <p className="docs-section-desc">
1353
+ A thin flexbox wrapper. <code>FlexItem</code> children opt into
1354
+ growing or shrinking; <code>isVertical</code> stacks them as a
1355
+ column.
1356
+ </p>
1357
+ <Demo
1358
+ stageClass="column"
1359
+ code={`<Flex>
1360
+ <FlexItem>aside</FlexItem>
1361
+ <FlexItem isGrow>main content</FlexItem>
1362
+ <FlexItem>aside</FlexItem>
1363
+ </Flex>
1364
+ <Flex isVertical>
1365
+ <FlexItem>row one</FlexItem>
1366
+ <FlexItem>row two</FlexItem>
1367
+ </Flex>`}
1368
+ >
1369
+ <Flex className="docs-flex-demo">
1370
+ <FlexItem className="docs-flex-box">aside</FlexItem>
1371
+ <FlexItem className="docs-flex-box" isGrow>
1372
+ main content
1373
+ </FlexItem>
1374
+ <FlexItem className="docs-flex-box">aside</FlexItem>
1375
+ </Flex>
1376
+ <Flex isVertical>
1377
+ <FlexItem className="docs-flex-box">row one</FlexItem>
1378
+ <FlexItem className="docs-flex-box">row two</FlexItem>
1379
+ </Flex>
1380
+ </Demo>
1381
+ </section>
1382
+
1383
+ <section className="docs-section" id="loader">
1384
+ <div className="docs-section-eyebrow">Components / 19</div>
1385
+ <h2 className="docs-section-title">Loader</h2>
1386
+ <p className="docs-section-desc">
1387
+ An indeterminate spinner for blocking waits. The ring mixes white
1388
+ and gray strokes, so it reads best on dark or tinted surfaces.
1389
+ </p>
1390
+ <Demo stageClass="center" code="<Loader />">
1391
+ <div className="docs-loader-stage">
1392
+ <Loader />
1393
+ </div>
1394
+ </Demo>
1395
+ </section>
1396
+
1397
+ <section className="docs-section" id="skeleton">
1398
+ <div className="docs-section-eyebrow">Components / 20</div>
1399
+ <h2 className="docs-section-title">Skeleton</h2>
1400
+ <p className="docs-section-desc">
1401
+ A shimmering placeholder line for content that is still loading.
1402
+ Compose several with varying widths to sketch the final layout.
1403
+ </p>
1404
+ <Demo
1405
+ stageClass="column"
1406
+ code={`<Skeleton />
1407
+ <Skeleton />
1408
+ <Skeleton />`}
1409
+ >
1410
+ <div className="docs-skeleton-demo">
1411
+ <Skeleton />
1412
+ <Skeleton />
1413
+ <Skeleton />
1414
+ </div>
1415
+ </Demo>
1416
+ </section>
1417
+
1418
+ <section className="docs-section" id="tooltip">
1419
+ <div className="docs-section-eyebrow">Components / 21</div>
1420
+ <h2 className="docs-section-title">Tooltip</h2>
1421
+ <p className="docs-section-desc">
1422
+ A small anchored bubble for contextual feedback. It positions
1423
+ absolutely against the nearest positioned ancestor; the{" "}
1424
+ <code>type</code> prop keys the color to the semantic palette.
1425
+ </p>
1426
+ <Demo
1427
+ code={`<Tooltip type="success">Saved successfully</Tooltip>
1428
+ <Tooltip type="danger">Something went wrong</Tooltip>`}
1429
+ >
1430
+ <div className="docs-tooltip-anchor">
1431
+ <Tooltip type="success">Saved successfully</Tooltip>
1432
+ </div>
1433
+ <div className="docs-tooltip-anchor">
1434
+ <Tooltip type="danger">Something went wrong</Tooltip>
1435
+ </div>
1436
+ </Demo>
1437
+ </section>
1438
+
1439
+ <section className="docs-section" id="validation">
1440
+ <div className="docs-section-eyebrow">Components / 22</div>
1441
+ <h2 className="docs-section-title">Validation</h2>
1442
+ <p className="docs-section-desc">
1443
+ Wraps a form control and reveals a tooltip with the validation
1444
+ message on hover. Hover the inputs below to see it.
1445
+ </p>
1446
+ <Demo
1447
+ stageClass="column"
1448
+ code={`<Validation type="danger" message="Email is required">
1449
+ <Input label="Email" type="email" validation="danger" />
1450
+ </Validation>
1451
+ <Validation type="success" message="Looks good">
1452
+ <Input label="Username" type="text" validation="success" />
1453
+ </Validation>`}
1454
+ >
1455
+ <Validation type="danger" message="Email is required">
1456
+ <Input label="Email" type="email" validation="danger" />
1457
+ </Validation>
1458
+ <Validation type="success" message="Looks good">
1459
+ <Input label="Username" type="text" validation="success" />
1460
+ </Validation>
1461
+ </Demo>
1462
+ </section>
1463
+
1464
+ <section className="docs-section" id="alert">
1465
+ <div className="docs-section-eyebrow">Components / 23</div>
1466
+ <h2 className="docs-section-title">Alert</h2>
1467
+ <p className="docs-section-desc">
1468
+ A bordered message box for inline page-level feedback. Styles-only
1469
+ primitive — apply the classes to your own markup.
1470
+ </p>
1471
+ <Demo
1472
+ stageClass="column"
1473
+ code={`<div className="gc-alert gc-alert--info">A new version is available.</div>
1474
+ <div className="gc-alert gc-alert--success">Settings saved.</div>
1475
+ <div className="gc-alert gc-alert--danger">Could not reach the server.</div>`}
1476
+ >
1477
+ <div className="gc-alert gc-alert--info">
1478
+ A new version is available.
1479
+ </div>
1480
+ <div className="gc-alert gc-alert--success">Settings saved.</div>
1481
+ <div className="gc-alert gc-alert--danger">
1482
+ Could not reach the server.
1483
+ </div>
1484
+ </Demo>
1485
+ </section>
1486
+
1487
+ <section className="docs-section" id="list">
1488
+ <div className="docs-section-eyebrow">Components / 24</div>
1489
+ <h2 className="docs-section-title">List</h2>
1490
+ <p className="docs-section-desc">
1491
+ A bordered stack of rows for simple records. Styles-only primitive
1492
+ — apply the classes to your own markup.
1493
+ </p>
1494
+ <Demo
1495
+ stageClass="column"
1496
+ code={`<ul className="gc-list">
1497
+ <li className="gc-list__item">Production deploy</li>
1498
+ <li className="gc-list__item">Staging deploy</li>
1499
+ <li className="gc-list__item">Nightly backup</li>
1500
+ </ul>`}
1501
+ >
1502
+ <ul className="gc-list docs-list-demo">
1503
+ <li className="gc-list__item">Production deploy</li>
1504
+ <li className="gc-list__item">Staging deploy</li>
1505
+ <li className="gc-list__item">Nightly backup</li>
1506
+ </ul>
1507
+ </Demo>
1508
+ </section>
1509
+
1510
+ <section className="docs-section" id="textarea">
1511
+ <div className="docs-section-eyebrow">Components / 25</div>
1512
+ <h2 className="docs-section-title">Textarea</h2>
1513
+ <p className="docs-section-desc">
1514
+ Multi-line text input matching the Input styling. Styles-only
1515
+ primitive — apply the class to a native textarea.
1516
+ </p>
1517
+ <Demo
1518
+ stageClass="column"
1519
+ code={`<textarea className="gc-textarea" rows={3} placeholder="Describe the issue…" />`}
1520
+ >
1521
+ <textarea
1522
+ className="gc-textarea"
1523
+ rows={3}
1524
+ placeholder="Describe the issue…"
1525
+ />
1526
+ </Demo>
1527
+ </section>
1528
+
1529
+ <section className="docs-section" id="led">
1530
+ <div className="docs-section-eyebrow">Components / 26</div>
1531
+ <h2 className="docs-section-title">LED</h2>
1532
+ <p className="docs-section-desc">
1533
+ A status light for dashboards and device panels. Add{" "}
1534
+ <code>gc-led--blink</code> for attention-demanding states.
1535
+ Styles-only primitive.
1536
+ </p>
1537
+ <Demo
1538
+ stageClass="center"
1539
+ code={`<span className="gc-led gc-led--green" />
1540
+ <span className="gc-led gc-led--blue" />
1541
+ <span className="gc-led gc-led--red" />
1542
+ <span className="gc-led gc-led--red gc-led--blink" />`}
1543
+ >
1544
+ <span className="gc-led gc-led--green" />
1545
+ <span className="gc-led gc-led--blue" />
1546
+ <span className="gc-led gc-led--red" />
1547
+ <span className="gc-led gc-led--red gc-led--blink" />
1548
+ </Demo>
1549
+ </section>
1550
+
1551
+ <section className="docs-section" id="joystick">
1552
+ <div className="docs-section-eyebrow">Components / 27</div>
1553
+ <h2 className="docs-section-title">Joystick</h2>
1554
+ <p className="docs-section-desc">
1555
+ A draggable two-axis control for hardware-like interfaces. Drag
1556
+ the knob — the position is reported through{" "}
1557
+ <code>onPositionChange</code>.
1558
+ </p>
1559
+ <Demo
1560
+ stageClass="center"
1561
+ code={`<Joystick
1562
+ isEnabled
1563
+ onPositionChange={(left, top) => console.log(left, top)}
1564
+ />`}
1565
+ >
1566
+ <JoystickDemo />
1567
+ </Demo>
1568
+ </section>
1569
+
1570
+ <section className="docs-section" id="scroller">
1571
+ <div className="docs-section-eyebrow">Components / 28</div>
1572
+ <h2 className="docs-section-title">Scroller</h2>
1573
+ <p className="docs-section-desc">
1574
+ A draggable horizontal slider for scrubbing through a range. Drag
1575
+ the knob — the position is reported through{" "}
1576
+ <code>onScrollChange</code> when the knob is released.
1577
+ </p>
1578
+ <Demo
1579
+ stageClass="center"
1580
+ code={`<Scroller
1581
+ min={0}
1582
+ max={100}
1583
+ onScrollChange={(value) => console.log(value)}
1584
+ />`}
1585
+ >
1586
+ <ScrollerDemo />
1587
+ </Demo>
1588
+ </section>
1589
+
1240
1590
  <footer className="docs-footer">
1241
1591
  <div>graphen · {VERSION} · MIT</div>
1242
1592
  <div>Built by the CODA_ team</div>
package/src/index.ts CHANGED
@@ -14,6 +14,8 @@ import Separator from "src/components/Separator";
14
14
  import Tooltip from "src/components/Tooltip";
15
15
  import Validation from "src/components/Validation";
16
16
  import Logo from "src/components/Logo";
17
+ import Navigation from "src/components/Navigation";
18
+ import NavigationOption from "src/components/NavigationOption";
17
19
  import Dropdown from "src/components/Dropdown";
18
20
  import Flex from "src/components/Flex";
19
21
  import FlexItem from "src/components/FlexItem";
@@ -45,6 +47,8 @@ export {
45
47
  Tooltip,
46
48
  Validation,
47
49
  Logo,
50
+ Navigation,
51
+ NavigationOption,
48
52
  Dropdown,
49
53
  Flex,
50
54
  FlexItem,