@ambientcss/components 2.0.1 → 3.0.0

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.
Files changed (46) hide show
  1. package/README.md +35 -0
  2. package/dist/index.cjs +1563 -384
  3. package/dist/index.cjs.map +1 -1
  4. package/dist/index.d.cts +763 -48
  5. package/dist/index.d.ts +763 -48
  6. package/dist/index.js +1524 -385
  7. package/dist/index.js.map +1 -1
  8. package/dist/styles.css +1102 -256
  9. package/package.json +2 -2
  10. package/src/components/AmbientButton.tsx +25 -25
  11. package/src/components/AmbientFader.tsx +33 -115
  12. package/src/components/AmbientKnob.tsx +64 -222
  13. package/src/components/AmbientPanel.tsx +8 -2
  14. package/src/components/AmbientProvider.tsx +3 -0
  15. package/src/components/AmbientRack.tsx +32 -0
  16. package/src/components/AmbientSelect.tsx +40 -0
  17. package/src/components/AmbientSlider.tsx +32 -113
  18. package/src/components/AmbientSwitch.tsx +58 -58
  19. package/src/controls/AmbientBank.tsx +138 -0
  20. package/src/controls/AmbientLatch.tsx +78 -0
  21. package/src/controls/AmbientPress.tsx +74 -0
  22. package/src/controls/AmbientRotary.tsx +94 -0
  23. package/src/controls/AmbientTravel.tsx +83 -0
  24. package/src/core/context.tsx +46 -0
  25. package/src/core/controllable.ts +33 -0
  26. package/src/core/dev.ts +15 -0
  27. package/src/core/frames.tsx +63 -0
  28. package/src/core/kit.tsx +107 -0
  29. package/src/core/material.ts +27 -0
  30. package/src/core/numeric.ts +88 -0
  31. package/src/core/types.ts +116 -0
  32. package/src/core/useBank.ts +163 -0
  33. package/src/core/useLatch.ts +54 -0
  34. package/src/core/usePress.ts +120 -0
  35. package/src/core/useRotary.ts +253 -0
  36. package/src/core/useTravel.ts +141 -0
  37. package/src/index.ts +127 -4
  38. package/src/kits/console.tsx +80 -0
  39. package/src/kits/grounded.tsx +113 -0
  40. package/src/parts/bank.tsx +32 -0
  41. package/src/parts/console.tsx +99 -0
  42. package/src/parts/knob.tsx +203 -0
  43. package/src/parts/latch.tsx +33 -0
  44. package/src/parts/press.tsx +56 -0
  45. package/src/parts/travel.tsx +70 -0
  46. package/src/styles.css +1102 -256
package/README.md CHANGED
@@ -25,3 +25,38 @@ export function Example() {
25
25
  );
26
26
  }
27
27
  ```
28
+
29
+ ## Two layers
30
+
31
+ Every control is a **mechanism** — kinematics, value, state and ARIA — plus a
32
+ **skin**. The named components are presets that pair one with a set of parts;
33
+ underneath, the mechanism has no appearance of its own and will wear whatever
34
+ you give it.
35
+
36
+ ```tsx
37
+ import { AmbientRotary, KnobBody, ScaleRing } from "@ambientcss/components";
38
+
39
+ <AmbientRotary
40
+ value={gain} onChange={setGain}
41
+ travel={{ start: -135, sweep: 270 }}
42
+ input="drag"
43
+ className="amb-knob"
44
+ parts={{
45
+ panel: <ScaleRing count={13} />,
46
+ base: <KnobBody flush />,
47
+ actuator: <MyPointer />,
48
+ }}
49
+ />
50
+ ```
51
+
52
+ Parts drop into four frames — `panel`, `base`, `actuator`, `fixture` — painted
53
+ in that order, of which only `actuator` moves. The control publishes its state
54
+ on its own root as `--ambx-percent`, `--ambx-angle`, `--ambx-size` and friends,
55
+ so a part can be pure CSS with no React state at all; `useControlState()` is the
56
+ same data typed, for parts that need JS.
57
+
58
+ Mechanisms: `AmbientRotary`, `AmbientTravel`, `AmbientPress`, `AmbientLatch`,
59
+ `AmbientBank`. Or take the hooks — `useRotary`, `useTravel`, `usePress`,
60
+ `useLatch`, `useBank` — and render the markup yourself.
61
+
62
+ Full guide: [Composing controls](https://kikkupico.github.io/ambientcss/ambient-components/composing).