From c1b7476f433d96ad204960f65991a333862a9e98 Mon Sep 17 00:00:00 2001 From: Felix Roos Date: Fri, 8 Dec 2023 22:22:07 +0100 Subject: [PATCH] + show active pattern at the top + move active pattern functions to top --- website/src/repl/panel/PatternsTab.jsx | 80 ++++++++++++++++---------- 1 file changed, 51 insertions(+), 29 deletions(-) diff --git a/website/src/repl/panel/PatternsTab.jsx b/website/src/repl/panel/PatternsTab.jsx index 37cac6f7..124ba400 100644 --- a/website/src/repl/panel/PatternsTab.jsx +++ b/website/src/repl/panel/PatternsTab.jsx @@ -1,4 +1,4 @@ -import React from 'react'; +import { useMemo } from 'react'; import * as tunes from '../tunes.mjs'; import { useSettings, @@ -12,6 +12,7 @@ import { addUserPattern, } from '../../settings.mjs'; import { logger } from '@strudel.cycles/core'; +import { DocumentDuplicateIcon, PencilSquareIcon, TrashIcon } from '@heroicons/react/20/solid'; function classNames(...classes) { return classes.filter(Boolean).join(' '); @@ -19,10 +20,50 @@ function classNames(...classes) { export function PatternsTab({ context }) { const { userPatterns, activePattern } = useSettings(); + const isExample = useMemo(() => activePattern && !!tunes[activePattern], [activePattern]); return (
-
+ {activePattern && ( +
+

{activePattern}

+
+ + {!isExample && ( + + )} + {!isExample && ( + + )} +
+
+ )} +
+ {Object.entries(userPatterns).map(([key, up]) => ( + { + const { code } = up; + setActivePattern(key); + context.handleUpdate(code, true); + }} + > + {key} + + ))} +
+
- - - @@ -66,24 +98,14 @@ export function PatternsTab({ context }) { /> import -
-
- {Object.entries(userPatterns).map(([key, up]) => ( - { - const { code } = up; - setActivePattern(key); - context.handleUpdate(code, true); - }} - > - {key} - - ))} +