Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New block merge #38

Merged
merged 16 commits into from
Aug 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .github/workflows/pr-block-rules.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: PR Block Rules

on:
pull_request:
types: [opened, edited]

jobs:
comment-on-pr:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Display block rules
run: |
RULES=$(cat ./block_creation_rules.md)
gh pr comment ${{ github.event.pull_request.number }} --body "$RULES"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33 changes: 33 additions & 0 deletions block_creation_rules.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
Hello there!
Thank you for contributing.

Before merging, please ensure that each modified or newly created block meets the following requirements:

**Concise List:**

##### 1. The block does one thing.
- For example, the `create_embed` block should only create an embed and not create a variable.

##### 2. The block has warnings for crucial inputs.
- For example, in the `get_user_by_id` block, the `id` field must include a warning, as it is crucial for the block to function as intended.

##### 3. Each block has maximum customizability.

##### 4. Inputs are error-proofed.
- **DO NOT CREATE INPUTS WHERE YOU CAN TYPE CODE** (with the exception of the insert JS block).
- Inputs should not cause errors, even when left empty.

##### 5. Consistent design patterns.
- Every block should be created in the same style.

##### 6. Clear and descriptive titles.

##### 7. Block modularity and reusability.
- Ensure that blocks can connect with each other in various scenarios. For example, if two blocks have the `user` type, they should be usable in all user inputs.

##### 8. Performance.

##### 9. Consider user feedback.

These rules will make app development easier, help eliminate pesky bugs, and simplify refactoring.

9 changes: 8 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 10 additions & 10 deletions src/lib/blocks/Javascript/Loops.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ const blocks: BlockDefinition[] = [
shape: BlockShape.Action,
inline: true,
colour: rgbToHex(91, 165, 91),
tooltip: "Repeat x times",
tooltip: "Repeats the code inside the given ammount of times.",
helpUrl: "",
code: (args) => {
return `for (let i = 0; i < ${args.VALUE === ""? "0" : args.VALUE}; i++) {\n${args.INPUT === ""? "" : args.INPUT}\n}`;
return `for (let i = 0; i < ${args.VALUE === "" ? "0" : args.VALUE}; i++) {\n${args.INPUT === "" ? "" : args.INPUT}\n}`;
}
},
{
Expand All @@ -35,10 +35,10 @@ const blocks: BlockDefinition[] = [
shape: BlockShape.Action,
inline: true,
colour: rgbToHex(91, 165, 91),
tooltip: "Repeat while",
tooltip: "Repeats the code inside until/while the condition is met.",
helpUrl: "",
code: (args) => {
return `while (${args.WHILE === "while" ? "" : "!"}( ${args.CONDITION === ""? "false" : args.CONDITION} )) {\n${args.INPUT === ""? "" : args.INPUT}\n}`;
return `while (${args.WHILE === "while" ? "" : "!"}( ${args.CONDITION === "" ? "false" : args.CONDITION} )) {\n${args.INPUT === "" ? "" : args.INPUT}\n}`;
}
},
{
Expand All @@ -60,10 +60,10 @@ const blocks: BlockDefinition[] = [
tooltip: "For loop",
helpUrl: "",
code: (args) => {
if(args.VARIABLE === "") return "";
let variable = `let ${args.VARIABLE} =${args.START ===""? "0" : args.START}`;
let condition = `${args.VARIABLE} < ${args.END === ""? "0" : args.END}`;
let step = `${args.VARIABLE} += ${args.STEP ===""? "0" : args.STEP}}`;
if (args.VARIABLE === "") return "";
const variable = `let ${args.VARIABLE} =${args.START === "" ? "0" : args.START}`;
const condition = `${args.VARIABLE} < ${args.END === "" ? "0" : args.END}`;
const step = `${args.VARIABLE} += ${args.STEP === "" ? "0" : args.STEP}}`;
if (args.VARIABLE === "") {
const varName = salt(10);
return `for(let vk${varName} = 0; false; vk${varName}+= 0) {}`;
Expand All @@ -82,7 +82,7 @@ const blocks: BlockDefinition[] = [
shape: BlockShape.Action,
inline: true,
colour: rgbToHex(91, 165, 91),
tooltip: "Array iteration",
tooltip: "Loops throught every item of the given array.",
helpUrl: "",
code: (args) => {
return `for (let ${args.ITEM} of ${args.ARRAY}) {\n${args.INPUT}\n}`;
Expand All @@ -100,7 +100,7 @@ const blocks: BlockDefinition[] = [
shape: BlockShape.Action,
inline: true,
colour: rgbToHex(91, 165, 91),
tooltip: "Break",
tooltip: "Breaks out of a loop.",
helpUrl: "",
code: (args) => {
return `${args.ACTION};`;
Expand Down
Loading
Loading