|
| 1 | +<script lang="ts"> |
| 2 | + import CopyPaste from './CopyPaste.svelte'; |
| 3 | + import LazyComponent from './LazyComponent.svelte'; |
| 4 | +</script> |
| 5 | + |
| 6 | +<div class="grid"> |
| 7 | + <h1 class="example"># svelte-knobs</h1> |
| 8 | + |
| 9 | + <div class="example"> |
| 10 | + <h2>Basic</h2> |
| 11 | + <LazyComponent component={() => import('./examples/BasicKnob.svelte')} /> |
| 12 | + |
| 13 | + <p>Basic styled svg knob</p> |
| 14 | + <CopyPaste>%import('./examples/BasicKnob.svelte')%</CopyPaste> |
| 15 | + </div> |
| 16 | + |
| 17 | + <div class="example"> |
| 18 | + <h2>Image</h2> |
| 19 | + <LazyComponent component={() => import('./examples/ImageKnob.svelte')} /> |
| 20 | + |
| 21 | + <p>You can use an image strip for a knob too.</p> |
| 22 | + <CopyPaste>%import('./examples/ImageKnob.svelte')%</CopyPaste> |
| 23 | + </div> |
| 24 | + |
| 25 | + <div class="example"> |
| 26 | + <h2>Custom knob</h2> |
| 27 | + |
| 28 | + <LazyComponent component={() => import('./examples/CustomKnob.svelte')} /> |
| 29 | + |
| 30 | + <p> |
| 31 | + In reality, svgknob and image knob are both based from a <code>{'<Draggable/>'}</code> component, |
| 32 | + that you can use as well, creating your very own custom made knob. |
| 33 | + </p> |
| 34 | + <CopyPaste>%import('./examples/CustomKnob.svelte')%</CopyPaste> |
| 35 | + </div> |
| 36 | + |
| 37 | + <div class="example"> |
| 38 | + <h2>Param knobs</h2> |
| 39 | + |
| 40 | + <LazyComponent component={() => import('./examples/ParamKnob.svelte')} /> |
| 41 | + |
| 42 | + <p> |
| 43 | + Since all knobs operate on values between 0 and 1 any type of scaling is done outside of the |
| 44 | + scope of a knob with parameter objects. |
| 45 | + </p> |
| 46 | + <CopyPaste>%import('./examples/ParamKnob.svelte')%</CopyPaste> |
| 47 | + </div> |
| 48 | + |
| 49 | + <div class="example"> |
| 50 | + <h2>Enum-param knobs</h2> |
| 51 | + |
| 52 | + <LazyComponent component={() => import('./examples/EnumParam.svelte')} /> |
| 53 | + |
| 54 | + <p> |
| 55 | + Enums or, in typescript realm <code>readonly string[]</code> parameter are a special type of |
| 56 | + parameter that don't denormalize into a number, instead into a string. <code>EnumParam</code> class |
| 57 | + comes with helpful properties for knob ui with already calcualted snap points and snap threshold |
| 58 | + to make value changes 'instant'. |
| 59 | + </p> |
| 60 | + <CopyPaste>%import('./examples/EnumParam.svelte')%</CopyPaste> |
| 61 | + </div> |
| 62 | +</div> |
| 63 | + |
| 64 | +<style> |
| 65 | + :global(body) { |
| 66 | + margin: 0; |
| 67 | + padding: 0; |
| 68 | + min-height: 100vh; |
| 69 | + background: #222; |
| 70 | + color: #fff; |
| 71 | + font-family: sans; |
| 72 | + } |
| 73 | +
|
| 74 | + .grid { |
| 75 | + padding: 2rem; |
| 76 | + display: flex; |
| 77 | + flex-direction: column; |
| 78 | + max-width: 720px; |
| 79 | + margin: 0 auto; |
| 80 | + gap: 8px; |
| 81 | + } |
| 82 | +
|
| 83 | + .example { |
| 84 | + position: relative; |
| 85 | + width: 100%; |
| 86 | + padding: 1rem; |
| 87 | + display: flex; |
| 88 | + margin: 0 auto; |
| 89 | + flex-direction: column; |
| 90 | + align-items: center; |
| 91 | + border-bottom: solid 2px #333; |
| 92 | + } |
| 93 | +
|
| 94 | + .example > p { |
| 95 | + text-align: center; |
| 96 | + } |
| 97 | +
|
| 98 | + .example > h2 { |
| 99 | + user-select: none; |
| 100 | + } |
| 101 | +</style> |
0 commit comments