From 71871901ef3c33d640391c1fe7ed88ef196d3280 Mon Sep 17 00:00:00 2001 From: k Date: Wed, 27 Nov 2024 18:36:43 +0100 Subject: [PATCH] website: update --- website/index.html | 5 +- website/scripts/main.js | 20 +-- website/scripts/simulation.js | 303 +++++++++++++++++++++----------- website/scripts/types/self.d.ts | 3 + 4 files changed, 216 insertions(+), 115 deletions(-) diff --git a/website/index.html b/website/index.html index db43348b8..98e367145 100644 --- a/website/index.html +++ b/website/index.html @@ -252,7 +252,6 @@ --fuchsia: oklch(0.629 0.294 322.523); --pink: oklch(0.624 0.245 357.444); --rose: oklch(0.6155 0.2495 17.012); - --dollar: var(--green); --background-color: light-dark(var(--white), var(--black)); --color: light-dark(var(--black), var(--white)); --off-color: light-dark(var(--light-gray), var(--dark-gray)); @@ -654,11 +653,11 @@ -webkit-appearance: none; -moz-appearance: none; appearance: none; - background: url('data:image/svg+xml;utf-8,') + background: url('data:image/svg+xml;utf-8,') 100% 50% no-repeat transparent; &:focus-visible { - border: none; + border: 0; } } diff --git a/website/scripts/main.js b/website/scripts/main.js index 497507d18..b648f2023 100644 --- a/website/scripts/main.js +++ b/website/scripts/main.js @@ -1,7 +1,7 @@ // @ts-check /** - * @import { Option, ResourceDataset, TimeScale, TimeRange, Unit, Marker, Weighted, DatasetPath, OHLC, FetchedJSON, DatasetValue, FetchedResult, AnyDatasetPath, SeriesBlueprint, BaselineSpecificSeriesBlueprint, CandlestickSpecificSeriesBlueprint, LineSpecificSeriesBlueprint, SpecificSeriesBlueprintWithChart, Signal, Color, DatasetCandlestickData, PartialChartOption, ChartOption, AnyPartialOption, ProcessedOptionAddons, OptionsTree, AnyPath, SimulationOption, Frequency, CreatePaneParameters, CreateBaselineSeriesParams, CreateCandlestickSeriesParams, CreateLineSeriesParams } from "./types/self" + * @import { Option, ResourceDataset, TimeScale, TimeRange, Unit, Marker, Weighted, DatasetPath, OHLC, FetchedJSON, DatasetValue, FetchedResult, AnyDatasetPath, SeriesBlueprint, BaselineSpecificSeriesBlueprint, CandlestickSpecificSeriesBlueprint, LineSpecificSeriesBlueprint, SpecificSeriesBlueprintWithChart, Signal, Color, DatasetCandlestickData, PartialChartOption, ChartOption, AnyPartialOption, ProcessedOptionAddons, OptionsTree, AnyPath, SimulationOption, Frequency, CreatePaneParameters, CreateBaselineSeriesParams, CreateCandlestickSeriesParams, CreateLineSeriesParams, LastValues } from "./types/self" * @import {createChart as CreateClassicChart, createChartEx as CreateCustomChart, LineStyleOptions} from "../packages/lightweight-charts/v4.2.0/types"; * @import * as _ from "../packages/ufuzzy/v1.0.14/types" * @import { DeepPartial, ChartOptions, IChartApi, IHorzScaleBehavior, WhitespaceData, SingleValueData, ISeriesApi, Time, LineData, LogicalRange, SeriesMarker, CandlestickData, SeriesType, BaselineStyleOptions, SeriesOptionsCommon } from "../packages/lightweight-charts/v4.2.0/types" @@ -665,8 +665,7 @@ function initPackages() { const chartModes = /** @type {const} */ (["Linear", "Log"]); const chartMode = signals.createSignal( /** @type {Lowercase} */ ( - localStorage.getItem(id) || - chartModes[chartIndex ? 0 : 1].toLowerCase() + localStorage.getItem(id) || "linear" ), ); @@ -2048,6 +2047,8 @@ function createColors(dark) { blue, rose, pink, + green, + purple, _1d: pink, _1w: red, @@ -2138,7 +2139,6 @@ function createColors(dark) { coinblocksCreated: purple, coinblocksDestroyed: red, coinblocksStored: green, - momentum: [green, yellow, red], momentumGreen: green, momentumYellow: yellow, momentumRed: red, @@ -2703,9 +2703,8 @@ packages.signals().then((signals) => } const lastHeight = createLastHeightResource(); - const lastValues = signals.createSignal( - /** @type {Record | null} */ (null), - ); + const lastValues = signals.createSignal(/** @type {LastValues} */ (null)); + function createFetchLastValuesWhenNeededEffect() { let previousHeight = -1; signals.createEffect(lastHeight, (lastHeight) => { @@ -2831,17 +2830,12 @@ packages.signals().then((signals) => signals.runWithOwner(owner, () => init({ colors, - consts, - dark, datasets, elements, - ids, lightweightCharts, - options, - selected: option, signals, utils, - webSockets, + lastValues, }), ), ), diff --git a/website/scripts/simulation.js b/website/scripts/simulation.js index 3c0306830..96c76eda2 100644 --- a/website/scripts/simulation.js +++ b/website/scripts/simulation.js @@ -1,35 +1,26 @@ /** - * @import {Options} from './options'; + * @import { Options } from './options'; + * @import { ColorName } from './types/self'; */ /** * @param {Object} args * @param {Colors} args.colors - * @param {Consts} args.consts * @param {LightweightCharts} args.lightweightCharts - * @param {SimulationOption} args.selected * @param {Signals} args.signals * @param {Utilities} args.utils - * @param {Options} args.options * @param {Datasets} args.datasets - * @param {WebSockets} args.webSockets * @param {Elements} args.elements - * @param {Ids} args.ids - * @param {Accessor} args.dark + * @param {Signal} args.lastValues */ export function init({ colors, - consts, - dark, datasets, elements, - ids, lightweightCharts, - options, - selected, signals, utils, - webSockets, + lastValues, }) { const simulationElement = elements.simulation; @@ -137,6 +128,25 @@ export function init({ }).headerElement, ); + /** + * @param {Object} param0 + * @param {ColorName} param0.color + * @param {string} param0.type + * @param {string} param0.text + */ + function createColoredTypeHTML({ color, type, text }) { + return `${createColoredSpan({ color, text: `${type}:` })} ${text}`; + } + + /** + * @param {Object} param0 + * @param {ColorName} param0.color + * @param {string} param0.text + */ + function createColoredSpan({ color, text }) { + return `${text}`; + } + parametersElement.append( createFieldElement({ title: createColoredTypeHTML({ @@ -291,9 +301,10 @@ export function init({ }), ); - const firstParagraph = window.document.createElement("p"); - - const secondParagraph = window.document.createElement("p"); + const p1 = window.document.createElement("p"); + const p2 = window.document.createElement("p"); + const p3 = window.document.createElement("p"); + const p4 = window.document.createElement("p"); const owner = signals.getOwner(); @@ -326,8 +337,9 @@ export function init({ console.log({ start, end }); resultsElement.innerHTML = ""; - resultsElement.append(firstParagraph); - resultsElement.append(secondParagraph); + resultsElement.append(p1); + resultsElement.append(p2); + resultsElement.append(p3); if (!start || !end || start > end) return; @@ -361,6 +373,8 @@ export function init({ const daysCountData = []; /** @type {LineData