Skip to content

Commit c0b7aa5

Browse files
committed
block list in home. update docs
1 parent b5ea6ae commit c0b7aa5

File tree

7 files changed

+128
-94
lines changed

7 files changed

+128
-94
lines changed

circuito-schema

public/bundle.js

+13-13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/client/blocks-list.js

+63-41
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
import React from "react";
22
import { Typeahead } from "react-bootstrap-typeahead";
33
import { toast } from "react-toastify";
4+
import { ListGroup } from "react-bootstrap";
45
import { update_a_block, update_a_coder } from "./controller.js";
56
import { createNewCoder } from "./form/coderfield.js";
7+
import { faPlus } from "@fortawesome/free-solid-svg-icons";
8+
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
69

710
function createNewBlockData(blockName) {
811
var blockId = Math.floor(Math.random() * 5000 + 5000);
@@ -22,9 +25,32 @@ function createNewBlockData(blockName) {
2225
};
2326
}
2427

28+
function MenuOption(props) {
29+
return (
30+
<div
31+
style={{
32+
height: 45,
33+
verticalAlign: "middle"
34+
}}
35+
key={props.id}
36+
>
37+
<span style={{ width: 45, display: "inline-block" }}>
38+
{props.img && (
39+
<img
40+
src={props.img.replace("/image/upload/", "/image/upload/h_42/")}
41+
/>
42+
)}
43+
</span>
44+
{props.label}
45+
</div>
46+
);
47+
}
48+
2549
export class BlocksList extends React.Component {
2650
constructor(props) {
2751
super(props);
52+
53+
this.state = { input: "" };
2854
}
2955

3056
render() {
@@ -42,16 +68,34 @@ export class BlocksList extends React.Component {
4268
<Typeahead
4369
options={blocksIdsLabels}
4470
selectHintOnEnter={true}
45-
allowNew={true}
46-
newSelectionPrefix="Create new block:"
71+
emptyLabel={false}
72+
onInputChange={input => {
73+
this.setState({ input });
74+
}}
4775
onChange={selection => {
48-
if (
49-
selection[0] &&
50-
typeof selection[0] === "object" &&
51-
"customOption" in selection[0]
52-
) {
76+
analytics.track("Block Opened", { name: selection[0].id });
77+
this.props.onBlockSelected(selection[0].id);
78+
}}
79+
bsSize={"small"}
80+
open
81+
maxHeight="600px"
82+
menuId="main-block-list"
83+
placeholder="Choose a block to edit or enter name to create a new one..."
84+
renderMenuItemChildren={(option, props, index) => (
85+
<MenuOption {...option} />
86+
)}
87+
/>
88+
89+
<ListGroup>
90+
<ListGroup.Item
91+
disabled={
92+
this.state.input === "" ||
93+
this.props.cachedData.blocks.includes(this.state.input)
94+
}
95+
action
96+
onClick={event => {
5397
// clicked create new
54-
var newBlockName = selection[0].label;
98+
var newBlockName = this.state.input;
5599

56100
analytics.track("Block Created", { name: newBlockName });
57101
analytics.track("Block Opened", { name: newBlockName });
@@ -84,39 +128,17 @@ export class BlocksList extends React.Component {
84128
this.props.onBlockSelected(newBlockName);
85129
}
86130
});
87-
} else {
88-
analytics.track("Block Opened", { name: selection[0].id });
89-
this.props.onBlockSelected(selection[0].id);
90-
}
91-
}}
92-
bsSize={"small"}
93-
open
94-
maxHeight="600px"
95-
menuId="main-block-list"
96-
placeholder="Choose a block to edit or enter name to create a new one..."
97-
renderMenuItemChildren={(option, props, index) => (
98-
<React.Fragment key={index}>
99-
<div
100-
style={{
101-
height: 45,
102-
verticalAlign: "middle"
103-
}}
104-
>
105-
<span style={{ width: 45, display: "inline-block" }}>
106-
{option.img && (
107-
<img
108-
src={option.img.replace(
109-
"/image/upload/",
110-
"/image/upload/h_42/"
111-
)}
112-
/>
113-
)}
114-
</span>
115-
{option.label}
116-
</div>
117-
</React.Fragment>
118-
)}
119-
/>
131+
}}
132+
>
133+
<FontAwesomeIcon icon={faPlus} style={{ width: "45px" }} />
134+
Create new block: &nbsp;
135+
<span>
136+
<mark class="rbt-highlight-text">
137+
{this.state.input || "Enter name"}
138+
</mark>
139+
</span>
140+
</ListGroup.Item>
141+
</ListGroup>
120142
</React.Fragment>
121143
);
122144
}

src/client/docs.js

+36-38
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ export const docs = {
2222
img: "block_image.png"
2323
},
2424
"block.requiresSoldering": {
25-
text: "Display an indicator in the app that parts in this block require soldering",
25+
text:
26+
"Display an indicator in the app that parts in this block require soldering",
2627
img: "block_soldering.png"
2728
},
2829
"block.description": {
29-
text:
30-
`A short paragraph in html describing the block, its features and uses. This description will appear in the block’s info pop up.
30+
text: `A short paragraph in html describing the block, its features and uses. This description will appear in the block’s info pop up.
3131
always wrap you paragraphs in \`\`\`<p>text</p>\`\`\``,
3232
img: "block_desc.png"
3333
},
@@ -80,13 +80,11 @@ E.g: when adding a controller similar to Arduino Uno, choose “Arduino Uno”
8080
text:
8181
"If blank, the system will try to optimally place the part on the circuit, based on the geometry of its SVG file. To override this preset, specify the rotation angle in degrees."
8282
},
83-
"circuit.part.includeInFirmware": {
83+
"circuit.part.includeInFirmware": {
8484
text: `Adds the port definition in the code.`
8585
},
8686

87-
88-
89-
"circuit.ports": {
87+
"circuit.ports": {
9088
text: `Ports are the representation of the physical interface between circuits.
9189
A port can either require or provide attributes. These attributes are used by the system to connect between ports.`
9290
},
@@ -109,16 +107,17 @@ A port can either require or provide attributes. These attributes are used by th
109107
"circuit.port.requires.load": {
110108
text: `Specify the load that the port provides/requires (Only for significant load above 50mA).`
111109
},
112-
"circuit.port.unique" : {
113-
text: "Defines that no other ports will be routed to its provider. Connecting Arduino Uno with 2 flex sensors with unique ports, will determine that each unique port will be connected to a different ADC port on the Arduino."
110+
"circuit.port.unique": {
111+
text:
112+
"Defines that no other ports will be routed to its provider. Connecting Arduino Uno with 2 flex sensors with unique ports, will determine that each unique port will be connected to a different ADC port on the Arduino."
114113
},
115114
"circuit.port.chainTo": {
116115
text: `Used for chainable blocks. (e.g. Led Matrix, Led Strips) When these are defined, the system will connect only the first instance of the chainable blocks to the controller and the rest will be chained to one another using this definition.
117116
In this field, specify a port name to chain to, it comes together with the ‘Port is Chainable’ in the corresponding provides port.`,
118-
img: "block_chainBlocks.png"
117+
img: "block_chainBlocks.png"
119118
},
120119

121-
"circuit.port.provides": {
120+
"circuit.port.provides": {
122121
text: `List all attributes it can provide.
123122
Note:
124123
- For power (3.3-5v and GND) pins, leave the spec blank.
@@ -160,38 +159,39 @@ Relative units. (0-inf)
160159
Support blocks with a lower cost will be tried first. For controllers, there may be more than one support block.`
161160
},
162161

163-
164-
165162
"circuit.coders": {
166163
text: `The coder information is used to generate the test code provided in the app.
167164
A block can have multiple coders which will differ according to their supported controllers.
168165
169166
The coder links between the block and the auto-generated code according to the selected controller. The coder’s information will be used to render the code for your controller. It’s also possible to add external code libraries to coders.`
170167
},
171-
"circuit.name":{
172-
text:`Internal name of the code in the database. Must be unique.`
173-
},
174-
"circuit.supportedControllers":{
175-
text:`List the controllers for which this coder is applicable.`
176-
},
177-
"circuit.files":{
178-
text:`Upload external code libraries if necessary.`
179-
},
180-
"circuit.license":{
181-
text:`It is important to also upload the license of the library added, and make sure that it is …`
182-
},
183-
"circuit.classname":{
184-
text:`Specify the class name for this coder if necessary.`
185-
},
186-
"circuit.varname":{
187-
text:`Specify the var name for this coder. Must be unique among all coders.`
188-
},
189-
"circuit.code":{
190-
text:`The firmware.ino is generated by combining templates from all selected coders.
168+
"coder.name": {
169+
text: `Internal name of the code in the database. Must be unique.`
170+
},
171+
"coder.supportedControllers": {
172+
text: `List the controllers for which this coder is applicable.`
173+
},
174+
"coder.files": {
175+
text: `Upload external code libraries if necessary.`
176+
},
177+
"coder.headers": {
178+
text: `Specify a list of header files to be included in the firmware.ino (could also be built-in Arduino IDE libraries such as SoftwareSerial.h).`
179+
},
180+
"coder.license": {
181+
text: `It is important to upload the license of the library added, specify the license type here and make sure that it is under the public domain.`
182+
},
183+
"coder.classname": {
184+
text: `Specify the class name for this coder if necessary.`
185+
},
186+
"coder.varname": {
187+
text: `Specify the var name for this coder. Must be unique among all coders.`
188+
},
189+
"coder.code": {
190+
text: `The firmware.ino is generated by combining templates from all selected coders.
191191
Fill in the following sections and preview the renderd code example to verify.
192192
`
193-
},
194-
"coder.code.global": {
193+
},
194+
"coder.code.global": {
195195
text: "Used for global variables. Rendered at the top of the file."
196196
},
197197
"coder.code.constructors": {
@@ -205,8 +205,7 @@ Fill in the following sections and preview the renderd code example to verify.
205205
text: `demonstrates basic use of the part. Should include comments.`
206206
},
207207

208-
209-
"circuit.parts": {
208+
"circuit.parts": {
210209
text: `Parts are the building blocks of the circuits. They are physical components, represented by an illustrated SVG file, and refer to a specific electronic component model.
211210
A circuit consists of at least one part which interconnects with other parts and ports of the block. These connections are defined in the ‘wiring’ section.
212211
`
@@ -281,5 +280,4 @@ E.g. screws, nuts, bolts, heatsinks, breakouts or special connectors.
281280
Note: these parts aren’t represented in the schematics.
282281
`
283282
}
284-
285283
};

src/client/form/commonfields.js

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ export function supportedControllersUISchema(controllersList) {
66
placeholder: "Select controllers",
77
multiple: true,
88
minLength: 0
9+
},
10+
"ui:options": {
11+
forceLabelDisplay: true
912
}
1013
};
1114
}

src/client/form/tooltipdescriptionfield.js

+3
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ export const TooltipDescriptionField = ({ id, description }) => {
2727
.use(html)
2828
.processSync(docText);
2929

30+
if (!(doc && doc.text))
31+
console.warn("Missing doc key ", descText)
32+
3033
return (
3134
<div className="tooltip-hint" id={id} data-tip={`${docHTML}${imgTag}`}>
3235
<a>

src/client/home.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export class Home extends React.Component {
1515

1616
render() {
1717
return (
18-
<Container>
18+
<Container style={{ maxWidth: "unset" }}>
1919
<Row>
2020
<Col>
2121
<Card>
@@ -35,6 +35,7 @@ export class Home extends React.Component {
3535
<h3>How this works</h3>
3636
</Card.Header>
3737
<Card.Body>
38+
Welcome to the <a href="www.circuito.io" target="_blank">circuito.io</a> Component Editor!
3839
<ol>
3940
<li>
4041
Choose a block to <b>edit</b> or create a new one
@@ -50,6 +51,13 @@ export class Home extends React.Component {
5051
it
5152
</li>
5253
</ol>
54+
Need help? Visitr our{" "}
55+
<a
56+
href="https://talk.circuito.io/c/component-editor"
57+
target="_blank"
58+
>
59+
support forum
60+
</a>
5361
</Card.Body>
5462
</Card>
5563
</Col>

0 commit comments

Comments
 (0)