mirror of
https://github.com/eliasstepanik/strudel.git
synced 2026-01-11 05:38:35 +00:00
prettier
This commit is contained in:
parent
47f65da621
commit
f47f5c1344
@ -36,12 +36,17 @@ export function Incrementor({ onChange, value, min = -Infinity, max = Infinity,
|
|||||||
className="w-32 my-0 border-none rounded-r-none bg-transparent appearance-none [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none"
|
className="w-32 my-0 border-none rounded-r-none bg-transparent appearance-none [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none"
|
||||||
/>
|
/>
|
||||||
<div className="flex gap-1 ">
|
<div className="flex gap-1 ">
|
||||||
<IncButton label={'increment'} disabled={value <= min} onClick={() => onChange(value - 1)}>
|
<IncButton label={'increment'} disabled={value <= min} onClick={() => onChange(value - 1)}>
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor" className="w-4 h-4">
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor" className="w-4 h-4">
|
||||||
<path d="M3.75 7.25a.75.75 0 0 0 0 1.5h8.5a.75.75 0 0 0 0-1.5h-8.5Z" />
|
<path d="M3.75 7.25a.75.75 0 0 0 0 1.5h8.5a.75.75 0 0 0 0-1.5h-8.5Z" />
|
||||||
</svg>
|
</svg>
|
||||||
</IncButton>
|
</IncButton>
|
||||||
<IncButton label={'decrement'} className="rounded-r-md" disabled={value >= max} onClick={() => onChange(value + 1)}>
|
<IncButton
|
||||||
|
label={'decrement'}
|
||||||
|
className="rounded-r-md"
|
||||||
|
disabled={value >= max}
|
||||||
|
onClick={() => onChange(value + 1)}
|
||||||
|
>
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor" className="w-4 h-4">
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor" className="w-4 h-4">
|
||||||
<path d="M8.75 3.75a.75.75 0 0 0-1.5 0v3.5h-3.5a.75.75 0 0 0 0 1.5h3.5v3.5a.75.75 0 0 0 1.5 0v-3.5h3.5a.75.75 0 0 0 0-1.5h-3.5v-3.5Z" />
|
<path d="M8.75 3.75a.75.75 0 0 0-1.5 0v3.5h-3.5a.75.75 0 0 0 0 1.5h3.5v3.5a.75.75 0 0 0 1.5 0v-3.5h3.5a.75.75 0 0 0 0-1.5h-3.5v-3.5Z" />
|
||||||
</svg>
|
</svg>
|
||||||
|
|||||||
@ -196,7 +196,7 @@ function PatternPageWithPagination({ patterns, patternOnClick, context, paginati
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let featuredPageNum = 1
|
let featuredPageNum = 1;
|
||||||
function FeaturedPatterns({ context }) {
|
function FeaturedPatterns({ context }) {
|
||||||
const examplePatterns = useExamplePatterns();
|
const examplePatterns = useExamplePatterns();
|
||||||
const collections = examplePatterns.collections;
|
const collections = examplePatterns.collections;
|
||||||
@ -215,13 +215,13 @@ function FeaturedPatterns({ context }) {
|
|||||||
}}
|
}}
|
||||||
paginationOnChange={async (pageNum) => {
|
paginationOnChange={async (pageNum) => {
|
||||||
await loadAndSetFeaturedPatterns(pageNum);
|
await loadAndSetFeaturedPatterns(pageNum);
|
||||||
featuredPageNum = pageNum
|
featuredPageNum = pageNum;
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let latestPageNum = 1
|
let latestPageNum = 1;
|
||||||
function LatestPatterns({ context }) {
|
function LatestPatterns({ context }) {
|
||||||
const examplePatterns = useExamplePatterns();
|
const examplePatterns = useExamplePatterns();
|
||||||
const collections = examplePatterns.collections;
|
const collections = examplePatterns.collections;
|
||||||
@ -236,7 +236,7 @@ function LatestPatterns({ context }) {
|
|||||||
}}
|
}}
|
||||||
paginationOnChange={async (pageNum) => {
|
paginationOnChange={async (pageNum) => {
|
||||||
await loadAndSetPublicPatterns(pageNum);
|
await loadAndSetPublicPatterns(pageNum);
|
||||||
latestPageNum = pageNum
|
latestPageNum = pageNum;
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|||||||
@ -29,7 +29,7 @@ export function Reference() {
|
|||||||
<div className="flex h-full w-full p-2 text-foreground overflow-hidden">
|
<div className="flex h-full w-full p-2 text-foreground overflow-hidden">
|
||||||
<div className="h-full flex flex-col gap-2 w-1/3 max-w-72 ">
|
<div className="h-full flex flex-col gap-2 w-1/3 max-w-72 ">
|
||||||
<div class="w-full flex">
|
<div class="w-full flex">
|
||||||
<Textbox placeholder="Search" value={search} onChange={setSearch}/>
|
<Textbox placeholder="Search" value={search} onChange={setSearch} />
|
||||||
</div>
|
</div>
|
||||||
<div className="flex flex-col h-full overflow-y-auto gap-1.5 bg-background bg-opacity-50 rounded-md">
|
<div className="flex flex-col h-full overflow-y-auto gap-1.5 bg-background bg-opacity-50 rounded-md">
|
||||||
{visibleFunctions.map((entry, i) => (
|
{visibleFunctions.map((entry, i) => (
|
||||||
|
|||||||
@ -54,11 +54,7 @@ export function SoundsTab() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div id="sounds-tab" className="px-4 flex flex-col w-full h-full dark:text-white text-stone-900">
|
<div id="sounds-tab" className="px-4 flex flex-col w-full h-full dark:text-white text-stone-900">
|
||||||
<Textbox
|
<Textbox placeholder="Search" value={search} onChange={(v) => setSearch(v)} />
|
||||||
placeholder="Search"
|
|
||||||
value={search}
|
|
||||||
onChange={(v) => setSearch(v)}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<div className="pb-2 flex shrink-0 flex-wrap">
|
<div className="pb-2 flex shrink-0 flex-wrap">
|
||||||
<ButtonGroup
|
<ButtonGroup
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { $featuredPatterns, $publicPatterns, patternFilterName } from '../user_pattern_utils.mjs';
|
import { $featuredPatterns, $publicPatterns, patternFilterName } from '../user_pattern_utils.mjs';
|
||||||
import { useStore } from '@nanostores/react';
|
import { useStore } from '@nanostores/react';
|
||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
import * as tunes from '../repl/tunes.mjs';
|
import * as tunes from '../repl/tunes.mjs';
|
||||||
|
|||||||
@ -199,4 +199,3 @@ export function setVersionDefaultsFrom(code) {
|
|||||||
console.error(err);
|
console.error(err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -8,8 +8,7 @@ import { confirmDialog, parseJSON, supabase } from './repl/util.mjs';
|
|||||||
export let $publicPatterns = atom([]);
|
export let $publicPatterns = atom([]);
|
||||||
export let $featuredPatterns = atom([]);
|
export let $featuredPatterns = atom([]);
|
||||||
|
|
||||||
|
const patternQueryLimit = 20;
|
||||||
const patternQueryLimit = 20
|
|
||||||
export const patternFilterName = {
|
export const patternFilterName = {
|
||||||
public: 'latest',
|
public: 'latest',
|
||||||
featured: 'featured',
|
featured: 'featured',
|
||||||
@ -49,40 +48,49 @@ export const setViewingPatternData = (data) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function parsePageNum(page) {
|
function parsePageNum(page) {
|
||||||
return isNaN(page) ? 0 : page
|
return isNaN(page) ? 0 : page;
|
||||||
}
|
}
|
||||||
export function loadPublicPatterns(page) {
|
export function loadPublicPatterns(page) {
|
||||||
page = parsePageNum(page)
|
page = parsePageNum(page);
|
||||||
const offset = page * patternQueryLimit
|
const offset = page * patternQueryLimit;
|
||||||
return supabase.from('code_v1').select().eq('public', true).range(offset, offset + patternQueryLimit ).order('id', { ascending: false });
|
return supabase
|
||||||
|
.from('code_v1')
|
||||||
|
.select()
|
||||||
|
.eq('public', true)
|
||||||
|
.range(offset, offset + patternQueryLimit)
|
||||||
|
.order('id', { ascending: false });
|
||||||
}
|
}
|
||||||
|
|
||||||
export function loadFeaturedPatterns(page = 0) {
|
export function loadFeaturedPatterns(page = 0) {
|
||||||
page = parsePageNum(page)
|
page = parsePageNum(page);
|
||||||
const offset = page * patternQueryLimit
|
const offset = page * patternQueryLimit;
|
||||||
return supabase.from('code_v1').select().eq('featured', true).range(offset, offset + patternQueryLimit).order('id', { ascending: false });
|
return supabase
|
||||||
|
.from('code_v1')
|
||||||
|
.select()
|
||||||
|
.eq('featured', true)
|
||||||
|
.range(offset, offset + patternQueryLimit)
|
||||||
|
.order('id', { ascending: false });
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function loadAndSetPublicPatterns(page) {
|
export async function loadAndSetPublicPatterns(page) {
|
||||||
const p = await loadPublicPatterns(page);
|
const p = await loadPublicPatterns(page);
|
||||||
const data = p?.data
|
const data = p?.data;
|
||||||
const pats = {}
|
const pats = {};
|
||||||
data?.forEach((data, key) => (pats[data.id ?? key] = data));
|
data?.forEach((data, key) => (pats[data.id ?? key] = data));
|
||||||
$publicPatterns.set(pats)
|
$publicPatterns.set(pats);
|
||||||
}
|
}
|
||||||
export async function loadAndSetFeaturedPatterns(page) {
|
export async function loadAndSetFeaturedPatterns(page) {
|
||||||
|
|
||||||
const p = await loadFeaturedPatterns(page);
|
const p = await loadFeaturedPatterns(page);
|
||||||
const data = p?.data
|
const data = p?.data;
|
||||||
const pats = {}
|
const pats = {};
|
||||||
data?.forEach((data, key) => (pats[data.id ?? key] = data));
|
data?.forEach((data, key) => (pats[data.id ?? key] = data));
|
||||||
$featuredPatterns.set(pats)
|
$featuredPatterns.set(pats);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function loadDBPatterns() {
|
export async function loadDBPatterns() {
|
||||||
try {
|
try {
|
||||||
await loadAndSetPublicPatterns()
|
await loadAndSetPublicPatterns();
|
||||||
await loadAndSetFeaturedPatterns()
|
await loadAndSetFeaturedPatterns();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('error loading patterns', err);
|
console.error('error loading patterns', err);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,8 +2,6 @@
|
|||||||
|
|
||||||
const defaultTheme = require('tailwindcss/defaultTheme');
|
const defaultTheme = require('tailwindcss/defaultTheme');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
darkMode: 'class',
|
darkMode: 'class',
|
||||||
content: [
|
content: [
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
// utility for combining class names
|
// utility for combining class names
|
||||||
export function cn(...classes) {
|
export function cn(...classes) {
|
||||||
return classes.filter(Boolean).join(' ');
|
return classes.filter(Boolean).join(' ');
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user