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

refactor(ui) & feat(blockly): Rework UI and add dynamic inputs #34

Open
wants to merge 60 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
c858cf9
feat: Dynamic inputs
ItsLimeNade Apr 20, 2024
717e9b2
Merge pull request #22 from scratch-for-discord/master
ItsLimeNade Apr 20, 2024
2d835e6
Fix: math category errors
ItsLimeNade Apr 20, 2024
fba3cf2
Merge branch 'dynamic-inputs' into merge
ItsLimeNade Apr 20, 2024
db6a561
Merge pull request #23 from scratch-for-discord/merge
ItsLimeNade Apr 20, 2024
da86697
Fix: Merge conflicts crumbs
ItsLimeNade Apr 20, 2024
4fdb7c2
Fix: import bug
ItsLimeNade Apr 20, 2024
218930a
Chore: Lint
ItsLimeNade Apr 20, 2024
06bb44d
Feat: Removed AsMu V1 -> V2
ItsLimeNade Apr 20, 2024
5517252
Feat: Better Tooltips + Remove logs
ItsLimeNade Apr 21, 2024
7d48e51
Feat: update workspace creation form
ItsLimeNade Apr 21, 2024
a1100a0
Uhm, not gonnna ask questions
ItsLimeNade Jul 8, 2024
8ce3906
Init: Ui refactor
retrouser955 Jul 29, 2024
4c557cc
now using shadcn-svelte + editor redesign (#32)
lea0o0oo Aug 20, 2024
e335428
init: workspace UI
retrouser955 Aug 20, 2024
641d06d
Merge branches 'dynamic-inputs' and 'dynamic-inputs' of https://githu…
retrouser955 Aug 20, 2024
17be696
Add varela font
retrouser955 Aug 20, 2024
265dc73
revert back to @lea0o0oo csr
retrouser955 Aug 20, 2024
f8ece80
fix: interface not rendering sometimes
retrouser955 Aug 20, 2024
d48f711
fix merge conflicts
retrouser955 Aug 20, 2024
06dd03a
fix more merge conflicts
retrouser955 Aug 20, 2024
360439a
attempt to fix workspace ui
retrouser955 Aug 21, 2024
3fcd1c7
Dynamic inputs revert (#35)
retrouser955 Aug 22, 2024
5c00325
chore: cleanup types
retrouser955 Aug 22, 2024
714cf13
fix: gh actions
retrouser955 Aug 22, 2024
e65b62e
Fix: navbar not showing on initial page load
retrouser955 Aug 22, 2024
8e08dda
init: user workspaces
retrouser955 Aug 22, 2024
3407ff9
Update navbar to use $page store instead
retrouser955 Aug 22, 2024
e6bfbba
Implement hide navbar feature
retrouser955 Aug 22, 2024
c87be8c
fix different sizes on viewports
retrouser955 Aug 22, 2024
2e9d00f
moved Collapse btn to left
Aug 22, 2024
8cb4403
Hidden overflow-x in warnings modal, so that when expanding the accor…
Aug 22, 2024
c26732c
make animation smoother
retrouser955 Aug 22, 2024
d6ccef5
init: new interface
retrouser955 Aug 23, 2024
e96407c
Make ui responsive on mobile devices
retrouser955 Aug 23, 2024
4fdd978
init: workspace ui
retrouser955 Aug 24, 2024
a3031c8
Bootstrap workspace creation
retrouser955 Aug 24, 2024
2bba814
make localstorage react to changes
retrouser955 Aug 24, 2024
2718e82
get edit and delete buttons working
retrouser955 Aug 25, 2024
fe574c1
implement load on open workspace
retrouser955 Aug 25, 2024
2905367
init: cryptography
retrouser955 Aug 25, 2024
aa3bad7
init: account tab
Aug 27, 2024
29378dd
fix: merge conflicts
Aug 27, 2024
5f558a6
add blockshape value
Aug 27, 2024
65de2cb
chore(lint): run eslint and prettier
Aug 27, 2024
a6e8b03
Make pull request tests stricter
retrouser955 Aug 27, 2024
7688723
feat(workflow): verbose pull request workflow
Aug 27, 2024
1094f09
merge
Aug 27, 2024
0a5d1c4
chore(format): run prettier
Aug 27, 2024
4b79aa2
chore(lint): fix eslint errors
Aug 27, 2024
0d73380
stop prettier from annoying us
Aug 27, 2024
f8f8a75
chore(lint & format): make eslint and prettier work together
Aug 27, 2024
652a052
feat(editor nav): make dropdown
retrouser955 Aug 31, 2024
d47e63e
refactor(EditorNavbar): Put file commands in dropdown instead
retrouser955 Sep 22, 2024
46a0ac7
feat(editor nav): toolbox
retrouser955 Sep 22, 2024
c2024df
chore(format & lint): Ran formatting scripts
retrouser955 Sep 23, 2024
db7182c
better login pages, 404 page (#66)
noxyyk Sep 28, 2024
c227aba
fix(spacing) & chore(lint)
retrouser955 Sep 28, 2024
5991304
sort out layouts
retrouser955 Sep 28, 2024
e4d507d
chore(fmt)
retrouser955 Sep 28, 2024
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
Prev Previous commit
Next Next commit
fix more merge conflicts
  • Loading branch information
retrouser955 committed Aug 20, 2024
commit 06dd03a18bd8a65d846b83bf3178a10cf06ac32e
241 changes: 0 additions & 241 deletions src/lib/blocks/Javascript/math.ts
Original file line number Diff line number Diff line change
Expand Up @@ -319,249 +319,8 @@ const blocks: BlockDefinition[] = [
// return `Math.random() * 100 < ${args.CHANCE}`
// }

<<<<<<< HEAD
// }
];
=======
case "inverse":
return `${args.NUMBER}) * -1`
case "log10":
return `Math.log(${args.NUMBER}) / Math.log(10)`
case "sin":
case "cos":
case "tan":
case "asin":
case "acos":
case "atan":
return `(Math.(${args.OPERATION}) / Math.PI) * 180`
default:
return `Math.${args.OPERATION}(${args.NUMBER})`
}
}
},
{
id: "constants",
text: "{CONSTANT}",
args: [
new Dropdown("CONSTANT", DropdownType.Auto, {
"π": "Math.PI",
"e": "Math.E",
"ϕ": "(1 + Math.sqrt(5)) / 2",
"√(2)": "Math.SQRT2",
"√(½)": "Math.Math.SQRT1_2",
"∞": "Infinity",
"NaN": "NaN",
})
],
shape: BlockShape.Floating,
output: BlockType.Number,
inline: true,
colour: "#5b67a5",
tooltip: "Allows you to use constants.",
helpUrl: "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number",
code: (args) => {
return `${args.CONSTANT}`
}
},
{
id: "is",
text: "{NUMBER} is {VALUE}",
args: [
new ValueInput("NUMBER", BlockType.Number),
new Dropdown("VALUE", DropdownType.Auto, {
"number": "number",
"even": "even",
"odd": "odd",
"prime": "prime",
"whole": "whole",
"positive": "positive",
"negative": "negative",
"divisible by": "divisible"
})],
placeholders: [
new Placeholder(PlaceholderType.Block, "NUMBER", "number", {NUMBER: 1}),


],
shape: BlockShape.Floating,
output: BlockType.Boolean,
inline: true,
colour: "#5b67a5",
tooltip: "Checks if a number is even, odd, prime, whole, positive, negative, or div",
helpUrl: "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number",
code: (args) => {
switch (`${args.VALUE}`) {
case "number":
return `typeof ${args.NUMBER} === "number" && ${args.NUMBER} % 1 === 0`
case "even":
return `${args.NUMBER} % 2 === 0`
case "odd":
return `${args.NUMBER} % 2!== 0`
case "prime":
return `isPrime(${args.NUMBER})` /* function isPrime(number) {if (number < 2) {return false;};for (let i = 2; i <= Math.sqrt(number); i++) {if (number % i === 0) {return false;}}return true;} */
case "whole":
return `${args.NUMBER} % 1 === 0`
case "positive":
return `${args.NUMBER} > 0`
case "negative":
return `${args.NUMBER} < 0`
default:
return `${args.NUMBER} % ${args.VALUE} === 0` // fix when added mutator
}
}
},
{
id: "array_math",
text: "{OPERATION} of list {ARRAY}",
args: [
new Dropdown("OPERATION", DropdownType.Auto, {
"sum": "sum",
"min": "min",
"max": "max",
"average": "average",
"median": "median",
"mode": "mode",
"range": "range",
"random": "random",
"standard deviation": "standard deviation",

}),
new ValueInput("ARRAY", BlockType.Array)
],
// placeholders: [
// new Placeholder(PlaceholderType.Block, "ARRAY", "array", {ARRAY: [1, 2, 3]})
// ],
shape: BlockShape.Floating,
output: BlockType.Number,
inline: true,
colour: "#5b67a5",
tooltip: "Allows you to use math with arrays.",
helpUrl: "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number",
code: (args) => {
switch (args.OPERATION) {
case "sum":
return `${args.ARRAY}.reduce((a, b) => a + b)`
case "min":
return `${args.ARRAY}.reduce((a, b) => Math.min(a, b))`
case "max":
return `${args.ARRAY}.reduce((a, b) => Math.max(a, b))`
case "average":
return `${args.ARRAY}.reduce((a, b) => a + b) / ${args.ARRAY}.length`
case "median":
return `${args.ARRAY}.sort((a, b) => a - b).length % 2? ${args.ARRAY}.sort((a, b) => a - b)[Math.floor(${args.ARRAY}.length / 2)] : ((${args.ARRAY}.sort((a, b) => a - b)[Math.floor(${args.ARRAY}.length / 2)] + ${args.ARRAY}.sort((a, b) => a - b - 1)[Math.floor(${args.ARRAY}.length / 2)]) / 2 ))`
case "mode":
return `${args.ARRAY}.sort((a, b) => a - b).length % 2`
case "range":
return `${args.ARRAY}.reduce((a, b) => Math.max(a, b) - Math.min(a, b))`
case "random":
return `Math.floor(Math.random() * ${args.ARRAY}.length)`
case "standard deviation":
return `Math.sqrt(${args.ARRAY}.reduce((a, b) => Math.pow(a - b, 2)) / ${args.ARRAY}.length)`
default:
return `Math.${args.OPERATION}(${args.ARRAY})`
}
}
},
{
id: "random_int",
text: "random integer between {MIN} to {MAX}",
args: [
new ValueInput("MIN", BlockType.Number),
new ValueInput("MAX", BlockType.Number)
],
placeholders: [
new Placeholder(PlaceholderType.Block, "MIN", "number", {NUMBER: 1}),
new Placeholder(PlaceholderType.Block, "MAX", "number", {NUMBER: 10})
],
shape: BlockShape.Floating,
output: BlockType.Number,
inline: true,
colour: "#5b67a5",
tooltip: "Gets a random integer between two numbers.",
helpUrl: "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number",
code: (args) => {
return `Math.floor(Math.random() * (${args.MAX} - ${args.MIN}) + ${args.MIN})`
}
},
{
id: "random_fraction",
text: "random fraction",
args: [],
shape: BlockShape.Floating,
output: BlockType.Number,
inline: true,
colour: "#5b67a5",
tooltip: "Gets a random fraction.",
helpUrl: "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number",
code: () => {
return `Math.random()`
}
},
{
id: "toNumber",
text: "convert text {TEXT} to number",
args: [
new ValueInput("TEXT", BlockType.String)
],
placeholders: [
new Placeholder(PlaceholderType.Block, "TEXT", "text", {TEXT: "123"})
],
shape: BlockShape.Floating,
output: BlockType.Number,
inline: true,
colour: "#5b67a5",
tooltip: "Converts text to a number.",
helpUrl: "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number",
code: (args) => {
return `parseInt(${args.TEXT})`
}
},
{
id: "constrain {VALUE} between {MIN} and {MAX}",
text: "constrain {VALUE} between {MIN} and {MAX}",
args: [
new ValueInput("VALUE", BlockType.Number),
new ValueInput("MIN", BlockType.Number),
new ValueInput("MAX", BlockType.Number)
],
placeholders: [
new Placeholder(PlaceholderType.Block, "VALUE", "number", {NUMBER: 50}),
new Placeholder(PlaceholderType.Block, "MIN", "number", {NUMBER: 1}),
new Placeholder(PlaceholderType.Block, "MAX", "number", {NUMBER: 100})
],
shape: BlockShape.Floating,
output: BlockType.Number,
inline: true,
colour: "#5b67a5",
tooltip: "Constrains a number between two numbers.",
helpUrl: "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number",
code: (args) => {
return `Math.min(Math.max(${args.VALUE}, ${args.MIN}), ${args.MAX})`
}
},
// {
// id: "chance {CHANCE} %",
// text: "{CHANCE} % chance of true",
// args: [
// new ValueInput("CHANCE", BlockType.Number)
// ],
// placeholders: [
// new Placeholder(PlaceholderType.Block, "CHANCE", "number", {NUMBER: 50})
// ],
// shape: BlockShape.Floating,
// output: BlockType.Boolean,
// inline: true,
// colour: "#5b67a5",
// tooltip: "Chances a number between two numbers.",
// helpUrl: "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number",
// code: (args) => {
// return `Math.random() * 100 < ${args.CHANCE}`
// }

// }

]
>>>>>>> master

const category: CategoryDefinition = {
name: "Math",
Expand Down
1 change: 1 addition & 0 deletions src/lib/blocks/Javascript/text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import ValueInput from "$lib/utils/BlockGen/Inputs/ValueInput";
import Placeholder from "$lib/utils/ToolboxGen/Placeholder";
import StatementInput from "$lib/utils/BlockGen/Inputs/StatementInput";
import Dropdown from "$lib/utils/BlockGen/Inputs/Dropdown";
import AssemblerMutatorV2 from "$lib/utils/BlockGen/Mutators/AssemblerMutatorV2"

const blocks: BlockDefinition[] = [
{
Expand Down