Skip to content

Commit

Permalink
Merge pull request #261 from JerryI/dev
Browse files Browse the repository at this point in the history
Update
  • Loading branch information
JerryI authored Aug 4, 2024
2 parents 3b25b69 + 561d79b commit 0e95b38
Show file tree
Hide file tree
Showing 357 changed files with 17,824 additions and 885 deletions.
Binary file modified .DS_Store
Binary file not shown.
8 changes: 7 additions & 1 deletion Components/FakeMenu.wlx
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,13 @@ Component[OptionsPattern[]] := With[{
</button>
</div>
], {Vi, Join[Plugins["misc"], {}]}]
,
,
<div class="py-0 px-2" role="none">
<button data-name="OpenSettings" data-ctl="true" class="block w-full hover:bg-teal-400 hover:text-white text-black group flex items-center px-1 my-1 py-1 rounded text-sm leading-4 dark:text-gray-400" role="menuitem" tabindex="-1">
Settings
</button>
</div>
,
<div class="py-0 px-2" role="none">
<button data-name="docsx" class="block w-full hover:bg-teal-400 hover:text-white text-black group flex items-center px-1 my-1 py-1 rounded text-sm leading-4 dark:text-gray-400" role="menuitem" tabindex="-1">
Docs
Expand Down
71 changes: 71 additions & 0 deletions Components/Notifications/Components/Custom.wlx
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
CreateType[Notifications`Custom(*`*), init, {"Topic"->"Title", "Icon" -> With[{},
<svg aria-hidden="true" class="w-6 h-6 text-gray-200 animate-spin dark:text-gray-600 fill-teal-600" viewBox="0 0 100 101" fill="none">
<path d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z" fill="currentColor"/>
<path d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z" fill="currentFill"/>
</svg>
], "Promise"->Null, "Body"->"Message", "DOM"->Null}]

init[n_] := With[{dom = CreateUUID[]},
Echo["Created! Spinner"];
n["DOM"] = dom;
n["Promise"] = Promise[];
Then[n["Promise"], Function[Null,
EventFire[#, Resolve, Null] &/@ n["Instances"]
],
Function[Null,
EventFire[#, Resolve, Null] &/@ n["Instances"]
]];
];

Notifications`Custom(*`*) /: Delete[n_Notifications`Custom(*`*)] := (
EventFire[n["Promise"], Resolve, "Removed"];
);

Component[n_, client_, controller_] := With[{Uid = n["DOM"], Message = n["Body"], Icon = n["Icon"], Topic = n["Topic"], p = Promise[], LocalController = CreateUUID[]},
n["Instances"] = Append[n["Instances"], p];
Then[p,
Function[Null,
EventFire[Uid, "Remove", <|"Client"->client|>];
],
Function[Null,
EventFire[Uid, "Remove", <|"Client"->client|>];
]
];

With[{template = {
<div id="{Uid}" style="z-index:1500" class="my-2 pointer-events-auto overflow-hidden rounded-lg bg-white shadow-lg ring-1 ring-black ring-opacity-5 dark:bg-gray-700">
<div class="p-3">
<div class="flex items-start">
<div class="flex-shrink-0">
<Icon/>
</div>
<div class="ml-3 flex-1 pt-0.5">
<p class="text-sm font-medium text-gray-900 dark:text-gray-400"><Topic/></p>
</div>
</div>
<Message/>
</div>
<WebUIJSBind Event={Uid}>
this.on('Remove', () => {
const doc = document.getElementById('<Uid/>');
doc.classList.remove('ease-out', 'duration-300');
doc.classList.add('ease-in', 'duration-100');
doc.classList.remove('opacity-100');
doc.classList.add('opacity-0');
setTimeout(() => {
doc.remove();
}, 100);
});
</WebUIJSBind>
</div>
,
""
} // StringRiffle
},

<|"Data" -> template, "ID" -> Uid|>
]
];


Component
5 changes: 1 addition & 4 deletions Components/Notifications/Components/Generic.wlx
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,7 @@ Script[OptionsPattern[]] := With[{Controller = OptionValue["Controller"], BackCo
setTimeout(() => {
element.classList.remove('translate-y-2', 'opacity-0', 'sm:translate-y-0', 'sm:translate-x-2');
element.classList.add('translate-y-0', 'opacity-100', 'sm:translate-x-0');
}, 30);



}, 30);

if (!("Timeout" in assoc)) {
acc_count += 1;
Expand Down
15 changes: 13 additions & 2 deletions Components/Notifications/Notifications.wlx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ ImportComponent["Components/Types.wl"];

MessageList = ImportComponent["Components/MessagesList.wlx"];
{SpinnerTemplate, SpinnerScript} = ImportComponent["Components/Spinner.wlx"];
CustomTemplate = ImportComponent["Components/Custom.wlx"];
{GenericTemplate, GenericScript} = ImportComponent["Components/Generic.wlx"];


Expand Down Expand Up @@ -61,6 +62,15 @@ Component[OptionsPattern[]] := Module[{buffer = {}, lastClient = Null}, With[{
EventFire[Controller, "Append", Join[<|"Client"->client, "Type"->"Spinner"|>, SpinnerTemplate[n, client, Controller]] ]
]
],

n_Notifications`Custom (*`*) :> Function[Null,

With[{client = $Client},
EventFire[Controller, "Append", Join[<|"Client"->client, "Type"->"Custom"|>, CustomTemplate[n, client, Controller]] ]
]
],



_Notifications`Rumble (*`*) -> Function[Null,
With[{client = $Client},
Expand Down Expand Up @@ -109,8 +119,9 @@ Component[OptionsPattern[]] := Module[{buffer = {}, lastClient = Null}, With[{
<SpinnerScript Controller={Controller}/>
,
<script type="module">
const audioCtx = new (window.AudioContext || window.webkitAudioContext)();

core.Beep = () => {
const audioCtx = new (window.AudioContext || window.webkitAudioContext)();
const oscillator = audioCtx.createOscillator();
oscillator.type = "triangle";
oscillator.frequency.setValueAtTime(440, audioCtx.currentTime);
Expand All @@ -130,7 +141,7 @@ Component[OptionsPattern[]] := Module[{buffer = {}, lastClient = Null}, With[{

core.HapticFeedback = () => {
if (!window.electronAPI) {console.warn('This is electron only feature'); return}
if (!window.electronAPI.harptic) {console.warn('Haptic feedback not supported'); return}
if (!window.electronAPI.harptic) {console.warn('Haptic feedback not supported in your App'); return}
window.electronAPI.harptic();
}
</script>
Expand Down
98 changes: 98 additions & 0 deletions Demos/04 - Animation/Atom with frame listener.wln
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
<|"Notebook" -> <|"FocusedCell" -> CellObj[JerryI`Notebook`CellObj`$98],
"HaveToSaveAs" -> False, "Objects" -> <||>, "Path" -> "/Users/kirill/Githu\
b/wolfram-js-frontend-dev/Demos/04 - Animation/Atom with frame listener.wln",
"Quick" -> True, "Symbols" ->
<|"light1" -> {0.7821723252011563, 4.938441702975688, 0},
"light2" -> {0.7821723252011563, -2.469220851487844, 4.276815969885432},
"light3" -> {3.2197086554931986, -2.948201623405119,
-2.4375363302920423}|>|>,
"Cells" ->
{<|"Data" -> ".md\n# Atom model animation\n*created by Kirill Belov*",
"Display" -> "codemirror", "Hash" ->
"8e5bafab-f2eb-4bb9-8f79-b4c5b3c17815", "Invisible" -> False,
"MetaOnly" -> False, "Props" -> <|"Hidden" -> True|>, "State" -> "Idle",
"Type" -> "Input", "UID" -> Null, "Notebook" ->
"492d93d1-09e4-4ddd-a4a9-1f524746aa7e"|>,
<|"Data" -> "># Atom model animation\n*created by Kirill Belov*",
"Display" -> "markdown", "Hash" ->
"e7679442-9e15-40a1-871e-4f6fb9e7f1a3", "Invisible" -> False,
"MetaOnly" -> False, "Props" -> <||>, "State" -> "Idle",
"Type" -> "Output", "UID" -> Null, "Notebook" ->
"492d93d1-09e4-4ddd-a4a9-1f524746aa7e"|>,
<|"Data" -> ".md\nPrecalculate paths of electrons",
"Display" -> "codemirror", "Hash" ->
"1ca43184-9b1b-4104-bea4-656d19c1bd86", "Invisible" -> False,
"MetaOnly" -> False, "Props" -> <|"Hidden" -> True|>, "State" -> "Idle",
"Type" -> "Input", "UID" -> Null, "Notebook" ->
"492d93d1-09e4-4ddd-a4a9-1f524746aa7e"|>,
<|"Data" -> ">Precalculate paths of electrons", "Display" -> "markdown",
"Hash" -> "bab1b977-6683-466b-b110-728af30d8793", "Invisible" -> False,
"MetaOnly" -> False, "Props" -> <||>, "State" -> "Idle",
"Type" -> "Output", "UID" -> Null, "Notebook" ->
"492d93d1-09e4-4ddd-a4a9-1f524746aa7e"|>,
<|"Data" -> "path1 = Table[{5 * Sin[t], 5 * Cos[t], 0}, {t, 0.0, 8*Pi, \
Pi/360.0}]; \nlight1 = path1[[1]]; \n\npath2 = RotationTransform[2Pi/3, {1, \
0, 0}] /@ path1; \nlight2 = path2[[1]]; \n\npath3 = RotationTransform[4Pi/3, \
{1, 0, 1}] /@ path1; \nlight3 = path3[[1]];", "Display" -> "codemirror",
"Hash" -> "d5258ba3-0228-42c9-a610-5c29e5573272", "Invisible" -> False,
"MetaOnly" -> False, "Props" -> <||>, "State" -> "Idle",
"Type" -> "Input", "UID" -> Null, "Notebook" ->
"492d93d1-09e4-4ddd-a4a9-1f524746aa7e"|>,
<|"Data" -> ".md\nSubscribe to a frame event", "Display" -> "codemirror",
"Hash" -> "52669e6c-07e6-4111-81c3-fae4dfedb974", "Invisible" -> False,
"MetaOnly" -> False, "Props" -> <|"Hidden" -> True|>, "State" -> "Idle",
"Type" -> "Input", "UID" -> Null, "Notebook" ->
"492d93d1-09e4-4ddd-a4a9-1f524746aa7e"|>,
<|"Data" -> ">Subscribe to a frame event", "Display" -> "markdown",
"Hash" -> "2ef737e4-dcd9-4e11-b126-9b1713e22095", "Invisible" -> False,
"MetaOnly" -> False, "Props" -> <||>, "State" -> "Idle",
"Type" -> "Output", "UID" -> Null, "Notebook" ->
"492d93d1-09e4-4ddd-a4a9-1f524746aa7e"|>,
<|"Data" -> "t := Mod[Round[AbsoluteTime[] * 100] + 1, \
Length[path1]]\n\nEventHandler[\"frame\", Function[Null,\n light1 = \
path1[[t]]; \n light2 = path2[[t]]; \n light3 = path3[[t]]; \n]];\n",
"Display" -> "codemirror", "Hash" ->
"0ebf8474-b364-4458-b661-fdb7b948b01b", "Invisible" -> False,
"MetaOnly" -> False, "Props" -> <||>, "State" -> "Idle",
"Type" -> "Input", "UID" -> Null, "Notebook" ->
"492d93d1-09e4-4ddd-a4a9-1f524746aa7e"|>,
<|"Data" -> ".md\nConstruct 3D graphics", "Display" -> "codemirror",
"Hash" -> "7a816888-7620-4fcc-a375-4ba968ab8999", "Invisible" -> False,
"MetaOnly" -> False, "Props" -> <|"Hidden" -> True|>, "State" -> "Idle",
"Type" -> "Input", "UID" -> Null, "Notebook" ->
"492d93d1-09e4-4ddd-a4a9-1f524746aa7e"|>,
<|"Data" -> ">Construct 3D graphics", "Display" -> "markdown",
"Hash" -> "f8ebe02d-c47a-4f9b-97f0-ea280e6c0f57", "Invisible" -> False,
"MetaOnly" -> False, "Props" -> <||>, "State" -> "Idle",
"Type" -> "Output", "UID" -> Null, "Notebook" ->
"492d93d1-09e4-4ddd-a4a9-1f524746aa7e"|>,
<|"Data" -> "Graphics3D[{ \n { \n \
MeshMaterial[MeshPhysicalMaterial[]], \n Roughness[0.1], \n \
Sphere[] \n }, \n { \n PointLight[Cyan, Offload @ light1], \n \
PointLight[Magenta, Offload @ light2], \n PointLight[Orange, Offload @ \
light3] \n }, \n { \n Emissive[Cyan, 5], Sphere[Offload @ light1, \
0.1], \n Emissive[Magenta, 5], Sphere[Offload @ light2, 0.1], \n \
Emissive[Orange, 5], Sphere[Offload @ light3, 0.1],\n \
AnimationFrameListener[Offload @ light3, \"Event\" -> \"frame\"]\n }, \n \
{ \n LightBlue, Line[path1], \n LightRed, Line[path2], \n \
LightGreen, Line[path3] \n } \n}, \n PlotRange -> {{-10, 10}, {-10, \
10}, {-10, 10}}, \n Lighting -> None \n] ", "Display" -> "codemirror",
"Hash" -> "4ea052a6-a70a-47c5-b7d5-177a4984e34d", "Invisible" -> False,
"MetaOnly" -> False, "Props" -> <||>, "State" -> "Idle",
"Type" -> "Input", "UID" -> Null, "Notebook" ->
"492d93d1-09e4-4ddd-a4a9-1f524746aa7e"|>,
<|"Data" -> ".md\nCancel animation", "Display" -> "codemirror",
"Hash" -> "7ab032f2-d282-487c-9c98-a499f2188968", "Invisible" -> False,
"MetaOnly" -> False, "Props" -> <|"Hidden" -> True|>, "State" -> "Idle",
"Type" -> "Input", "UID" -> Null, "Notebook" ->
"492d93d1-09e4-4ddd-a4a9-1f524746aa7e"|>,
<|"Data" -> ">Cancel animation", "Display" -> "markdown",
"Hash" -> "23ec6eb4-f609-4709-8af0-5a58bdab17cb", "Invisible" -> False,
"MetaOnly" -> False, "Props" -> <||>, "State" -> "Idle",
"Type" -> "Output", "UID" -> Null, "Notebook" ->
"492d93d1-09e4-4ddd-a4a9-1f524746aa7e"|>,
<|"Data" -> "EventRemove[\"frame\"]", "Display" -> "codemirror",
"Hash" -> "aae18bf4-9cb1-42b9-88e9-6dcc332a6e7e", "Invisible" -> False,
"MetaOnly" -> False, "Props" -> <||>, "State" -> "Idle",
"Type" -> "Input", "UID" -> Null, "Notebook" ->
"492d93d1-09e4-4ddd-a4a9-1f524746aa7e"|>}, "serializer" -> "jsfn4"|>
Loading

0 comments on commit 0e95b38

Please sign in to comment.