|
1 | 1 | # Contributing to Wokwi Elements
|
2 | 2 |
|
3 |
| -First of all, thank you for considering contributing to Wokwi Elements! |
| 3 | +First of all, thank you for considering contributing to Wokwi Elements! |
4 | 4 | Please go over these guidelines to ensure that your contribution lands
|
5 | 5 | successfully.
|
6 | 6 |
|
7 | 7 | ## Creating a New Element
|
8 | 8 |
|
9 |
| -Before starting to work on a new element, please |
| 9 | +Before starting to work on a new element, please |
10 | 10 | [file an issue](https://github.com/wokwi/wokwi-elements/issues/new/choose)
|
11 |
| -to discuss the implementation. |
| 11 | +to discuss the implementation. |
12 | 12 |
|
13 | 13 | Also, please make sure that any 3d-party graphics that you use
|
14 | 14 | for the element is released under a permissive license (such as
|
15 |
| -MIT, BSD, Apache, or CC-BY), and that you give credits to the |
| 15 | +MIT, BSD, Apache, or CC-BY), and that you give credits to the |
16 | 16 | original authors as required.
|
17 | 17 |
|
18 | 18 | To create the element, use our hygen generator, by running:
|
@@ -45,14 +45,50 @@ Please make sure to follow these guidelines when working on your new element:
|
45 | 45 | 3. Add docstring to the element class and any public properties/methods. These
|
46 | 46 | doc strings will appear in the Docs tag in storybook. Check out the [Resistor
|
47 | 47 | Element](src/resistor-element.ts) for an example.
|
48 |
| -4. Your commit messages should follow the [conventional commits |
| 48 | +4. Include a `pinInfo` property in your elements. This property defines the pins |
| 49 | + of the element, specifying at least the name and x/y position of each pin. |
| 50 | + |
| 51 | + Example (from the [LED element](src/led-element.ts)): |
| 52 | + |
| 53 | + ```typescript |
| 54 | + readonly pinInfo: ElementPin[] = [ |
| 55 | + { name: 'A', x: 24, y: 42, signals: [], description: 'Anode' }, |
| 56 | + { name: 'C', x: 16, y: 42, signals: [], description: 'Cathode' }, |
| 57 | + ]; |
| 58 | + ``` |
| 59 | + |
| 60 | +5. Create a storybook story for each element configuration. For example, check the [LCD1602 |
| 61 | + stories](src/lcd1602-element.stories.ts) |
| 62 | +6. Your commit messages should follow the [conventional commits |
49 | 63 | standard](https://www.conventionalcommits.org/), e.g.:
|
50 | 64 | `feat: add neopixel element`
|
51 | 65 |
|
| 66 | +## Debugging Pin Info |
| 67 | + |
| 68 | +When working on the `pinInfo` property, it is often useful to visually see the |
| 69 | +pins that you define. To see the pin locations, add the `<wokwi-show-pins>` |
| 70 | +utility element to your story: |
| 71 | + |
| 72 | +1. Import the element definition into your story, by adding this line at the top |
| 73 | + of the story file: |
| 74 | + ``` |
| 75 | + import './utils/show-pins-element'; |
| 76 | + ``` |
| 77 | +2. Wrap your element with the <wokwi-show-pins> element, e.g. |
| 78 | + ``` |
| 79 | + export const HCSR04 = () => html` |
| 80 | + <wokwi-show-pins> |
| 81 | + <wokwi-hc-sr04></wokwi-hc-sr04> |
| 82 | + </wokwi-show-pins> |
| 83 | + `; |
| 84 | + ``` |
| 85 | +3. When you are happy with the pin definition, please remove the `<wokwi-show-pins>` |
| 86 | + from your story. It is only a debugging tool, and shouldn't be present in the final story. |
| 87 | + |
52 | 88 | ## Video Tutorial and Blog Post
|
53 | 89 |
|
54 | 90 | The [Membrane keypad element live-coding video tutorial](https://www.youtube.com/watch?v=gh27icNatwA) walks
|
55 | 91 | through the complete process behind creating an element: research, drawing, and writing the code /
|
56 |
| -stories. |
| 92 | +stories. |
57 | 93 |
|
58 | 94 | If you prefer reading over watching a video, please check out [Recreating The Arduino Pushbutton Using SVG And <lit-element>](https://www.smashingmagazine.com/2020/01/recreating-arduino-pushbutton-svg/).
|
0 commit comments